From ed9d0566bc45e472db53a335de1a44db65bdba15 Mon Sep 17 00:00:00 2001 From: Mathieu Rochette Date: Fri, 12 Jan 2024 10:53:07 +0100 Subject: [PATCH 1/3] Only look at attributes implementing Annotation This make the code slight more efficient as it avoids instantiating unrelated attributes and also prevents crashes in case some attributes cannot be instantiated --- src/Config/Parser/AttributeParser.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Config/Parser/AttributeParser.php b/src/Config/Parser/AttributeParser.php index 250a50561..11f658164 100644 --- a/src/Config/Parser/AttributeParser.php +++ b/src/Config/Parser/AttributeParser.php @@ -5,6 +5,7 @@ namespace Overblog\GraphQLBundle\Config\Parser; use Overblog\GraphQLBundle\Config\Parser\MetadataParser\MetadataParser; +use Overblog\GraphQLBundle\Annotation\Annotation; use ReflectionAttribute; use ReflectionClass; use ReflectionClassConstant; @@ -26,7 +27,7 @@ public static function getMetadatas(Reflector $reflector): array case $reflector instanceof ReflectionProperty: case $reflector instanceof ReflectionClassConstant: if (is_callable([$reflector, 'getAttributes'])) { - $attributes = $reflector->getAttributes(); + $attributes = $reflector->getAttributes(Annotation::class, \ReflectionAttribute::IS_INSTANCEOF); } } From 02a2d98fddc52537bdacebea5d1d71907d4deacd Mon Sep 17 00:00:00 2001 From: Mathieu Rochette Date: Fri, 12 Jan 2024 11:44:23 +0100 Subject: [PATCH 2/3] Update src/Config/Parser/AttributeParser.php --- src/Config/Parser/AttributeParser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/Parser/AttributeParser.php b/src/Config/Parser/AttributeParser.php index 11f658164..434435702 100644 --- a/src/Config/Parser/AttributeParser.php +++ b/src/Config/Parser/AttributeParser.php @@ -27,7 +27,7 @@ public static function getMetadatas(Reflector $reflector): array case $reflector instanceof ReflectionProperty: case $reflector instanceof ReflectionClassConstant: if (is_callable([$reflector, 'getAttributes'])) { - $attributes = $reflector->getAttributes(Annotation::class, \ReflectionAttribute::IS_INSTANCEOF); + $attributes = $reflector->getAttributes(Annotation::class, ReflectionAttribute::IS_INSTANCEOF); } } From 686a9ae4221a64e04cd57f50128a4cb8219ee639 Mon Sep 17 00:00:00 2001 From: Mathieu Rochette Date: Fri, 12 Jan 2024 11:52:29 +0100 Subject: [PATCH 3/3] Update src/Config/Parser/AttributeParser.php --- src/Config/Parser/AttributeParser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/Parser/AttributeParser.php b/src/Config/Parser/AttributeParser.php index 434435702..c4d938c6f 100644 --- a/src/Config/Parser/AttributeParser.php +++ b/src/Config/Parser/AttributeParser.php @@ -4,8 +4,8 @@ namespace Overblog\GraphQLBundle\Config\Parser; -use Overblog\GraphQLBundle\Config\Parser\MetadataParser\MetadataParser; use Overblog\GraphQLBundle\Annotation\Annotation; +use Overblog\GraphQLBundle\Config\Parser\MetadataParser\MetadataParser; use ReflectionAttribute; use ReflectionClass; use ReflectionClassConstant;