Skip to content

Commit ecd0fbb

Browse files
committed
Tweaks thanks to Nicolas
1 parent f882813 commit ecd0fbb

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/Symfony/Component/DependencyInjection/Compiler/AutowireExceptionPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
/**
1919
* Throws autowire exceptions from AutowirePass for definitions that still exist.
2020
*
21+
* @deprecated AutowireExceptionPass is deprecated since version 3.4 and will be removed in 4.0.
2122
* @author Ryan Weaver <ryan@knpuniversity.com>
2223
*/
2324
class AutowireExceptionPass implements CompilerPassInterface

src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct($throwOnAutowireException = true)
4444
}
4545

4646
/**
47-
* @deprecated
47+
* @deprecated since version 3.3, to be removed in 4.0.
4848
*
4949
* @return AutowiringFailedException[]
5050
*/

src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,20 @@ protected function processValue($value, $isRoot = false)
4242
foreach ($value->getArguments() as $k => $v) {
4343
if ($k !== $i++) {
4444
if (!is_int($k)) {
45-
$value->addError(sprintf('Invalid constructor argument for service "%s": integer expected but found string "%s". Check your service definition.', $this->currentId, $k));
45+
$msg = sprintf('Invalid constructor argument for service "%s": integer expected but found string "%s". Check your service definition.', $this->currentId, $k);
46+
$value->addError($msg);
4647

4748
if ($this->throwExceptions) {
48-
throw new RuntimeException(sprintf('Invalid constructor argument for service "%s": integer expected but found string "%s". Check your service definition.', $this->currentId, $k));
49+
throw new RuntimeException($msg);
4950
}
5051

5152
break;
5253
}
5354

54-
$value->addError(sprintf('Invalid constructor argument %d for service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $this->currentId, $i));
55+
$msg = sprintf('Invalid constructor argument %d for service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $this->currentId, $i);
56+
$value->addError($msg);
5557
if ($this->throwExceptions) {
56-
throw new RuntimeException(sprintf('Invalid constructor argument %d for service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $this->currentId, $i));
58+
throw new RuntimeException($msg);
5759
}
5860
}
5961
}
@@ -63,17 +65,20 @@ protected function processValue($value, $isRoot = false)
6365
foreach ($methodCall[1] as $k => $v) {
6466
if ($k !== $i++) {
6567
if (!is_int($k)) {
66-
$value->addError(sprintf('Invalid argument for method call "%s" of service "%s": integer expected but found string "%s". Check your service definition.', $methodCall[0], $this->currentId, $k));
68+
$msg = sprintf('Invalid argument for method call "%s" of service "%s": integer expected but found string "%s". Check your service definition.', $methodCall[0], $this->currentId, $k);
69+
$value->addError($msg);
70+
6771
if ($this->throwExceptions) {
68-
throw new RuntimeException(sprintf('Invalid argument for method call "%s" of service "%s": integer expected but found string "%s". Check your service definition.', $methodCall[0], $this->currentId, $k));
72+
throw new RuntimeException($msg);
6973
}
7074

7175
break;
7276
}
7377

74-
$value->addError(sprintf('Invalid argument %d for method call "%s" of service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $methodCall[0], $this->currentId, $i));
78+
$msg = sprintf('Invalid argument %d for method call "%s" of service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $methodCall[0], $this->currentId, $i);
79+
$value->addError($msg);
7580
if ($this->throwExceptions) {
76-
throw new RuntimeException(sprintf('Invalid argument %d for method call "%s" of service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $methodCall[0], $this->currentId, $i));
81+
throw new RuntimeException($msg);
7782
}
7883
}
7984
}

0 commit comments

Comments
 (0)