8000 [DI] Refacto / cleanup / minor fixes by nicolas-grekas · Pull Request #21561 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DI] Refacto / cleanup / minor fixes #21561

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
Feb 8, 2017
Merged

Conversation

nicolas-grekas
Copy link
Member
Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

An almost neutral refacto touching only new things in master - unlocking some next steps.

  • renames "autowire method" to "autowire call"
  • renames GetterProxyInterface to InheritanceProxyInterface
  • moves some helpers in a new internal InheritanceProxyHelper
  • some other minor things

foreach ($methodCalls as $i => $call) {
list($method, $arguments) = $call;
$method = $parameterBag->resolveValue($method);
Copy link
Member Author
@nicolas-grekas nicolas-grekas Feb 8, 2017

Choose a reason for hiding this comment

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

this should not happen - we don't resolve method calls in ContainerBuilder/PhpDumper

@@ -24,6 +24,9 @@
*/
class AutowirePass extends AbstractRecursivePass
{
const MODE_REQUIRED = 1;
const MODE_OPTIONAL = 2;
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't we mark these constants as internal ?

@@ -510,22 +511,31 @@ private function addServiceOverriddenGetters($id, Definition $definition)
}
if (!$r->isFinal()) {
if (0 < $r->getNumberOfParameters()) {
$getters = implode('__construct($container'.$this->salt.', ', explode('(', $this->generateSignature($r), 2));
$constructor = implode('($container'.$this->salt.', ', explode('(', InheritanceProxyHelper::getSignature($r, $call), 2));
Copy link
Member
@stof stof Feb 8, 2017

Choose a reason for hiding this comment

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

aren't we missing $r->name at the beginning ?

Copy link
Member

Choose a reason for hiding this comment

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

btw, this tells me that we may be missing a test for this code path, as Travis is green

Copy link
Member Author

Choose a reason for hiding this comment

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

getSignature now embeds the name of the method, so no bug (and yes it's tested :) )

return $r;
}

public static function getSignature(\ReflectionFunctionAbstract $r, &$call = null)
Copy link
Member

Choose a reason for hiding this comment

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

would be great to document it a bit (for instance explaining what $call will be)

return ($r->returnsReference() ? '&' : '').($r->isClosure() ? '' : $r->name).'('.implode(', ', $signature).')'.$type;
}

public static function getTypeHint($type, \ReflectionFunctionAbstract $r)
Copy link
Member

Choose a reason for hiding this comment

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

$type should be documented as string|ReflectionType


public static function getTypeHint($type, \ReflectionFunctionAbstract $r)
{
if (is_string($type)) {
Copy link
Member

Choose a reason for hiding this comment

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

this case only happen on PHP 5.x, right ? If yes, we should add a comment about this, to be helpful for the guy doing the cleanup in Symfony 4. If no, we need to support iterable, void and scalar types just below.

@nicolas-grekas
Copy link
Member Author

@stof comments addressed

@fabpot
Copy link
Member
fabpot commented Feb 8, 2017

Thank you @nicolas-grekas.

josephdpurcell pushed a commit to josephdpurcell/symfony that referenced this pull request Feb 8, 2017
…kas)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Refacto / cleanup / minor fixes

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

An almost neutral refacto touching only new things in master - unlocking some next steps.

- renames "autowire method" to "autowire call"
- renames `GetterProxyInterface` to `InheritanceProxyInterface`
- moves some helpers in a new internal `InheritanceProxyHelper`
- some other minor things

Commits
-------

ad5b5b5 [DI] Refacto / cleanup / minor fixes
@fabpot fabpot merged commit ad5b5b5 into symfony:master Feb 8, 2017
@nicolas-grekas nicolas-grekas deleted the di-clean branch February 14, 2017 09:21
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
0