Skip to content

Fix ArrayObject getIteratorClass() after void setIteratorClass() (#10778) - #10800

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-10778-arrayobject-get-iterator-class
Jun 23, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-10778-arrayobject-get-iterator-class

Conversation

@PurHur

@PurHur PurHur commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

php-src reference: ext/spl/spl_array.c — spl_array_setIteratorClass / spl_array_getIteratorClass

PHP implementation: lib/Compiler.php (filterDeadVoidStatementMethodCallProducers), ext/spl/ArrayObjectBuiltin.php

Closes #10778

Test plan

  • Issue repro:
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_gap_arrayobject_getiterator_after_set.php
php bin/vm.php test/repro/maintainer_gap_arrayobject_get_iterator_class.php
'

Output (VM):

'ArrayIterator'
'ArrayIterator'
'ArrayIterator'
TypeError: ArrayObject::setIteratorClass(): Argument #1 ($iteratorClass) must be a class name derived from ArrayIterator, stdClass given

(both repros exit 0)

  • Compliance:
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./vendor/bin/phpunit --filter arrayobject_getiterator_after_set'

OK (2 tests, 2 assertions)

Made with Cursor

).

Skip dead void MethodCall inline producers so var_export($ao->getIteratorClass(), true)
binds the getter result, and run setIteratorClass validation when returnVar is null.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 3217c68 into master Jun 23, 2026
@PurHur
PurHur deleted the agent/issue-10778-arrayobject-get-iterator-class branch June 23, 2026 12:24
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.

Stdlib: ArrayObject::getIteratorClass() returns null after void setIteratorClass() in expression (ext/spl/spl_array.c)

1 participant