You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe a BC break was introduced in Symfony 2.8 (and remains there) which means that it is no longer possible to use non-static closures with the console component.
PHP Fatal error: Uncaught exception 'Symfony\Component\Debug\Exception\ContextErrorException'
with message 'Warning: Cannot bind an instance to a static closure' in
/projects/api/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:286
This is caused because with the code introduced in 2.8 it attempts to bind an instance to any closure, which is not permitted for static closures.
I couldn't locate why this code change was introduced in the first place - simply removing the bind call appears to solve my problem, but without understanding why the change was introduced I don't know what else I might be breaking.
The text was updated successfully, but these errors were encountered:
This PR was squashed before being merged into the 2.8 branch (closes#20847).
Discussion
----------
[Console] fixed BC issue with static closures
| Q | A
| ------------- | ---
| Branch? | 2.8
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #20845
| License | MIT
| Doc PR | n/a
Static closures were unable to be used in Command::setCode since #14431. This change fixes the BC break and ensures static closures can still be used.
Edit: It seems the inability to bind static closures was considered a feature in PHP5 but was considered a bug by PHP7. As such, the tests need to work around this fact - but the code can remain the same. This code change can be tidied/removed once Symfony is PHP7+ only.
Discussion here:
https://bugs.php.net/bug.php?id=64761https://bugs.php.net/bug.php?id=68792
Commits
-------
3247308 [Console] fixed BC issue with static closures
Following this commit:
symfony/console@9f7a193#diff-25a75e093c4a0d5564a36cebbb1384b3R290
I believe a BC break was introduced in Symfony 2.8 (and remains there) which means that it is no longer possible to use non-static closures with the console component.
Simplified example based on some of my code:
Results in:
This is caused because with the code introduced in 2.8 it attempts to bind an instance to any closure, which is not permitted for static closures.
I couldn't locate why this code change was introduced in the first place - simply removing the bind call appears to solve my problem, but without understanding why the change was introduced I don't know what else I might be breaking.
The text was updated successfully, but these errors were encountered: