-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
#4]
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -302,7 +302,23 @@ private function resolveImplement(ServiceDefinition $def, $name) | |
} | ||
|
||
if (!$def->parameters) { | ||
$ctorParams = array(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Majkl578
Contributor
|
||
if ($def->factory && !$def->factory->arguments && ($class = $this->resolveEntityClass($def->factory, array($name => 1))) | ||
&& ($ctor = Reflection\ClassType::from($class)->getConstructor()) | ||
) { | ||
foreach ($ctor->getParameters() as $param) { | ||
$ctorParams[$param->getName()] = $param; | ||
} | ||
} | ||
|
||
foreach ($method->getParameters() as $param) { | ||
if (isset($ctorParams[$param->getName()])) { | ||
$arg = $ctorParams[$param->getName()]; | ||
if ($param->getClassName() !== $arg->getClassName() || $param->isArray() !== $arg->isArray()) { | ||
throw new ServiceCreationException("Type hint for $arg doesn't match type hint for $param"); | ||
} | ||
$def->factory->arguments[$arg->getPosition()] = ContainerBuilder::literal('$' . $arg->getName()); | ||
} | ||
$paramDef = ($param->isArray() ? 'array' : $param->getClassName()) . ' ' . $param->getName(); | ||
if ($param->isOptional()) { | ||
$def->parameters[$paramDef] = $param->getDefaultValue(); | ||
|
3 comments
on commit a1f48d0
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.
Big things today :). 👍
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.
❤️
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.
Ohhh
"ctor" stands for "constructor"? I need to read
getConstructor()
bellow to understand (if so) andfaCTORy
on line right bellow confuses my guessing till then.I'd prefer full name in this case as it might be misleading. What do you think?