composer update
This commit is contained in:
parent
f6abc3dce2
commit
71dfaca858
1753 changed files with 45274 additions and 14619 deletions
|
@ -37,6 +37,7 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
|
|||
private $hasProxyDumper;
|
||||
private $lazy;
|
||||
private $expressionLanguage;
|
||||
private $byConstructor;
|
||||
|
||||
/**
|
||||
* @param bool $onlyConstructorArguments Sets this Service Reference pass to ignore method calls
|
||||
|
@ -64,6 +65,7 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
|
|||
$this->graph = $container->getCompiler()->getServiceReferenceGraph();
|
||||
$this->graph->clear();
|
||||
$this->lazy = false;
|
||||
$this->byConstructor = false;
|
||||
|
||||
foreach ($container->getAliases() as $id => $alias) {
|
||||
$targetId = $this->getDefinitionId((string) $alias);
|
||||
|
@ -100,7 +102,8 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
|
|||
$targetDefinition,
|
||||
$value,
|
||||
$this->lazy || ($this->hasProxyDumper && $targetDefinition && $targetDefinition->isLazy()),
|
||||
ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $value->getInvalidBehavior()
|
||||
ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $value->getInvalidBehavior(),
|
||||
$this->byConstructor
|
||||
);
|
||||
|
||||
return $value;
|
||||
|
@ -118,8 +121,11 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
|
|||
}
|
||||
$this->lazy = false;
|
||||
|
||||
$byConstructor = $this->byConstructor;
|
||||
$this->byConstructor = true;
|
||||
$this->processValue($value->getFactory());
|
||||
$this->processValue($value->getArguments());
|
||||
$this->byConstructor = $byConstructor;
|
||||
|
||||
if (!$this->onlyConstructorArguments) {
|
||||
$this->processValue($value->getProperties());
|
||||
|
|
|
@ -452,7 +452,17 @@ class AutowirePass extends AbstractRecursivePass
|
|||
|
||||
private function createTypeNotFoundMessage(TypedReference $reference, $label)
|
||||
{
|
||||
if (!$r = $this->container->getReflectionClass($type = $reference->getType(), false)) {
|
||||
$trackResources = $this->container->isTrackingResources();
|
||||
$this->container->setResourceTracking(false);
|
||||
try {
|
||||
if ($r = $this->container->getReflectionClass($type = $reference->getType(), false)) {
|
||||
$alternatives = $this->createTypeAlternatives($reference);
|
||||
}
|
||||
} finally {
|
||||
$this->container->setResourceTracking($trackResources);
|
||||
}
|
||||
|
||||
if (!$r) {
|
||||
// either $type does not exist or a parent class does not exist
|
||||
try {
|
||||
$resource = new ClassExistenceResource($type, false);
|
||||
|
@ -465,7 +475,6 @@ class AutowirePass extends AbstractRecursivePass
|
|||
|
||||
$message = sprintf('has type "%s" but this class %s.', $type, $parentMsg ? sprintf('is missing a parent class (%s)', $parentMsg) : 'was not found');
|
||||
} else {
|
||||
$alternatives = $this->createTypeAlternatives($reference);
|
||||
$message = $this->container->has($type) ? 'this service is abstract' : 'no such service exists';
|
||||
$message = sprintf('references %s "%s" but %s.%s', $r->isInterface() ? 'interface' : 'class', $type, $message, $alternatives);
|
||||
|
||||
|
|
|
@ -127,13 +127,19 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe
|
|||
}
|
||||
|
||||
$ids = array();
|
||||
$isReferencedByConstructor = false;
|
||||
foreach ($graph->getNode($id)->getInEdges() as $edge) {
|
||||
if ($edge->isWeak()) {
|
||||
$isReferencedByConstructor = $isReferencedByConstructor || $edge->isReferencedByConstructor();
|
||||
if ($edge->isWeak() || $edge->isLazy()) {
|
||||
return false;
|
||||
}
|
||||
$ids[] = $edge->getSourceNode()->getId();
|
||||
}
|
||||
|
||||
if (!$ids) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (\count(array_unique($ids)) > 1) {
|
||||
return false;
|
||||
}
|
||||
|
@ -142,6 +148,10 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe
|
|||
return false;
|
||||
}
|
||||
|
||||
return !$ids || $this->container->getDefinition($ids[0])->isShared();
|
||||
if ($isReferencedByConstructor && $this->container->getDefinition($ids[0])->isLazy() && ($definition->getProperties() || $definition->getMethodCalls() || $definition->getConfigurator())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->container->getDefinition($ids[0])->isShared();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,12 +51,12 @@ class PassConfig
|
|||
$this->optimizationPasses = array(array(
|
||||
new ResolveChildDefinitionsPass(),
|
||||
new ServiceLocatorTagPass(),
|
||||
new RegisterServiceSubscribersPass(),
|
||||
new DecoratorServicePass(),
|
||||
new ResolveParameterPlaceHoldersPass(false),
|
||||
new ResolveFactoryClassPass(),
|
||||
new FactoryReturnTypePass($resolveClassPass),
|
||||
new CheckDefinitionValidityPass(),
|
||||
new RegisterServiceSubscribersPass(),
|
||||
new ResolveNamedArgumentsPass(),
|
||||
new AutowireRequiredMethodsPass(),
|
||||
new ResolveBindingsPass(),
|
||||
|
|
|
@ -34,6 +34,8 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
|||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
$this->usedBindings = $container->getRemovedBindingIds();
|
||||
|
||||
try {
|
||||
parent::process($container);
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ class ResolveNamedArgumentsPass extends AbstractRecursivePass
|
|||
if (null === $parameters) {
|
||||
$r = $this->getReflectionMethod($value, $method);
|
||||
$class = $r instanceof \ReflectionMethod ? $r->class : $this->currentId;
|
||||
$method = $r->getName();
|
||||
$parameters = $r->getParameters();
|
||||
}
|
||||
|
||||
|
|
|
@ -91,11 +91,13 @@ class ServiceReferenceGraph
|
|||
* @param string $reference
|
||||
* @param bool $lazy
|
||||
* @param bool $weak
|
||||
* @param bool $byConstructor
|
||||
*/
|
||||
public function connect($sourceId, $sourceValue, $destId, $destValue = null, $reference = null/*, bool $lazy = false, bool $weak = false*/)
|
||||
public function connect($sourceId, $sourceValue, $destId, $destValue = null, $reference = null/*, bool $lazy = false, bool $weak = false, bool $byConstructor = false*/)
|
||||
{
|
||||
$lazy = \func_num_args() >= 6 ? func_get_arg(5) : false;
|
||||
$weak = \func_num_args() >= 7 ? func_get_arg(6) : false;
|
||||
$byConstructor = \func_num_args() >= 8 ? func_get_arg(7) : false;
|
||||
|
||||
if (null === $sourceId || null === $destId) {
|
||||
return;
|
||||
|
@ -103,7 +105,7 @@ class ServiceReferenceGraph
|
|||
|
||||
$sourceNode = $this->createNode($sourceId, $sourceValue);
|
||||
$destNode = $this->createNode($destId, $destValue);
|
||||
$edge = new ServiceReferenceGraphEdge($sourceNode, $destNode, $reference, $lazy, $weak);
|
||||
$edge = new ServiceReferenceGraphEdge($sourceNode, $destNode, $reference, $lazy, $weak, $byConstructor);
|
||||
|
||||
$sourceNode->addOutEdge($edge);
|
||||
$destNode->addInEdge($edge);
|
||||
|
|
|
@ -25,6 +25,7 @@ class ServiceReferenceGraphEdge
|
|||
private $value;
|
||||
private $lazy;
|
||||
private $weak;
|
||||
private $byConstructor;
|
||||
|
||||
/**
|
||||
* @param ServiceReferenceGraphNode $sourceNode
|
||||
|
@ -32,14 +33,16 @@ class ServiceReferenceGraphEdge
|
|||
* @param mixed $value
|
||||
* @param bool $lazy
|
||||
* @param bool $weak
|
||||
* @param bool $byConstructor
|
||||
*/
|
||||
public function __construct(ServiceReferenceGraphNode $sourceNode, ServiceReferenceGraphNode $destNode, $value = null, $lazy = false, $weak = false)
|
||||
public function __construct(ServiceReferenceGraphNode $sourceNode, ServiceReferenceGraphNode $destNode, $value = null, $lazy = false, $weak = false, $byConstructor = false)
|
||||
{
|
||||
$this->sourceNode = $sourceNode;
|
||||
$this->destNode = $destNode;
|
||||
$this->value = $value;
|
||||
$this->lazy = $lazy;
|
||||
$this->weak = $weak;
|
||||
$this->byConstructor = $byConstructor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,4 +94,14 @@ class ServiceReferenceGraphEdge
|
|||
{
|
||||
return $this->weak;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the edge links with a constructor argument.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isReferencedByConstructor()
|
||||
{
|
||||
return $this->byConstructor;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue