-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[3.0]Closures support $this in PHP >= 5.4 #14365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@dosten you need change |
@aitboudad done |
It would be better to group in one PR all changes for closures support > 5.4, not only |
I will go to make all changes in this PR since this only makes some changes missing in #12841 |
@@ -354,8 +352,6 @@ public function addExpressionLanguageProvider(ExpressionFunctionProviderInterfac | |||
} | |||
|
|||
/** | |||
* This method is public because it needs to be callable from a closure in PHP 5.3. It should be converted back to protected in 3.0. | |||
* @internal | |||
* @return GeneratorDumperInterface | |||
*/ | |||
public function getGeneratorDumperInstance() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be converted to protected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to private, not to protected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no it was protected before 2.7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aitboudad done, something more? |
no it's ok for me, 👍 |
👍 |
As the one who wrote most of this (or that) code, thanks for bringing this up! 👍 |
$baseClass = $this->options['matcher_base_class']; | ||
$expressionLanguageProviders = $this->expressionLanguageProviders; | ||
$that = $this; // required for PHP 5.3 where "$this" cannot be use()d in anonymous functions. Change in Symfony 3.0. | ||
|
||
$cache = $this->getConfigCacheFactory()->cache($this->options['cache_dir'].'/'.$class.'.php', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$class is not defined, please look at tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be $this->options['matcher_cache_class']
ping @fabpot |
@@ -320,25 +315,22 @@ public function getGenerator() | |||
if (null === $this->options['cache_dir'] || null === $this->options['generator_cache_class']) { | |||
$this->generator = new $this->options['generator_class']($this->getRouteCollection(), $this->context, $this->logger); | |||
} else { | |||
$class = $this->options['generator_cache_class']; | |||
$baseClass = $this->options['generator_base_class']; | |||
$that = $this; // required for PHP 5.3 where "$this" cannot be use()d in anonymous functions. Change in Symfony 3.0. | |||
$cache = $this->getConfigCacheFactory()->cache($this->options['cache_dir'].'/'.$class.'.php', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same problem
@dosten the code is still broken. please make sure the tests pass before pinging people. |
@Tobion sorry, fixed and rebased but the tests still failing: |
@dosten can you please rebase+squash? |
@nicolas-grekas done |
Thank you @dosten. |
This PR was merged into the 3.0-dev branch. Discussion ---------- [3.0]Closures support $this in PHP >= 5.4 | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | License | MIT Closures support `$this` in PHP >= 5.4 ping @aitboudad Commits ------- 38f32c1 $this can be used inside a closure in PHP >= 5.4
Closures support
$this
in PHP >= 5.4ping @aitboudad