sebastianbergmann / recursion-context

Provides functionality to recursively process PHP variables
BSD 3-Clause "New" or "Revised" License
6.52k stars 18 forks source link

Undefined index in context.php #5

Closed philcross closed 7 years ago

philcross commented 7 years ago

We've suddenly got a lot a lot of issues with context.php issuing an undefined index notice:

notice: Undefined offset: 1 in vendor/sebastian/recursion-context/src/Context.php line 141

Looks like the latest branch 1.0.3 has broken it, reverted to 1.0.2 and is working again.

sebastianbergmann commented 7 years ago

@bwoebi Can you have a look?

iMega commented 7 years ago

See https://github.com/sebastianbergmann/recursion-context/pull/6

weierophinney commented 7 years ago

I can confirm; see a recent zend-expressive test run. Tests pass on previous versions, but not against 1.0.3.

bwoebi commented 7 years ago

Weird, I cannot reproduce this locally (I tried with zend-expressive and recursion context 1.0.3). Also, how can index 1 not be set? array_splice() is returning an array keyed incrementally from 0 up (by default).

And the line there is count($end) != 2 || $end[1] !== 2 ? false : $end[0] … i.e. if there's less than two elements, $end[1] should not be accessed?!

bwoebi commented 7 years ago

… oh, array_slice is preserving non-numeric keys… yeah, #6 should fix it then.

khoanhd commented 7 years ago

it works right now, thanks.