You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$message = [sprintf('Either method "%s::%s()" should ', $class, $defaultIndexMethod), sprintf(' or tag "%s" on %s is missing attribute "%s".', $tagName, $service, $indexAttribute)];
140
+
$message = [sprintf('Either method "%s::%s()" should ', $class, $defaultMethod), sprintf(' or tag "%s" on %s is missing attribute "%s".', $tagName, $service, $indexAttribute)];
128
141
} else {
129
-
$message = [sprintf('Method "%s::%s()" should ', $class, $defaultIndexMethod), '.'];
142
+
$message = [sprintf('Method "%s::%s()" should ', $class, $defaultMethod), '.'];
130
143
}
131
144
132
-
if (!($rm = $r->getMethod($defaultIndexMethod))->isStatic()) {
145
+
if (!($rm = $r->getMethod($defaultMethod))->isStatic()) {
if (!($r = $container->getReflectionClass($class)) || !$r->hasMethod($defaultPriorityMethod)) {
159
-
returnnull;
160
-
}
155
+
if ('priority' === $indexAttribute) {
156
+
if (!\is_int($default)) {
157
+
thrownewInvalidArgumentException(implode(sprintf('return int (got "%s")', get_debug_type($default)), $message));
158
+
}
161
159
162
-
if (!($rm = $r->getMethod($defaultPriorityMethod))->isStatic()) {
163
-
thrownewInvalidArgumentException(sprintf('Either method "%s::%s()" should be static or tag "%s" on service "%s" is missing attribute "priority".', $class, $defaultPriorityMethod, $tagName, $serviceId));
160
+
return$default;
164
161
}
165
162
166
-
if (!$rm->isPublic()) {
167
-
thrownewInvalidArgumentException(sprintf('Either method "%s::%s()" should be public or tag "%s" on service "%s" is missing attribute "priority".', $class, $defaultPriorityMethod, $tagName, $serviceId));
163
+
if (\is_int($default)) {
164
+
$default = (string) $default;
168
165
}
169
166
170
-
$defaultPriority = $rm->invoke(null);
171
-
172
-
if (!\is_int($defaultPriority)) {
173
-
thrownewInvalidArgumentException(sprintf('Method "%s::%s()" should return an integer (got "%s") or tag "%s" on service "%s" is missing attribute "priority".', $class, $defaultPriorityMethod, get_debug_type($defaultPriority), $tagName, $serviceId));
@@ -188,6 +191,34 @@ public function provideInvalidDefaultMethods(): iterable
188
191
yield ['getMethodShouldBePublicInsteadPrivate', null, sprintf('Method "%s::getMethodShouldBePublicInsteadPrivate()" should be public.', FooTaggedForInvalidDefaultMethodClass::class)];
189
192
yield ['getMethodShouldBePublicInsteadPrivate', 'foo', sprintf('Either method "%s::getMethodShouldBePublicInsteadPrivate()" should be public or tag "my_custom_tag" on service "service1" is missing attribute "foo".', FooTaggedForInvalidDefaultMethodClass::class)];
0 commit comments