Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Compiler/Compiler.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
28 | 28 |
29 public function __construct() | 29 public function __construct() |
30 { | 30 { |
31 $this->passConfig = new PassConfig(); | 31 $this->passConfig = new PassConfig(); |
32 $this->serviceReferenceGraph = new ServiceReferenceGraph(); | 32 $this->serviceReferenceGraph = new ServiceReferenceGraph(); |
33 $this->loggingFormatter = new LoggingFormatter(); | |
34 } | 33 } |
35 | 34 |
36 /** | 35 /** |
37 * Returns the PassConfig. | 36 * Returns the PassConfig. |
38 * | 37 * |
55 | 54 |
56 /** | 55 /** |
57 * Returns the logging formatter which can be used by compilation passes. | 56 * Returns the logging formatter which can be used by compilation passes. |
58 * | 57 * |
59 * @return LoggingFormatter | 58 * @return LoggingFormatter |
59 * | |
60 * @deprecated since version 3.3, to be removed in 4.0. Use the ContainerBuilder::log() method instead. | |
60 */ | 61 */ |
61 public function getLoggingFormatter() | 62 public function getLoggingFormatter() |
62 { | 63 { |
64 if (null === $this->loggingFormatter) { | |
65 @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the ContainerBuilder::log() method instead.', __METHOD__), E_USER_DEPRECATED); | |
66 | |
67 $this->loggingFormatter = new LoggingFormatter(); | |
68 } | |
69 | |
63 return $this->loggingFormatter; | 70 return $this->loggingFormatter; |
64 } | 71 } |
65 | 72 |
66 /** | 73 /** |
67 * Adds a pass to the PassConfig. | 74 * Adds a pass to the PassConfig. |
68 * | 75 * |
69 * @param CompilerPassInterface $pass A compiler pass | 76 * @param CompilerPassInterface $pass A compiler pass |
70 * @param string $type The type of the pass | 77 * @param string $type The type of the pass |
71 * @param int $priority Used to sort the passes | 78 * @param int $priority Used to sort the passes |
72 */ | 79 */ |
73 public function addPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION/*, $priority = 0*/) | 80 public function addPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION/*, int $priority = 0*/) |
74 { | 81 { |
75 if (func_num_args() >= 3) { | 82 if (func_num_args() >= 3) { |
76 $priority = func_get_arg(2); | 83 $priority = func_get_arg(2); |
77 } else { | 84 } else { |
78 if (__CLASS__ !== get_class($this)) { | 85 if (__CLASS__ !== get_class($this)) { |
79 $r = new \ReflectionMethod($this, __FUNCTION__); | 86 $r = new \ReflectionMethod($this, __FUNCTION__); |
80 if (__CLASS__ !== $r->getDeclaringClass()->getName()) { | 87 if (__CLASS__ !== $r->getDeclaringClass()->getName()) { |
81 @trigger_error(sprintf('Method %s() will have a third `$priority = 0` argument in version 4.0. Not defining it is deprecated since 3.2.', __METHOD__), E_USER_DEPRECATED); | 88 @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); |
82 } | 89 } |
83 } | 90 } |
84 | 91 |
85 $priority = 0; | 92 $priority = 0; |
86 } | 93 } |
90 | 97 |
91 /** | 98 /** |
92 * Adds a log message. | 99 * Adds a log message. |
93 * | 100 * |
94 * @param string $string The log message | 101 * @param string $string The log message |
102 * | |
103 * @deprecated since version 3.3, to be removed in 4.0. Use the ContainerBuilder::log() method instead. | |
95 */ | 104 */ |
96 public function addLogMessage($string) | 105 public function addLogMessage($string) |
97 { | 106 { |
107 @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the ContainerBuilder::log() method instead.', __METHOD__), E_USER_DEPRECATED); | |
108 | |
98 $this->log[] = $string; | 109 $this->log[] = $string; |
110 } | |
111 | |
112 /** | |
113 * @final | |
114 */ | |
115 public function log(CompilerPassInterface $pass, $message) | |
116 { | |
117 if (false !== strpos($message, "\n")) { | |
118 $message = str_replace("\n", "\n".get_class($pass).': ', trim($message)); | |
119 } | |
120 | |
121 $this->log[] = get_class($pass).': '.$message; | |
99 } | 122 } |
100 | 123 |
101 /** | 124 /** |
102 * Returns the log. | 125 * Returns the log. |
103 * | 126 * |
108 return $this->log; | 131 return $this->log; |
109 } | 132 } |
110 | 133 |
111 /** | 134 /** |
112 * Run the Compiler and process all Passes. | 135 * Run the Compiler and process all Passes. |
113 * | |
114 * @param ContainerBuilder $container | |
115 */ | 136 */ |
116 public function compile(ContainerBuilder $container) | 137 public function compile(ContainerBuilder $container) |
117 { | 138 { |
118 try { | 139 try { |
119 foreach ($this->passConfig->getPasses() as $pass) { | 140 foreach ($this->passConfig->getPasses() as $pass) { |
136 if ($usedEnvs) { | 157 if ($usedEnvs) { |
137 $e = new EnvParameterException($usedEnvs, $e); | 158 $e = new EnvParameterException($usedEnvs, $e); |
138 } | 159 } |
139 | 160 |
140 throw $e; | 161 throw $e; |
162 } finally { | |
163 $this->getServiceReferenceGraph()->clear(); | |
141 } | 164 } |
142 } | 165 } |
143 } | 166 } |