Skip to content

Prevent "undefined index" notice if $parts array is empty in Index\Index#removeIndexedDefinition#750

Open
asccc wants to merge 1 commit into
felixfbecker:masterfrom
asccc:master
Open

Prevent "undefined index" notice if $parts array is empty in Index\Index#removeIndexedDefinition#750
asccc wants to merge 1 commit into
felixfbecker:masterfrom
asccc:master

Conversation

@asccc

@asccc asccc commented Aug 1, 2019

Copy link
Copy Markdown

If $level reaches 0 with only one more element in the $parts array, the next call to array_slice($parts, 0, $level) will return an empty array. This will trigger a "undefined index" notice in the next recursion on $part = $parts[$level]. This notice gets promoted to an ErrorException in the error-handler (if the local php.ini is configured to report notices) which will cancel further processing.

Fixes #695

If `$level` reaches 0, `array_slice($parts, 0, $level)` returns an empty array. This will issue a "undefined index notice" in the next recursion on `$part = $parts[$level]`. This notice gets transformed to an ErrorException which will cancel further analysis.
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.09%. Comparing base (9dc1656) to head (5a4605f).

Files with missing lines Patch % Lines
src/Index/Index.php 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #750      +/-   ##
============================================
- Coverage     82.12%   82.09%   -0.03%     
- Complexity      935      936       +1     
============================================
  Files            44       44              
  Lines          2154     2156       +2     
============================================
+ Hits           1769     1770       +1     
- Misses          385      386       +1     
Files with missing lines Coverage Δ
src/Index/Index.php 76.19% <0.00%> (-1.23%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Undefined Offset: 0

1 participant