Skip to content

Language: Zend null-default typed property fatal suggests ?T (#31820) - #31827

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-31820-null-default-typed-prop-msg
Aug 17, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-31820-null-default-typed-prop-msg

Conversation

@PurHur

@PurHur PurHur commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Summary

php-src reference

  • Zend/zend_compile.c — typed property default null check (“Use the nullable type ?%s …”)
  • PHP: lib/Compiler.php (throwTypedDefaultMismatch)

Test plan

  • Issue repro (VM)
  • Multi-type spot check (int/string/float/bool/class + nullable ok)
  • ./script/phpunit.sh --filter TypedPropNullDefaultFatal31820 (VM + JIT)

Verification

$ ./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_null_default_typed_prop.php' ; echo EXIT:$?
parseAndCompile failure: target=/compiler/test/repro/maintainer_gap_null_default_typed_prop.php: Default value for property of type int may not be null. Use the nullable type ?int to allow null default value
EXIT:255

$ ./script/phpunit.sh --filter TypedPropNullDefaultFatal31820
OK (4 tests, 6 assertions)

Not covered: full VMTest/JITTest suites; union-type null defaults (still early-return in assert path).

Made with Cursor

Match zend_compile.c wording for non-nullable property defaults of null;
keep ?T = null accepted. Guard with dedicated VM/JIT compliance cases.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 4760fdd into master Aug 17, 2026
1 check failed
@PurHur
PurHur deleted the agent/issue-31820-null-default-typed-prop-msg branch August 17, 2026 04:42
PurHur added a commit that referenced this pull request Aug 17, 2026
…ollow-up)

#31827 matched Zend’s message text but still printed parseAndCompile failure.
Pass property source location so CLI shows PHP Fatal error: like zend_compile.c.

Co-authored-by: Cursor <cursoragent@cursor.com>
PurHur added a commit that referenced this pull request Aug 17, 2026
…ollow-up) (#31829)

#31827 matched Zend’s message text but still printed parseAndCompile failure.
Pass property source location so CLI shows PHP Fatal error: like zend_compile.c.

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Language: null default on non-nullable typed property fatal message — Zend suggests ?T (zend_compile.c)

1 participant