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)];
138
+
$message = [sprintf('Either method "%s::%s()" should ', $class, $defaultMethod), sprintf(' or tag "%s" on %s is missing attribute "%s".', $tagName, $service, $indexAttribute)];
128
139
} else {
129
-
$message = [sprintf('Method "%s::%s()" should ', $class, $defaultIndexMethod), '.'];
140
+
$message = [sprintf('Method "%s::%s()" should ', $class, $defaultMethod), '.'];
130
141
}
131
142
132
-
if (!($rm = $r->getMethod($defaultIndexMethod))->isStatic()) {
143
+
if (!($rm = $r->getMethod($defaultMethod))->isStatic()) {
if (!($r = $container->getReflectionClass($class)) || !$r->hasMethod($defaultPriorityMethod)) {
159
-
returnnull;
160
-
}
153
+
if ('priority' === $indexAttribute) {
154
+
if (!\is_int($default)) {
155
+
thrownewInvalidArgumentException(implode(sprintf('return int (got "%s")', get_debug_type($default)), $message));
156
+
}
161
157
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));
158
+
return$default;
164
159
}
165
160
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));
161
+
if (\is_int($default)) {
162
+
$default = (string) $default;
168
163
}
169
164
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