Skip to content

Fix static closure bindTo fatal + restore Error parity (#4613) - #10425

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-4613-static-closure-bind-return-type
Jun 21, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-4613-static-closure-bind-return-type

Conversation

@PurHur

@PurHur PurHur commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix VM::returnTypeCallableName() to read func->class->value instead of concatenating the PHPCfg\Operand\Literal object — unblocks methods with class return types such as make(): Closure.
  • Reopened Language: static closure bindTo()/bind() with $this must Error (Zend/zend_closures.c parity) #4613: static Closure::bindTo() / Closure::bind() with $this now reach the existing ClosureSupport guard and throw Error: Cannot bind static closure to object on VM and JIT (was fatal before bind path ran).
  • Adjust compliance/repro catch blocks to catch (Error) without $e to avoid unrelated catch-slot warning noise in output comparison.

php-src reference

  • Zend/zend_closures.c — zend_closure_bind() static-closure guard

PHP implementation

  • lib/VM.php — returnTypeCallableName()
  • lib/VM/ClosureSupport.php — existing static closure Error (unchanged)

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/compliance/cases/language/static_closure_bind.phpt
php bin/jit.php test/compliance/cases/language/static_closure_bind.phpt
php bin/vm.php test/repro/maintainer_gap_static_closure_bind_regression.php
./vendor/bin/phpunit --filter static_closure_bind
'

Output:

Error: Cannot bind static closure to object
Error: Cannot bind static closure to object
object
OK (2 tests, 2 assertions)

Closes #4613

Made with Cursor

…#4613).

Use func->class->value when building return-type labels so methods with
:class return types (e.g. make(): Closure) no longer fatal; static
Closure::bindTo/bind now emit Zend Error as expected.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 18246a0 into master Jun 21, 2026
@PurHur
PurHur deleted the agent/issue-4613-static-closure-bind-return-type branch June 21, 2026 08:22
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: static closure bindTo()/bind() with $this must Error (Zend/zend_closures.c parity)

1 participant