Skip to content

[DependencyInjection] Define default priority inside service class #31943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Closed
Prev Previous commit
Next Next commit
fixed some code standard
  • Loading branch information
pcabreus committed Jun 11, 2019
commit c021fc8452703627c01dfbdf50c398355b039cfe
Original file line number Diff line number Diff line change
Expand Up @@ -63,43 +63,18 @@ private function findAndSortTaggedServices($tagName, ContainerBuilder $container

$priority = 0;
if ($defaultPriorityMethod && $r->hasMethod($defaultPriorityMethod)) {
if (!($rpm = $r->getMethod($defaultPriorityMethod))->isStatic()) {
throw new InvalidArgumentException(
sprintf(
'Default priority method "%s::%s()" of the "%s"-tagged collection on service "%s" must be static.',
$class,
$defaultPriorityMethod,
$tagName,
$serviceId
)
);
if (!($priorityReflMethod = $r->getMethod($defaultPriorityMethod))->isStatic()) {
throw new InvalidArgumentException(sprintf('Default priority method "%s::%s()" of the "%s"-tagged collection on service "%s" must be static.', $class, $defaultPriorityMethod, $tagName, $serviceId));
}

if (!$rpm->isPublic()) {
throw new InvalidArgumentException(
sprintf(
'Method "%s::%s()" should be public: tag "%s" on service "%s" is missing default priority method.',
$class,
$defaultPriorityMethod,
$tagName,
$serviceId
)
);
if (!$priorityReflMethod->isPublic()) {
throw new InvalidArgumentException(sprintf('Method "%s::%s()" should be public: tag "%s" on service "%s" is missing default priority method.', $class, $defaultPriorityMethod, $tagName, $serviceId));
}

$priority = $rpm->invoke(null);
$priority = $priorityReflMethod->invoke(null);

if (!\is_int($priority)) {
throw new InvalidArgumentException(
sprintf(
'Method "%s::%s()" should return an integer, got %s: tag "%s" on service "%s" is missing default priority method.',
$class,
$defaultPriorityMethod,
\gettype($priority),
$tagName,
$serviceId
)
);
throw new InvalidArgumentException(sprintf('Method "%s::%s()" should return an integer, got %s: tag "%s" on service "%s" is missing default priority method.', $class, $defaultPriorityMethod, \gettype($priority), $tagName, $serviceId));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,6 @@ function tagged(string $tag, string $indexAttribute = null, string $defaultIndex

/**
* Creates a lazy iterator by tag name.
*
* @param string $tag
* @param string|null $indexAttribute
* @param string|null $defaultIndexMethod
* @param bool $needsIndexes
* @param string|null $defaultPriorityMethod
*
* @return TaggedIteratorArgument
*/
function tagged_iterator(string $tag, string $indexAttribute = null, string $defaultIndexMethod = null, bool $needsIndexes = false, string $defaultPriorityMethod = null): TaggedIteratorArgument
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$needsIndexes should be removed, it's always false for iterators

{
Expand All @@ -143,14 +135,6 @@ function tagged_iterator(string $tag, string $indexAttribute = null, string $def

/**
* Creates a service locator by tag name.
*
* @param string $tag
* @param string $indexAttribute
* @param string|null $defaultIndexMethod
* @param bool $needsIndexes
* @param string|null $defaultPriorityMethod
*
* @return ServiceLocatorArgument
*/
function tagged_locator(string $tag, string $indexAttribute, string $defaultIndexMethod = null, bool $needsIndexes = true, string $defaultPriorityMethod = null): ServiceLocatorArgument
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$needsIndexes should be removed, it's always true for locators

{
Expand All @@ -159,10 +143,6 @@ function tagged_locator(string $tag, string $indexAttribute, string $defaultInde

/**
* Creates an expression.
*
* @param string $expression
*
* @return Expression
*/
function expr(string $expression): Expression
{
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy