Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Compiler/PassConfig.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
27 const TYPE_BEFORE_REMOVING = 'beforeRemoving'; | 27 const TYPE_BEFORE_REMOVING = 'beforeRemoving'; |
28 const TYPE_OPTIMIZE = 'optimization'; | 28 const TYPE_OPTIMIZE = 'optimization'; |
29 const TYPE_REMOVE = 'removing'; | 29 const TYPE_REMOVE = 'removing'; |
30 | 30 |
31 private $mergePass; | 31 private $mergePass; |
32 private $afterRemovingPasses = array(); | 32 private $afterRemovingPasses = []; |
33 private $beforeOptimizationPasses = array(); | 33 private $beforeOptimizationPasses = []; |
34 private $beforeRemovingPasses = array(); | 34 private $beforeRemovingPasses = []; |
35 private $optimizationPasses; | 35 private $optimizationPasses; |
36 private $removingPasses; | 36 private $removingPasses; |
37 | 37 |
38 public function __construct() | 38 public function __construct() |
39 { | 39 { |
40 $this->mergePass = new MergeExtensionConfigurationPass(); | 40 $this->mergePass = new MergeExtensionConfigurationPass(); |
41 | 41 |
42 $this->beforeOptimizationPasses = array( | 42 $this->beforeOptimizationPasses = [ |
43 100 => array( | 43 100 => [ |
44 $resolveClassPass = new ResolveClassPass(), | 44 $resolveClassPass = new ResolveClassPass(), |
45 new ResolveInstanceofConditionalsPass(), | 45 new ResolveInstanceofConditionalsPass(), |
46 new RegisterEnvVarProcessorsPass(), | 46 new RegisterEnvVarProcessorsPass(), |
47 ), | 47 ], |
48 -1000 => array(new ExtensionCompilerPass()), | 48 -1000 => [new ExtensionCompilerPass()], |
49 ); | 49 ]; |
50 | 50 |
51 $this->optimizationPasses = array(array( | 51 $this->optimizationPasses = [[ |
52 new ResolveChildDefinitionsPass(), | 52 new ResolveChildDefinitionsPass(), |
53 new ServiceLocatorTagPass(), | 53 new ServiceLocatorTagPass(), |
54 new RegisterServiceSubscribersPass(), | |
54 new DecoratorServicePass(), | 55 new DecoratorServicePass(), |
55 new ResolveParameterPlaceHoldersPass(false), | 56 new ResolveParameterPlaceHoldersPass(false), |
56 new ResolveFactoryClassPass(), | 57 new ResolveFactoryClassPass(), |
57 new FactoryReturnTypePass($resolveClassPass), | 58 new FactoryReturnTypePass($resolveClassPass), |
58 new CheckDefinitionValidityPass(), | 59 new CheckDefinitionValidityPass(), |
59 new RegisterServiceSubscribersPass(), | |
60 new ResolveNamedArgumentsPass(), | 60 new ResolveNamedArgumentsPass(), |
61 new AutowireRequiredMethodsPass(), | 61 new AutowireRequiredMethodsPass(), |
62 new ResolveBindingsPass(), | 62 new ResolveBindingsPass(), |
63 new AutowirePass(false), | 63 new AutowirePass(false), |
64 new ResolveTaggedIteratorArgumentPass(), | 64 new ResolveTaggedIteratorArgumentPass(), |
67 new ResolveInvalidReferencesPass(), | 67 new ResolveInvalidReferencesPass(), |
68 new AnalyzeServiceReferencesPass(true), | 68 new AnalyzeServiceReferencesPass(true), |
69 new CheckCircularReferencesPass(), | 69 new CheckCircularReferencesPass(), |
70 new CheckReferenceValidityPass(), | 70 new CheckReferenceValidityPass(), |
71 new CheckArgumentsValidityPass(false), | 71 new CheckArgumentsValidityPass(false), |
72 )); | 72 ]]; |
73 | 73 |
74 $this->beforeRemovingPasses = array( | 74 $this->beforeRemovingPasses = [ |
75 -100 => array( | 75 -100 => [ |
76 new ResolvePrivatesPass(), | 76 new ResolvePrivatesPass(), |
77 ), | 77 ], |
78 ); | 78 ]; |
79 | 79 |
80 $this->removingPasses = array(array( | 80 $this->removingPasses = [[ |
81 new RemovePrivateAliasesPass(), | 81 new RemovePrivateAliasesPass(), |
82 new ReplaceAliasByActualDefinitionPass(), | 82 new ReplaceAliasByActualDefinitionPass(), |
83 new RemoveAbstractDefinitionsPass(), | 83 new RemoveAbstractDefinitionsPass(), |
84 new RepeatedPass(array( | 84 new RepeatedPass([ |
85 new AnalyzeServiceReferencesPass(), | 85 new AnalyzeServiceReferencesPass(), |
86 new InlineServiceDefinitionsPass(), | 86 new InlineServiceDefinitionsPass(), |
87 new AnalyzeServiceReferencesPass(), | 87 new AnalyzeServiceReferencesPass(), |
88 new RemoveUnusedDefinitionsPass(), | 88 new RemoveUnusedDefinitionsPass(), |
89 )), | 89 ]), |
90 new DefinitionErrorExceptionPass(), | 90 new DefinitionErrorExceptionPass(), |
91 new CheckExceptionOnInvalidReferenceBehaviorPass(), | 91 new CheckExceptionOnInvalidReferenceBehaviorPass(), |
92 new ResolveHotPathPass(), | 92 new ResolveHotPathPass(), |
93 )); | 93 ]]; |
94 } | 94 } |
95 | 95 |
96 /** | 96 /** |
97 * Returns all passes in order to be processed. | 97 * Returns all passes in order to be processed. |
98 * | 98 * |
99 * @return CompilerPassInterface[] | 99 * @return CompilerPassInterface[] |
100 */ | 100 */ |
101 public function getPasses() | 101 public function getPasses() |
102 { | 102 { |
103 return array_merge( | 103 return array_merge( |
104 array($this->mergePass), | 104 [$this->mergePass], |
105 $this->getBeforeOptimizationPasses(), | 105 $this->getBeforeOptimizationPasses(), |
106 $this->getOptimizationPasses(), | 106 $this->getOptimizationPasses(), |
107 $this->getBeforeRemovingPasses(), | 107 $this->getBeforeRemovingPasses(), |
108 $this->getRemovingPasses(), | 108 $this->getRemovingPasses(), |
109 $this->getAfterRemovingPasses() | 109 $this->getAfterRemovingPasses() |
119 * | 119 * |
120 * @throws InvalidArgumentException when a pass type doesn't exist | 120 * @throws InvalidArgumentException when a pass type doesn't exist |
121 */ | 121 */ |
122 public function addPass(CompilerPassInterface $pass, $type = self::TYPE_BEFORE_OPTIMIZATION/*, int $priority = 0*/) | 122 public function addPass(CompilerPassInterface $pass, $type = self::TYPE_BEFORE_OPTIMIZATION/*, int $priority = 0*/) |
123 { | 123 { |
124 if (func_num_args() >= 3) { | 124 if (\func_num_args() >= 3) { |
125 $priority = func_get_arg(2); | 125 $priority = func_get_arg(2); |
126 } else { | 126 } else { |
127 if (__CLASS__ !== get_class($this)) { | 127 if (__CLASS__ !== \get_class($this)) { |
128 $r = new \ReflectionMethod($this, __FUNCTION__); | 128 $r = new \ReflectionMethod($this, __FUNCTION__); |
129 if (__CLASS__ !== $r->getDeclaringClass()->getName()) { | 129 if (__CLASS__ !== $r->getDeclaringClass()->getName()) { |
130 @trigger_error(sprintf('Method %s() will have a third `int $priority = 0` argument in version 4.0. Not defining it is deprecated since Symfony 3.2.', __METHOD__), E_USER_DEPRECATED); | 130 @trigger_error(sprintf('Method %s() will have a third `int $priority = 0` argument in version 4.0. Not defining it is deprecated since Symfony 3.2.', __METHOD__), E_USER_DEPRECATED); |
131 } | 131 } |
132 } | 132 } |
140 } | 140 } |
141 | 141 |
142 $passes = &$this->$property; | 142 $passes = &$this->$property; |
143 | 143 |
144 if (!isset($passes[$priority])) { | 144 if (!isset($passes[$priority])) { |
145 $passes[$priority] = array(); | 145 $passes[$priority] = []; |
146 } | 146 } |
147 $passes[$priority][] = $pass; | 147 $passes[$priority][] = $pass; |
148 } | 148 } |
149 | 149 |
150 /** | 150 /** |
217 * | 217 * |
218 * @param CompilerPassInterface[] $passes | 218 * @param CompilerPassInterface[] $passes |
219 */ | 219 */ |
220 public function setAfterRemovingPasses(array $passes) | 220 public function setAfterRemovingPasses(array $passes) |
221 { | 221 { |
222 $this->afterRemovingPasses = array($passes); | 222 $this->afterRemovingPasses = [$passes]; |
223 } | 223 } |
224 | 224 |
225 /** | 225 /** |
226 * Sets the BeforeOptimization passes. | 226 * Sets the BeforeOptimization passes. |
227 * | 227 * |
228 * @param CompilerPassInterface[] $passes | 228 * @param CompilerPassInterface[] $passes |
229 */ | 229 */ |
230 public function setBeforeOptimizationPasses(array $passes) | 230 public function setBeforeOptimizationPasses(array $passes) |
231 { | 231 { |
232 $this->beforeOptimizationPasses = array($passes); | 232 $this->beforeOptimizationPasses = [$passes]; |
233 } | 233 } |
234 | 234 |
235 /** | 235 /** |
236 * Sets the BeforeRemoving passes. | 236 * Sets the BeforeRemoving passes. |
237 * | 237 * |
238 * @param CompilerPassInterface[] $passes | 238 * @param CompilerPassInterface[] $passes |
239 */ | 239 */ |
240 public function setBeforeRemovingPasses(array $passes) | 240 public function setBeforeRemovingPasses(array $passes) |
241 { | 241 { |
242 $this->beforeRemovingPasses = array($passes); | 242 $this->beforeRemovingPasses = [$passes]; |
243 } | 243 } |
244 | 244 |
245 /** | 245 /** |
246 * Sets the Optimization passes. | 246 * Sets the Optimization passes. |
247 * | 247 * |
248 * @param CompilerPassInterface[] $passes | 248 * @param CompilerPassInterface[] $passes |
249 */ | 249 */ |
250 public function setOptimizationPasses(array $passes) | 250 public function setOptimizationPasses(array $passes) |
251 { | 251 { |
252 $this->optimizationPasses = array($passes); | 252 $this->optimizationPasses = [$passes]; |
253 } | 253 } |
254 | 254 |
255 /** | 255 /** |
256 * Sets the Removing passes. | 256 * Sets the Removing passes. |
257 * | 257 * |
258 * @param CompilerPassInterface[] $passes | 258 * @param CompilerPassInterface[] $passes |
259 */ | 259 */ |
260 public function setRemovingPasses(array $passes) | 260 public function setRemovingPasses(array $passes) |
261 { | 261 { |
262 $this->removingPasses = array($passes); | 262 $this->removingPasses = [$passes]; |
263 } | 263 } |
264 | 264 |
265 /** | 265 /** |
266 * Sort passes by priority. | 266 * Sort passes by priority. |
267 * | 267 * |
269 * | 269 * |
270 * @return CompilerPassInterface[] | 270 * @return CompilerPassInterface[] |
271 */ | 271 */ |
272 private function sortPasses(array $passes) | 272 private function sortPasses(array $passes) |
273 { | 273 { |
274 if (0 === count($passes)) { | 274 if (0 === \count($passes)) { |
275 return array(); | 275 return []; |
276 } | 276 } |
277 | 277 |
278 krsort($passes); | 278 krsort($passes); |
279 | 279 |
280 // Flatten the array | 280 // Flatten the array |
281 return call_user_func_array('array_merge', $passes); | 281 return \call_user_func_array('array_merge', $passes); |
282 } | 282 } |
283 } | 283 } |