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
if (($r = ($r ?? $container->getReflectionClass($class))) && $r->hasMethod($defaultPriorityMethod)) {
71
-
if (!($rm = $r->getMethod($defaultPriorityMethod))->isStatic()) {
72
-
thrownewInvalidArgumentException(sprintf('Method "%s::%s()" should be static: tag "%s" on service "%s".', $class, $defaultPriorityMethod, $tagName, $serviceId));
73
-
}
74
-
75
-
if (!$rm->isPublic()) {
76
-
thrownewInvalidArgumentException(sprintf('Method "%s::%s()" should be public: tag "%s" on service "%s".', $class, $defaultPriorityMethod, $tagName, $serviceId));
77
-
}
78
-
79
-
$defaultPriority = $rm->invoke(null);
80
-
81
-
if (!\is_int($defaultPriority)) {
82
-
thrownewInvalidArgumentException(sprintf('Method "%s::%s()" should return an integer, got %s: tag "%s" on service "%s".', $class, $defaultPriorityMethod, \gettype($priority), $tagName, $serviceId));
if (($r = ($r ?? $container->getReflectionClass($class))) && $r->hasMethod($defaultIndexMethod)) {
101
-
if (!($rm = $r->getMethod($defaultIndexMethod))->isStatic()) {
102
-
thrownewInvalidArgumentException(sprintf('Method "%s::%s()" should be static: tag "%s" on service "%s" is missing "%s" attribute.', $class, $defaultIndexMethod, $tagName, $serviceId, $indexAttribute));
thrownewInvalidArgumentException(sprintf('Method "%s::%s()" should be public: tag "%s" on service "%s" is missing "%s" attribute.', $class, $defaultIndexMethod, $tagName, $serviceId, $indexAttribute));
107
-
}
86
+
if ($services) {
87
+
krsort($services);
88
+
$services = array_merge(...$services);
89
+
}
108
90
109
-
$defaultIndex = $rm->invoke(null);
91
+
return$services;
92
+
}
93
+
}
110
94
111
-
if (!\is_string($defaultIndex)) {
112
-
thrownewInvalidArgumentException(sprintf('Method "%s::%s()" should return a string, got %s: tag "%s" on service "%s" is missing "%s" attribute.', $class, $defaultIndexMethod, \gettype($defaultIndex), $tagName, $serviceId, $indexAttribute));
113
-
}
114
-
}
95
+
/**
96
+
* @internal
97
+
*/
98
+
class PriorityTaggedServiceUtil
99
+
{
100
+
/**
101
+
* Gets the index defined by the default index method.
if (!($r = $r ?? $container->getReflectionClass($class)) || !$r->hasMethod($defaultIndexMethod)) {
109
+
returnnull;
110
+
}
118
111
119
-
$index = $index ?? $defaultIndex;
112
+
if (!($rm = $r->getMethod($defaultIndexMethod))->isStatic()) {
113
+
thrownewInvalidArgumentException(sprintf('Either method "%s::%s()" should be static or tag "%s" on service "%s" is missing attribute "%s".', $class, $defaultIndexMethod, $tagName, $serviceId, $indexAttribute));
thrownewInvalidArgumentException(sprintf('Either method "%s::%s()" should be public or tag "%s" on service "%s" is missing attribute "%s".', $class, $defaultIndexMethod, $tagName, $serviceId, $indexAttribute));
118
+
}
129
119
130
-
$services[$priority][$index] = $reference;
131
-
}
120
+
$defaultIndex = $rm->invoke(null);
121
+
122
+
if (!\is_string($defaultIndex)) {
123
+
thrownewInvalidArgumentException(sprintf('Either method "%s::%s()" should return a string (got %s) or tag "%s" on service "%s" is missing attribute "%s".', $class, $defaultIndexMethod, \gettype($defaultIndex), $tagName, $serviceId, $indexAttribute));
132
124
}
133
125
134
-
if ($services) {
135
-
krsort($services);
136
-
$services = array_merge(...$services);
126
+
return [$defaultIndex, $class, $r];
127
+
}
128
+
129
+
/**
130
+
* Gets the priority defined by the default priority method.
if (!($r = $r ?? $container->getReflectionClass($class)) || !$r->hasMethod($defaultPriorityMethod)) {
138
+
returnnull;
137
139
}
138
140
139
-
return$services;
141
+
if (!($rm = $r->getMethod($defaultPriorityMethod))->isStatic()) {
142
+
thrownewInvalidArgumentException(sprintf('Either method "%s::%s()" should be static or tag "%s" on service "%s" is missing attribute "priority".', $class, $defaultPriorityMethod, $tagName, $serviceId));
143
+
}
144
+
145
+
if (!$rm->isPublic()) {
146
+
thrownewInvalidArgumentException(sprintf('Either method "%s::%s()" should be public or tag "%s" on service "%s" is missing attribute "priority".', $class, $defaultPriorityMethod, $tagName, $serviceId));
147
+
}
148
+
149
+
$defaultPriority = $rm->invoke(null);
150
+
151
+
if (!\is_int($defaultPriority)) {
152
+
thrownewInvalidArgumentException(sprintf('Method "%s::%s()" should return an integer (got %s) or tag "%s" on service "%s" is missing attribute "priority".', $class, $defaultPriorityMethod, \gettype($defaultPriority), $tagName, $serviceId));
0 commit comments