Skip to content

[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

Merged
merged 1 commit into from
Jul 3, 2021

Conversation

derrabus
Copy link
Member

@derrabus derrabus commented Jul 1, 2021

Q A
Branch? 6.0
Bug fix? no
New feature? no
Deprecations? no
Tickets N/A
License MIT
Doc PR N/A

Same procedure as #41924, but on a more complex component.

@stof
Copy link
Member

stof commented Jul 1, 2021

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)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not nullable?

Copy link
Contributor

@ro0NL ro0NL Jul 1, 2021

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.

👍

Copy link
Member Author

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.

fabpot added a commit that referenced this pull request Jul 2, 2021
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__]);
Copy link
Member

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

fabpot added a commit that referenced this pull request Jul 2, 2021
…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
symfony-splitter pushed a commit to symfony/dependency-injection that referenced this pull request Jul 2, 2021
…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
@nicolas-grekas
Copy link
Member

Thank you @derrabus.

@nicolas-grekas nicolas-grekas merged commit d948312 into symfony:6.0 Jul 3, 2021
@derrabus derrabus deleted the types/di-properties branch July 4, 2021 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants