diff --git a/src/Symfony/SymfonyContainerResultCacheMetaExtension.php b/src/Symfony/SymfonyContainerResultCacheMetaExtension.php index bc2cf67..1f93d7d 100644 --- a/src/Symfony/SymfonyContainerResultCacheMetaExtension.php +++ b/src/Symfony/SymfonyContainerResultCacheMetaExtension.php @@ -6,6 +6,7 @@ use function array_map; use function hash; use function serialize; +use function sort; final class SymfonyContainerResultCacheMetaExtension implements ResultCacheMetaExtension { @@ -29,20 +30,32 @@ public function getHash(): string { return hash('sha256', serialize([ 'parameters' => array_map( - static fn (ParameterDefinition $parameter) => [ + static fn (ParameterDefinition $parameter): array => [ 'name' => $parameter->getKey(), 'value' => $parameter->getValue(), ], $this->parameterMap->getParameters(), ), 'services' => array_map( - static fn (ServiceDefinition $service) => [ - 'id' => $service->getId(), - 'class' => $service->getClass(), - 'public' => $service->isPublic() ? 'yes' : 'no', - 'synthetic' => $service->isSynthetic() ? 'yes' : 'no', - 'alias' => $service->getAlias(), - ], + static function (ServiceDefinition $service): array { + $serviceTags = array_map( + static fn (ServiceTag $tag) => [ + 'name' => $tag->getName(), + 'attributes' => $tag->getAttributes(), + ], + $service->getTags(), + ); + sort($serviceTags); + + return [ + 'id' => $service->getId(), + 'class' => $service->getClass(), + 'public' => $service->isPublic() ? 'yes' : 'no', + 'synthetic' => $service->isSynthetic() ? 'yes' : 'no', + 'alias' => $service->getAlias(), + 'tags' => $serviceTags, + ]; + }, $this->serviceMap->getServices(), ), ])); diff --git a/tests/Symfony/SymfonyContainerResultCacheMetaExtensionTest.php b/tests/Symfony/SymfonyContainerResultCacheMetaExtensionTest.php index e0e8f34..d90b5a9 100644 --- a/tests/Symfony/SymfonyContainerResultCacheMetaExtensionTest.php +++ b/tests/Symfony/SymfonyContainerResultCacheMetaExtensionTest.php @@ -167,6 +167,89 @@ public static function provideContainerHashIsCalculatedCorrectlyCases(): iterabl XML, ]; + yield 'service tag attributes changes' => [ + [ + <<<'XML' + + + + + + + + + XML, + <<<'XML' + + + + + + + + + XML, + ], + <<<'XML' + + + + + + + + + XML, + ]; + + yield 'service tag added' => [ + [ + <<<'XML' + + + + + + + + XML, + ], + <<<'XML' + + + + + + + + + XML, + ]; + + yield 'service tag removed' => [ + [ + <<<'XML' + + + + + + + + + XML, + ], + <<<'XML' + + + + + + + + XML, + ]; + yield 'new service added' => [ [ <<<'XML'