-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Add types to private properties #41928
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
src/Symfony/Component/DependencyInjection/Compiler/AliasDeprecatedPublicServicesPass.php
Show resolved
Hide resolved
for the Psalm false positive, I reported the bug at vimeo/psalm#6027 |
@@ -194,7 +194,7 @@ protected function getReflectionMethod(Definition $definition, string $method) | |||
|
|||
private function getExpressionLanguage(): ExpressionLanguage | |||
{ | |||
if (null === $this->expressionLanguage) { | |||
if (!isset($this->expressionLanguage)) { |
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.
why not nullable?
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.
the private scope confused me. But from #41924 i figured this lazy loading tactic is probably slightly preferred, as we dont need to give in on type info.
👍
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.
Right. null
was previously used for lazy initialization only and I'd like to avoid making properties nullable. If someone accesses this property before initialization, they made a mistake and PHP will raise an exception for us. This is a good thing.
This PR was merged into the 4.4 branch. Discussion ---------- [DependencyInjection] Fix doc blocks | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A Two small backports from #41928. Commits ------- 950b2e7 [DependencyInjection] Fix doc blocks
$this->getEnv->setAccessible(true); | ||
$this->getEnv = $this->getEnv->getClosure($this); | ||
} | ||
$this->getEnv ??= \Closure::fromCallable([$this, __FUNCTION__]); |
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.
psalm bug here, it's not able to compute __FUNCTION__
correctly
let's use 'getEnv' instead
…nto a constant (derrabus) This PR was merged into the 4.4 branch. Discussion ---------- [DependencyInjection] Turn $defaultDeprecationTemplate into a constant | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | #41928 (comment) | License | MIT | Doc PR | N/A Commits ------- 936e399 [DependencyInjection] Turn $defaultDeprecationTemplate into a constant
…nto a constant (derrabus) This PR was merged into the 4.4 branch. Discussion ---------- [DependencyInjection] Turn $defaultDeprecationTemplate into a constant | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | symfony/symfony#41928 (comment) | License | MIT | Doc PR | N/A Commits ------- 936e399ff9 [DependencyInjection] Turn $defaultDeprecationTemplate into a constant
7b7588a
to
069da20
Compare
Thank you @derrabus. |
Same procedure as #41924, but on a more complex component.