Skip to content

Stdlib: settype() uninitialized typed property by-ref — Error not LogicException (#13884) - #13889

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-13884-settype-uninit-typed-byref
Jun 30, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-13884-settype-uninit-typed-byref

Conversation

@PurHur

@PurHur PurHur commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add TypedPropertyCheck::assertWritableByReference() for Zend's by-reference guard on uninitialized non-nullable typed properties (ext/standard/type.c, Zend/zend_types.c).
  • VmSettype::apply() invokes the guard before coercion so settype($o->x, 'int') throws the Zend Error text instead of a builtin LogicException.

Closes #13884

Verification

./script/docker-exec.sh -- bash -lc '
  php test/repro/maintainer_gap_settype_uninitialized_typed.php
  php bin/vm.php test/repro/maintainer_gap_settype_uninitialized_typed.php
  php bin/compile.php -l test/repro/maintainer_gap_settype_uninitialized_typed.php
  ./vendor/bin/phpunit --filter settype_uninit_typed_byref test/compliance/
'

Output:

Cannot access uninitialized non-nullable property C::$x by reference

PHPUnit (Docker): OK (3 tests, 3 assertions) — VM + JIT compliance.

Made with Cursor

…3884).

Add TypedPropertyCheck::assertWritableByReference and invoke it from VmSettype before coercion so Zend's by-reference Error replaces the builtin LogicException.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 75b173f into master Jun 30, 2026
@PurHur
PurHur deleted the agent/issue-13884-settype-uninit-typed-byref branch June 30, 2026 01:17
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: settype() on uninitialized typed property by-ref — LogicException not Error (ext/standard/type.c)

1 participant