Skip to content

Commit aebae80

Browse files
committed
[DependencyInjection] improve deprecation messages
Also include the service id in the deprecation message.
1 parent 7fbcd20 commit aebae80

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Loader/XmlFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private function parseDefinition(\DOMElement $service, $file)
151151
foreach (array('class', 'scope', 'public', 'factory-class', 'factory-method', 'factory-service', 'synthetic', 'lazy', 'abstract') as $key) {
152152
if ($value = $service->getAttribute($key)) {
153153
if (in_array($key, array('factory-class', 'factory-method', 'factory-service'))) {
154-
@trigger_error(sprintf('The "%s" attribute in file "%s" is deprecated since version 2.6 and will be removed in 3.0. Use the "factory" element instead.', $key, $file), E_USER_DEPRECATED);
154+
@trigger_error(sprintf('The "%s" attribute of service "%s" in file "%s" is deprecated since version 2.6 and will be removed in 3.0. Use the "factory" element instead.', $key, (string) $service->getAttribute('id'), $file), E_USER_DEPRECATED);
155155
}
156156
$method = 'set'.str_replace('-', '', $key);
157157
$definition->$method(XmlUtils::phpize($value));
@@ -162,7 +162,7 @@ private function parseDefinition(\DOMElement $service, $file)
162162
$triggerDeprecation = 'request' !== (string) $service->getAttribute('id');
163163

164164
if ($triggerDeprecation) {
165-
@trigger_error(sprintf('The "synchronized" attribute in file "%s" is deprecated since version 2.7 and will be removed in 3.0.', $file), E_USER_DEPRECATED);
165+
@trigger_error(sprintf('The "synchronized" attribute of service "%s" in file "%s" is deprecated since version 2.7 and will be removed in 3.0.', (string) $service->getAttribute('id'), $file), E_USER_DEPRECATED);
166166
}
167167

168168
$definition->setSynchronized(XmlUtils::phpize($value), $triggerDeprecation);

Loader/YamlFileLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private function parseDefinition($id, $service, $file)
172172
}
173173

174174
if (isset($service['synchronized'])) {
175-
@trigger_error(sprintf('The "synchronized" key in file "%s" is deprecated since version 2.7 and will be removed in 3.0.', $file), E_USER_DEPRECATED);
175+
@trigger_error(sprintf('The "synchronized" key of service "%s" in file "%s" is deprecated since version 2.7 and will be removed in 3.0.', $id, $file), E_USER_DEPRECATED);
176176
$definition->setSynchronized($service['synchronized'], 'request' !== $id);
177177
}
178178

@@ -202,17 +202,17 @@ private function parseDefinition($id, $service, $file)
202202
}
203203

204204
if (isset($service['factory_class'])) {
205-
@trigger_error(sprintf('The "factory_class" key in file "%s" is deprecated since version 2.6 and will be removed in 3.0. Use "factory" instead.', $file), E_USER_DEPRECATED);
205+
@trigger_error(sprintf('The "factory_class" key of service "%s" in file "%s" is deprecated since version 2.6 and will be removed in 3.0. Use "factory" instead.', $id, $file), E_USER_DEPRECATED);
206206
$definition->setFactoryClass($service['factory_class']);
207207
}
208208

209209
if (isset($service['factory_method'])) {
210-
@trigger_error(sprintf('The "factory_method" key in file "%s" is deprecated since version 2.6 and will be removed in 3.0. Use "factory" instead.', $file), E_USER_DEPRECATED);
210+
@trigger_error(sprintf('The "factory_method" key of service "%s" in file "%s" is deprecated since version 2.6 and will be removed in 3.0. Use "factory" instead.', $id, $file), E_USER_DEPRECATED);
211211
$definition->setFactoryMethod($service['factory_method']);
212212
}
213213

214214
if (isset($service['factory_service'])) {
215-
@trigger_error(sprintf('The "factory_service" key in file "%s" is deprecated since version 2.6 and will be removed in 3.0. Use "factory" instead.', $file), E_USER_DEPRECATED);
215+
@trigger_error(sprintf('The "factory_service" key of service "%s" in file "%s" is deprecated since version 2.6 and will be removed in 3.0. Use "factory" instead.', $id, $file), E_USER_DEPRECATED);
216216
$definition->setFactoryService($service['factory_service']);
217217
}
218218

0 commit comments

Comments
 (0)