Skip to content

Language: Closure::fromCallable() and Closure::bindTo() VM (#3266) - #3275

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-3266-closure-from-callable
May 30, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-3266-closure-from-callable

Conversation

@PurHur

@PurHur PurHur commented May 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implement VM builtins Closure::fromCallable() and Closure::bindTo() with Zend zend_closures.c parity for string functions, static/instance method callables, and rebound $this/scope.
  • Extend ClosureState with wrapped-callable and binding metadata; wire invocation through initClosureCall / applyClosureBinding so private method wrappers respect declaring-class scope.
  • Add three compliance .phpt cases to ClosureVMTest.

php-src reference

  • Zend/zend_closures.c — zend_closure_from_callable, zend_closure_bind_to

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit test/compliance/ClosureVMTest.php'

Closes #3266

Made with Cursor

Add VM builtins for Closure::fromCallable (string, static, and instance
method callables) and Closure::bindTo with bound $this/scope semantics
matching Zend zend_closures.c; guarded by ClosureVMTest compliance cases.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 2616ade into master May 30, 2026
@PurHur
PurHur deleted the agent/issue-3266-closure-from-callable branch May 30, 2026 05:09
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: Closure::fromCallable() and Closure::bindTo() (Zend zend_closures.c parity)

1 participant