@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $this->graph->connect($this->currentId, $this->currentDefinition, $targetId, $targetDefinition, $value, $this->lazy || $this->hasProxyDumper && $targetDefinition && $targetDefinition->isLazy(), ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $value->getInvalidBehavior(), $this->byConstructor); |
87 | 87 | return $value; |
88 | 88 | } |
89 | - if (!$value instanceof Definition) { |
|
89 | + if ( ! $value instanceof Definition) { |
|
90 | 90 | return parent::processValue($value, $isRoot); |
91 | 91 | } |
92 | 92 | if ($isRoot) { |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $this->processValue($value->getFactory()); |
104 | 104 | $this->processValue($value->getArguments()); |
105 | 105 | $this->byConstructor = $byConstructor; |
106 | - if (!$this->onlyConstructorArguments) { |
|
106 | + if ( ! $this->onlyConstructorArguments) { |
|
107 | 107 | $this->processValue($value->getProperties()); |
108 | 108 | $this->processValue($value->getMethodCalls()); |
109 | 109 | $this->processValue($value->getConfigurator()); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | while ($this->container->hasAlias($id)) { |
128 | 128 | $id = (string) $this->container->getAlias($id); |
129 | 129 | } |
130 | - if (!$this->container->hasDefinition($id)) { |
|
130 | + if ( ! $this->container->hasDefinition($id)) { |
|
131 | 131 | return null; |
132 | 132 | } |
133 | 133 | return $this->container->normalizeId($id); |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | private function getExpressionLanguage() |
136 | 136 | { |
137 | 137 | if (null === $this->expressionLanguage) { |
138 | - if (!\class_exists(ExpressionLanguage::class)) { |
|
138 | + if ( ! \class_exists(ExpressionLanguage::class)) { |
|
139 | 139 | throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); |
140 | 140 | } |
141 | 141 | $providers = $this->container->getExpressionLanguageProviders(); |
142 | - $this->expressionLanguage = new ExpressionLanguage(null, $providers, function ($arg) { |
|
142 | + $this->expressionLanguage = new ExpressionLanguage(null, $providers, function($arg) { |
|
143 | 143 | if ('""' === \substr_replace($arg, '', 1, -1)) { |
144 | 144 | $id = \stripcslashes(\substr($arg, 1, -1)); |
145 | 145 | $id = $this->getDefinitionId($id); |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | { |
37 | 37 | foreach ($container->getDefinitions() as $id => $definition) { |
38 | 38 | // synthetic service is public |
39 | - if ($definition->isSynthetic() && !($definition->isPublic() || $definition->isPrivate())) { |
|
39 | + if ($definition->isSynthetic() && ! ($definition->isPublic() || $definition->isPrivate())) { |
|
40 | 40 | throw new RuntimeException(\sprintf('A synthetic service ("%s") must be public.', $id)); |
41 | 41 | } |
42 | 42 | // non-synthetic, non-abstract service has class |
43 | - if (!$definition->isAbstract() && !$definition->isSynthetic() && !$definition->getClass()) { |
|
43 | + if ( ! $definition->isAbstract() && ! $definition->isSynthetic() && ! $definition->getClass()) { |
|
44 | 44 | if ($definition->getFactory()) { |
45 | 45 | throw new RuntimeException(\sprintf('Please add the class to service "%s" even if it is constructed by a factory since we might need to add method calls based on compile-time checks.', $id)); |
46 | 46 | } |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | foreach ($definition->getTags() as $name => $tags) { |
57 | 57 | foreach ($tags as $attributes) { |
58 | 58 | foreach ($attributes as $attribute => $value) { |
59 | - if (!\is_scalar($value) && null !== $value) { |
|
59 | + if ( ! \is_scalar($value) && null !== $value) { |
|
60 | 60 | throw new RuntimeException(\sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s".', $id, $name, $attribute)); |
61 | 61 | } |
62 | 62 | } |
63 | 63 | } |
64 | 64 | } |
65 | - if ($definition->isPublic() && !$definition->isPrivate()) { |
|
65 | + if ($definition->isPublic() && ! $definition->isPrivate()) { |
|
66 | 66 | $resolvedId = $container->resolveEnvPlaceholders($id, null, $usedEnvs); |
67 | 67 | if (null !== $usedEnvs) { |
68 | 68 | throw new EnvParameterException([$resolvedId], null, 'A service name ("%s") cannot contain dynamic values.'); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } |
71 | 71 | } |
72 | 72 | foreach ($container->getAliases() as $id => $alias) { |
73 | - if ($alias->isPublic() && !$alias->isPrivate()) { |
|
73 | + if ($alias->isPublic() && ! $alias->isPrivate()) { |
|
74 | 74 | $resolvedId = $container->resolveEnvPlaceholders($id, null, $usedEnvs); |
75 | 75 | if (null !== $usedEnvs) { |
76 | 76 | throw new EnvParameterException([$resolvedId], null, 'An alias name ("%s") cannot contain dynamic values.'); |
@@ -47,12 +47,12 @@ |
||
47 | 47 | if ($value instanceof ArgumentInterface) { |
48 | 48 | return $value; |
49 | 49 | } |
50 | - if ($value instanceof Definition && $isRoot && (isset($this->resolvedIds[$this->currentId]) || !$value->hasTag($this->tagName) || $value->isDeprecated())) { |
|
50 | + if ($value instanceof Definition && $isRoot && (isset($this->resolvedIds[$this->currentId]) || ! $value->hasTag($this->tagName) || $value->isDeprecated())) { |
|
51 | 51 | return $value->isDeprecated() ? $value->clearTag($this->tagName) : $value; |
52 | 52 | } |
53 | 53 | if ($value instanceof Reference && ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior() && $this->container->has($id = $this->container->normalizeId($value))) { |
54 | 54 | $definition = $this->container->findDefinition($id); |
55 | - if (!$definition->hasTag($this->tagName) && !$definition->isDeprecated()) { |
|
55 | + if ( ! $definition->hasTag($this->tagName) && ! $definition->isDeprecated()) { |
|
56 | 56 | $this->resolvedIds[$id] = \true; |
57 | 57 | $definition->addTag($this->tagName); |
58 | 58 | parent::processValue($definition, \false); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | return null; |
86 | 86 | } |
87 | 87 | if (\is_string($factory = $definition->getFactory())) { |
88 | - if (!\function_exists($factory)) { |
|
88 | + if ( ! \function_exists($factory)) { |
|
89 | 89 | throw new RuntimeException(\sprintf('Invalid service "%s": function "%s" does not exist.', $this->currentId, $factory)); |
90 | 90 | } |
91 | 91 | $r = new \ReflectionFunction($factory); |
@@ -108,18 +108,18 @@ discard block |
||
108 | 108 | } |
109 | 109 | $class = $definition->getClass(); |
110 | 110 | try { |
111 | - if (!($r = $this->container->getReflectionClass($class))) { |
|
111 | + if ( ! ($r = $this->container->getReflectionClass($class))) { |
|
112 | 112 | throw new RuntimeException(\sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class)); |
113 | 113 | } |
114 | 114 | } catch (\ReflectionException $e) { |
115 | - throw new RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId) . \lcfirst($e->getMessage())); |
|
115 | + throw new RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId).\lcfirst($e->getMessage())); |
|
116 | 116 | } |
117 | - if (!($r = $r->getConstructor())) { |
|
117 | + if ( ! ($r = $r->getConstructor())) { |
|
118 | 118 | if ($required) { |
119 | 119 | throw new RuntimeException(\sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, \sprintf($class !== $this->currentId ? ' "%s"' : '', $class))); |
120 | 120 | } |
121 | - } elseif (!$r->isPublic()) { |
|
122 | - throw new RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId) . \sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class) . ' must be public.'); |
|
121 | + } elseif ( ! $r->isPublic()) { |
|
122 | + throw new RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId).\sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class).' must be public.'); |
|
123 | 123 | } |
124 | 124 | return $r; |
125 | 125 | } |
@@ -135,18 +135,18 @@ discard block |
||
135 | 135 | if ('__construct' === $method) { |
136 | 136 | return $this->getConstructor($definition, \true); |
137 | 137 | } |
138 | - if (!($class = $definition->getClass())) { |
|
138 | + if ( ! ($class = $definition->getClass())) { |
|
139 | 139 | throw new RuntimeException(\sprintf('Invalid service "%s": the class is not set.', $this->currentId)); |
140 | 140 | } |
141 | - if (!($r = $this->container->getReflectionClass($class))) { |
|
141 | + if ( ! ($r = $this->container->getReflectionClass($class))) { |
|
142 | 142 | throw new RuntimeException(\sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class)); |
143 | 143 | } |
144 | - if (!$r->hasMethod($method)) { |
|
145 | - throw new RuntimeException(\sprintf('Invalid service "%s": method "%s()" does not exist.', $this->currentId, $class !== $this->currentId ? $class . '::' . $method : $method)); |
|
144 | + if ( ! $r->hasMethod($method)) { |
|
145 | + throw new RuntimeException(\sprintf('Invalid service "%s": method "%s()" does not exist.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method)); |
|
146 | 146 | } |
147 | 147 | $r = $r->getMethod($method); |
148 | - if (!$r->isPublic()) { |
|
149 | - throw new RuntimeException(\sprintf('Invalid service "%s": method "%s()" must be public.', $this->currentId, $class !== $this->currentId ? $class . '::' . $method : $method)); |
|
148 | + if ( ! $r->isPublic()) { |
|
149 | + throw new RuntimeException(\sprintf('Invalid service "%s": method "%s()" must be public.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method)); |
|
150 | 150 | } |
151 | 151 | return $r; |
152 | 152 | } |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | } |
60 | 60 | $value = clone $value; |
61 | 61 | } |
62 | - if (!$value instanceof Reference || !$this->container->hasDefinition($id = $this->container->normalizeId($value))) { |
|
62 | + if ( ! $value instanceof Reference || ! $this->container->hasDefinition($id = $this->container->normalizeId($value))) { |
|
63 | 63 | return parent::processValue($value, $isRoot); |
64 | 64 | } |
65 | 65 | $definition = $this->container->getDefinition($id); |
66 | - if (!$this->isInlineableDefinition($id, $definition, $this->container->getCompiler()->getServiceReferenceGraph())) { |
|
66 | + if ( ! $this->isInlineableDefinition($id, $definition, $this->container->getCompiler()->getServiceReferenceGraph())) { |
|
67 | 67 | return $value; |
68 | 68 | } |
69 | 69 | $this->container->log($this, \sprintf('Inlined service "%s" to "%s".', $id, $this->currentId)); |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | if ($definition->getErrors() || $definition->isDeprecated() || $definition->isLazy() || $definition->isSynthetic()) { |
94 | 94 | return \false; |
95 | 95 | } |
96 | - if (!$definition->isShared()) { |
|
96 | + if ( ! $definition->isShared()) { |
|
97 | 97 | return \true; |
98 | 98 | } |
99 | 99 | if ($definition->isPublic() || $definition->isPrivate()) { |
100 | 100 | return \false; |
101 | 101 | } |
102 | - if (!$graph->hasNode($id)) { |
|
102 | + if ( ! $graph->hasNode($id)) { |
|
103 | 103 | return \true; |
104 | 104 | } |
105 | 105 | if ($this->currentId == $id) { |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | } |
115 | 115 | $ids[] = $edge->getSourceNode()->getId(); |
116 | 116 | } |
117 | - if (!$ids) { |
|
117 | + if ( ! $ids) { |
|
118 | 118 | return \true; |
119 | 119 | } |
120 | 120 | if (\count(\array_unique($ids)) > 1) { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | private $currentPath; |
28 | 28 | protected function processValue($value, $isRoot = \false) |
29 | 29 | { |
30 | - if (!$value instanceof Definition) { |
|
30 | + if ( ! $value instanceof Definition) { |
|
31 | 31 | return parent::processValue($value, $isRoot); |
32 | 32 | } |
33 | 33 | if ($isRoot) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | private function doResolveDefinition(ChildDefinition $definition) |
68 | 68 | { |
69 | - if (!$this->container->has($parent = $definition->getParent())) { |
|
69 | + if ( ! $this->container->has($parent = $definition->getParent())) { |
|
70 | 70 | throw new RuntimeException(\sprintf('Parent definition "%s" does not exist.', $parent)); |
71 | 71 | } |
72 | 72 | $searchKey = \array_search($parent, $this->currentPath); |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | { |
27 | 27 | protected function processValue($value, $isRoot = \false) |
28 | 28 | { |
29 | - if (!$value instanceof Definition || !$value->hasTag('container.service_locator')) { |
|
29 | + if ( ! $value instanceof Definition || ! $value->hasTag('container.service_locator')) { |
|
30 | 30 | return parent::processValue($value, $isRoot); |
31 | 31 | } |
32 | - if (!$value->getClass()) { |
|
32 | + if ( ! $value->getClass()) { |
|
33 | 33 | $value->setClass(ServiceLocator::class); |
34 | 34 | } |
35 | 35 | $arguments = $value->getArguments(); |
36 | - if (!isset($arguments[0]) || !\is_array($arguments[0])) { |
|
36 | + if ( ! isset($arguments[0]) || ! \is_array($arguments[0])) { |
|
37 | 37 | throw new InvalidArgumentException(\sprintf('Invalid definition for service "%s": an array of references is expected as first argument when the "container.service_locator" tag is set.', $this->currentId)); |
38 | 38 | } |
39 | 39 | $i = 0; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | if ($v instanceof ServiceClosureArgument) { |
42 | 42 | continue; |
43 | 43 | } |
44 | - if (!$v instanceof Reference) { |
|
44 | + if ( ! $v instanceof Reference) { |
|
45 | 45 | throw new InvalidArgumentException(\sprintf('Invalid definition for service "%s": an array of references is expected as first argument when the "container.service_locator" tag is set, "%s" found for key "%s".', $this->currentId, \is_object($v) ? \get_class($v) : \gettype($v), $k)); |
46 | 46 | } |
47 | 47 | if ($i === $k) { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | \ksort($arguments[0]); |
57 | 57 | $value->setArguments($arguments); |
58 | - $id = 'service_locator.' . ContainerBuilder::hash($value); |
|
58 | + $id = 'service_locator.'.ContainerBuilder::hash($value); |
|
59 | 59 | if ($isRoot) { |
60 | 60 | if ($id !== $this->currentId) { |
61 | 61 | $this->container->setAlias($id, new Alias($this->currentId, \false)); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public static function register(ContainerBuilder $container, array $refMap, $callerId = null) |
75 | 75 | { |
76 | 76 | foreach ($refMap as $id => $ref) { |
77 | - if (!$ref instanceof Reference) { |
|
77 | + if ( ! $ref instanceof Reference) { |
|
78 | 78 | throw new InvalidArgumentException(\sprintf('Invalid service locator definition: only services can be referenced, "%s" found for key "%s". Inject parameter values using constructors instead.', \is_object($ref) ? \get_class($ref) : \gettype($ref), $id)); |
79 | 79 | } |
80 | 80 | $refMap[$id] = new ServiceClosureArgument($ref); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | if (null !== $callerId && $container->hasDefinition($callerId)) { |
85 | 85 | $locator->setBindings($container->getDefinition($callerId)->getBindings()); |
86 | 86 | } |
87 | - if (!$container->hasDefinition($id = 'service_locator.' . ContainerBuilder::hash($locator))) { |
|
87 | + if ( ! $container->hasDefinition($id = 'service_locator.'.ContainerBuilder::hash($locator))) { |
|
88 | 88 | $container->setDefinition($id, $locator); |
89 | 89 | } |
90 | 90 | if (null !== $callerId) { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | // Locators are shared when they hold the exact same list of factories; |
93 | 93 | // to have them specialized per consumer service, we use a cloning factory |
94 | 94 | // to derivate customized instances from the prototype one. |
95 | - $container->register($id .= '.' . $callerId, ServiceLocator::class)->setPublic(\false)->setFactory([new Reference($locatorId), 'withContext'])->addArgument($callerId)->addArgument(new Reference('service_container')); |
|
95 | + $container->register($id .= '.'.$callerId, ServiceLocator::class)->setPublic(\false)->setFactory([new Reference($locatorId), 'withContext'])->addArgument($callerId)->addArgument(new Reference('service_container')); |
|
96 | 96 | } |
97 | 97 | return new Reference($id); |
98 | 98 | } |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | { |
26 | 26 | protected function processValue($value, $isRoot = \false) |
27 | 27 | { |
28 | - if (!$value instanceof Definition || $value->isAbstract() || $value->isSynthetic() || !$value->hasTag('container.service_subscriber')) { |
|
28 | + if ( ! $value instanceof Definition || $value->isAbstract() || $value->isSynthetic() || ! $value->hasTag('container.service_subscriber')) { |
|
29 | 29 | return parent::processValue($value, $isRoot); |
30 | 30 | } |
31 | 31 | $serviceMap = []; |
32 | 32 | $autowire = $value->isAutowired(); |
33 | 33 | foreach ($value->getTag('container.service_subscriber') as $attributes) { |
34 | - if (!$attributes) { |
|
34 | + if ( ! $attributes) { |
|
35 | 35 | $autowire = \true; |
36 | 36 | continue; |
37 | 37 | } |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | if ([] !== \array_diff(\array_keys($attributes), ['id', 'key'])) { |
40 | 40 | throw new InvalidArgumentException(\sprintf('The "container.service_subscriber" tag accepts only the "key" and "id" attributes, "%s" given for service "%s".', \implode('", "', \array_keys($attributes)), $this->currentId)); |
41 | 41 | } |
42 | - if (!\array_key_exists('id', $attributes)) { |
|
42 | + if ( ! \array_key_exists('id', $attributes)) { |
|
43 | 43 | throw new InvalidArgumentException(\sprintf('Missing "id" attribute on "container.service_subscriber" tag with key="%s" for service "%s".', $attributes['key'], $this->currentId)); |
44 | 44 | } |
45 | - if (!\array_key_exists('key', $attributes)) { |
|
45 | + if ( ! \array_key_exists('key', $attributes)) { |
|
46 | 46 | $attributes['key'] = $attributes['id']; |
47 | 47 | } |
48 | 48 | if (isset($serviceMap[$attributes['key']])) { |
@@ -51,17 +51,17 @@ discard block |
||
51 | 51 | $serviceMap[$attributes['key']] = new Reference($attributes['id']); |
52 | 52 | } |
53 | 53 | $class = $value->getClass(); |
54 | - if (!($r = $this->container->getReflectionClass($class))) { |
|
54 | + if ( ! ($r = $this->container->getReflectionClass($class))) { |
|
55 | 55 | throw new InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $this->currentId)); |
56 | 56 | } |
57 | - if (!$r->isSubclassOf(ServiceSubscriberInterface::class)) { |
|
57 | + if ( ! $r->isSubclassOf(ServiceSubscriberInterface::class)) { |
|
58 | 58 | throw new InvalidArgumentException(\sprintf('Service "%s" must implement interface "%s".', $this->currentId, ServiceSubscriberInterface::class)); |
59 | 59 | } |
60 | 60 | $class = $r->name; |
61 | 61 | $subscriberMap = []; |
62 | 62 | $declaringClass = (new \ReflectionMethod($class, 'getSubscribedServices'))->class; |
63 | 63 | foreach ($class::getSubscribedServices() as $key => $type) { |
64 | - if (!\is_string($type) || !\preg_match('/^\\??[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+(?:\\\\[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+)*+$/', $type)) { |
|
64 | + if ( ! \is_string($type) || ! \preg_match('/^\\??[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+(?:\\\\[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+)*+$/', $type)) { |
|
65 | 65 | throw new InvalidArgumentException(\sprintf('"%s::getSubscribedServices()" must return valid PHP types for service "%s" key "%s", "%s" returned.', $class, $this->currentId, $key, \is_string($type) ? $type : \gettype($type))); |
66 | 66 | } |
67 | 67 | if ($optionalBehavior = '?' === $type[0]) { |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | if (\is_int($key)) { |
72 | 72 | $key = $type; |
73 | 73 | } |
74 | - if (!isset($serviceMap[$key])) { |
|
75 | - if (!$autowire) { |
|
74 | + if ( ! isset($serviceMap[$key])) { |
|
75 | + if ( ! $autowire) { |
|
76 | 76 | throw new InvalidArgumentException(\sprintf('Service "%s" misses a "container.service_subscriber" tag with "key"/"id" attributes corresponding to entry "%s" as returned by "%s::getSubscribedServices()".', $this->currentId, $key, $class)); |
77 | 77 | } |
78 | 78 | $serviceMap[$key] = new Reference($type); |
@@ -29,7 +29,7 @@ |
||
29 | 29 | continue; |
30 | 30 | } |
31 | 31 | if (\preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+(?:\\\\[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+)++$/', $id)) { |
32 | - if ($definition instanceof ChildDefinition && !\class_exists($id)) { |
|
32 | + if ($definition instanceof ChildDefinition && ! \class_exists($id)) { |
|
33 | 33 | throw new InvalidArgumentException(\sprintf('Service definition "%s" has a parent but no class, and its name looks like a FQCN. Either the class is missing or you want to inherit it from the parent service. To resolve this ambiguity, please rename this service to a non-FQCN (e.g. using dots), or create the missing class.', $id)); |
34 | 34 | } |
35 | 35 | $this->changes[\strtolower($id)] = $id; |