Category
Regression · php-src-strict · nested new + arrow-fn callback (re-#13180 / #6692)
Problem
new CallbackFilterIterator(new ArrayIterator([1,2,3,4]), fn($v) => $v % 2 === 0) fatals on VM with LogicException: Call to undefined method ArrayIterator::__invoke(). Zend filters to 2,4. Binding the iterator and/or Closure to locals first matches Zend — the nested-new + inline arrow form misbinds the callback (iterator object used as callable) (2026-07-16).
| Repro |
Zend 8.2+ |
VM (2026-07-16) |
new CallbackFilterIterator(new ArrayIterator([1,2,3,4]), fn($v)=>$v%2===0) |
2,4 |
LogicException: Call to undefined method ArrayIterator::__invoke() |
$inner=...; $cb=fn...; new CallbackFilterIterator($inner,$cb) |
2,4 |
2,4 |
string callback "even" |
2,4 |
2,4 |
php-src reference
PHP implementation target
Repro
./script/docker-exec.sh -- bash -lc 'php test/repro/callback_filter_iterator_arrow_nested.php; php bin/vm.php test/repro/callback_filter_iterator_arrow_nested.php'
<?php
error_reporting(E_ALL);
try {
$it = new CallbackFilterIterator(new ArrayIterator([1, 2, 3, 4]), fn($v) => $v % 2 === 0);
echo implode(',', iterator_to_array($it, false)) . "\n";
} catch (Throwable $e) {
echo get_class($e) . ': ' . $e->getMessage() . "\n";
}
Done when
Category
Regression· php-src-strict · nestednew+ arrow-fn callback (re-#13180 / #6692)Problem
new CallbackFilterIterator(new ArrayIterator([1,2,3,4]), fn($v) => $v % 2 === 0)fatals on VM withLogicException: Call to undefined method ArrayIterator::__invoke(). Zend filters to2,4. Binding the iterator and/or Closure to locals first matches Zend — the nested-new+ inline arrow form misbinds the callback (iterator object used as callable) (2026-07-16).new CallbackFilterIterator(new ArrayIterator([1,2,3,4]), fn($v)=>$v%2===0)2,4LogicException: Call to undefined method ArrayIterator::__invoke()$inner=...; $cb=fn...; new CallbackFilterIterator($inner,$cb)2,42,4"even"2,42,4php-src reference
ext/spl/spl_iterators.c—CallbackFilterIterator::__construct(Iterator $iterator, callable $callback)PHP implementation target
lib/Compiler.php— nestednewas arg0 must not steal arg1 Closure/arrow (same nested-ctor family as Language: nested new as first ctor arg + second arg — Traversable TypeError / mode dropped (Zend/zend_compile.c) #19439)ext/spl/CallbackFilterIterator accept/__invokepath — call the real callback; no C runtime growthRepro
./script/docker-exec.sh -- bash -lc 'php test/repro/callback_filter_iterator_arrow_nested.php; php bin/vm.php test/repro/callback_filter_iterator_arrow_nested.php'Done when
2,4matching Zend; exit 0.phptundertest/compliance/cases/spl/