Skip to content

Language: parent::__construct() with no ctor throws Cannot call constructor (#25909) - #25919

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-25909-parent-construct-no-ctor
Jul 31, 2026
Merged

Language: parent::__construct() with no ctor throws Cannot call constructor (#25909)#25919
PurHur merged 1 commit into
masterfrom
agent/issue-25909-parent-construct-no-ctor

Conversation

@PurHur

@PurHur PurHur commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • When parent::__construct() / Class::__construct() targets a class with no constructor, throw Zend’s Error: Cannot call constructor instead of Call to undefined static method ….
  • Do not fall through to __callStatic for missing __construct (php-src zend_object_handlers.c).
  • VM (initStaticCallable) + JIT (initJitStaticCall); inherited parent ctors unchanged.

Closes #25909

Test plan

  • Zend / VM / JIT on test/repro/issue_25909_parent_construct_no_ctor.phpError:Cannot call constructor (+ named form)
  • __callStatic present still yields Cannot call constructor (matches Zend)
  • php vendor/bin/phpunit --filter ParentConstructNoCtorTest → OK (3 tests)
  • Inherited parent::__construct() still runs grandparent ctor

Verification

ZEND/VM/JIT:
Error:Cannot call constructor
named:Cannot call constructor

OK (3 tests, 9 assertions)

Refs Zend/zend_object_handlers.c, Zend/zend_execute.c

Made with Cursor

…ructor (#25909)

Match Zend when parent/Class::__construct() targets a class with no constructor:
emit Error "Cannot call constructor" instead of undefined-static-method, and do
not fall through to __callStatic.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur force-pushed the agent/issue-25909-parent-construct-no-ctor branch from 1fca2dd to 16d78be Compare July 31, 2026 10:56
@PurHur
PurHur merged commit 9ebe2ce into master Jul 31, 2026
@PurHur
PurHur deleted the agent/issue-25909-parent-construct-no-ctor branch July 31, 2026 10:56
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: parent::__construct() with no parent ctor — wrong Error (Zend Cannot call constructor)

1 participant