From ffd0c9e0f145f091926237736fc0beb14dacf474 Mon Sep 17 00:00:00 2001 From: Yurii Kuvshynov <141632421+fogrye@users.noreply.github.com> Date: Thu, 28 Mar 2024 21:30:41 +0100 Subject: [PATCH 01/11] chore: update deps --- composer.json | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 5e47330..ba48401 100644 --- a/composer.json +++ b/composer.json @@ -18,30 +18,30 @@ "require" : { "php" : ">=8.1", "ext-json": "*", - "thecodingmachine/graphqlite" : "^6.0", - "thecodingmachine/graphqlite-symfony-validator-bridge" : "^6.0", - "symfony/framework-bundle": "^6", - "symfony/validator": "^6", - "symfony/translation": "^6", + "thecodingmachine/graphqlite" : "^7.0", + "thecodingmachine/graphqlite-symfony-validator-bridge": "dev-master", + "symfony/framework-bundle": "^6.0 || ^7.0", + "symfony/validator": "^6.0 || ^7.0", + "symfony/translation": "^6.0 || ^7.0", "doctrine/annotations": "^1.13 || ^2.0.1", - "symfony/psr-http-message-bridge": "^2.0", + "symfony/psr-http-message-bridge": "^6.0 || ^7.0", "nyholm/psr7": "^1.1", - "laminas/laminas-diactoros": "^2.2.2", + "laminas/laminas-diactoros": "^2.2 || ^3.0", "overblog/graphiql-bundle": "^0.2 || ^0.3", "thecodingmachine/cache-utils": "^1", - "symfony/console": "^6" + "symfony/console": "^6.0 || ^7.0" }, "require-dev": { - "symfony/security-bundle": "^6", - "symfony/yaml": "^6", + "symfony/security-bundle": "^6.0 || ^7.0", + "symfony/yaml": "^6.0 || ^7.0", "beberlei/porpaginas": "^1.2 || ^2.0", "php-coveralls/php-coveralls": "^2.1.0", - "symfony/phpunit-bridge": "^6 || ^7", + "symfony/phpunit-bridge": "^6.0 || ^7.0", "phpstan/phpstan": "^1.8", "composer/package-versions-deprecated": "^1.8" }, "conflict": { - "mouf/classname-mapper": "<1.0.2", + "thecodingmachine/graphqlite": "<7.0", "symfony/event-dispatcher": "<4.3", "symfony/security-core": "<4.3", "symfony/routing": "<4.3", @@ -58,6 +58,12 @@ "TheCodingMachine\\GraphQLite\\Bundle\\" : "" } }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/fogrye/graphqlite-symfony-validator-bridge.git" + } + ], "extra": { "branch-alias": { "dev-master": "6.0.x-dev" From f07540aaa20a5df43766fa5a3fc5713ecd010461 Mon Sep 17 00:00:00 2001 From: Yurii Kuvshynov <141632421+fogrye@users.noreply.github.com> Date: Thu, 28 Mar 2024 21:31:26 +0100 Subject: [PATCH 02/11] fix: replace ClassNameMapper with Finder --- DependencyInjection/Configuration.php | 2 +- .../GraphQLiteCompilerPass.php | 34 +++++-------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 21a29b1..3ea06eb 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -11,7 +11,7 @@ class Configuration implements ConfigurationInterface /** * @return TreeBuilder */ - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('graphqlite'); $rootNode = $treeBuilder->getRootNode(); diff --git a/DependencyInjection/GraphQLiteCompilerPass.php b/DependencyInjection/GraphQLiteCompilerPass.php index bee4783..af4b9dd 100644 --- a/DependencyInjection/GraphQLiteCompilerPass.php +++ b/DependencyInjection/GraphQLiteCompilerPass.php @@ -4,10 +4,12 @@ namespace TheCodingMachine\GraphQLite\Bundle\DependencyInjection; use Doctrine\Common\Annotations\PsrCachedReader; +use Generator; use GraphQL\Server\ServerConfig; use GraphQL\Validator\Rules\DisableIntrospection; use GraphQL\Validator\Rules\QueryComplexity; use GraphQL\Validator\Rules\QueryDepth; +use Kcs\ClassFinder\Finder\ComposerFinder; use ReflectionNamedType; use Symfony\Component\Cache\Adapter\ApcuAdapter; use Symfony\Component\Cache\Adapter\PhpFilesAdapter; @@ -19,7 +21,6 @@ use function class_exists; use Doctrine\Common\Annotations\AnnotationReader as DoctrineAnnotationReader; use Doctrine\Common\Annotations\AnnotationRegistry; -use Mouf\Composer\ClassNameMapper; use Psr\SimpleCache\CacheInterface; use ReflectionParameter; use function filter_var; @@ -40,7 +41,6 @@ use TheCodingMachine\CacheUtils\ClassBoundCacheContractInterface; use TheCodingMachine\CacheUtils\ClassBoundMemoryAdapter; use TheCodingMachine\CacheUtils\FileBoundCache; -use TheCodingMachine\ClassExplorer\Glob\GlobClassExplorer; use TheCodingMachine\GraphQLite\AggregateControllerQueryProviderFactory; use TheCodingMachine\GraphQLite\AnnotationReader; use TheCodingMachine\GraphQLite\Annotations\Autowire; @@ -479,34 +479,18 @@ private function getCodeCache(): ClassBoundCacheContractInterface * Returns the array of globbed classes. * Only instantiable classes are returned. * - * @return array> Key: fully qualified class name + * @param string $namespace + * @return array>|Generator Key: fully qualified class name */ - private function getClassList(string $namespace, int $globTtl = 2, bool $recursive = true): array + private function getClassList(string $namespace): array|Generator { - $explorer = new GlobClassExplorer($namespace, $this->getPsr16Cache(), $globTtl, ClassNameMapper::createFromComposerFile(null, null, true), $recursive); - $allClasses = $explorer->getClassMap(); - $classes = []; - foreach ($allClasses as $className => $phpFile) { - if (! class_exists($className, false)) { - // Let's try to load the file if it was not imported yet. - // We are importing the file manually to avoid triggering the autoloader. - // The autoloader might trigger errors if the file does not respect PSR-4 or if the - // Symfony DebugAutoLoader is installed. (see https://github.com/thecodingmachine/graphqlite/issues/216) - require_once $phpFile; - // @phpstan-ignore-next-line Does it exist now? - if (! class_exists($className, false)) { - continue; - } - } - - $refClass = new ReflectionClass($className); - if (! $refClass->isInstantiable()) { + $finder = new ComposerFinder(); + foreach ($finder->inNamespace($namespace) as $class) { + if (!$class instanceof ReflectionClass){ continue; } - $classes[$className] = $refClass; + yield $class->getName() => $class; } - - return $classes; } } From c6b6b79f2b084a3838cf18ba5e53652120566098 Mon Sep 17 00:00:00 2001 From: Yurii Kuvshynov <141632421+fogrye@users.noreply.github.com> Date: Thu, 28 Mar 2024 22:21:18 +0100 Subject: [PATCH 03/11] fix: namespace should not end with \ --- DependencyInjection/GraphQLiteExtension.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/GraphQLiteExtension.php b/DependencyInjection/GraphQLiteExtension.php index 8fa97ce..a6b4b10 100644 --- a/DependencyInjection/GraphQLiteExtension.php +++ b/DependencyInjection/GraphQLiteExtension.php @@ -43,7 +43,7 @@ public function load(array $configs, ContainerBuilder $container): void } $namespaceController = array_map( function($namespace): string { - return rtrim($namespace, '\\') . '\\'; + return rtrim($namespace, '\\'); }, $controllers ); @@ -57,7 +57,7 @@ function($namespace): string { } $namespaceType = array_map( function($namespace): string { - return rtrim($namespace, '\\') . '\\'; + return rtrim($namespace, '\\'); }, $types ); From 8e606f355d6995ddfb9c1d3dec8f1f7d910200b2 Mon Sep 17 00:00:00 2001 From: Yurii Kuvshynov <141632421+fogrye@users.noreply.github.com> Date: Thu, 28 Mar 2024 22:24:55 +0100 Subject: [PATCH 04/11] rm fork --- composer.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/composer.json b/composer.json index ba48401..1629d43 100644 --- a/composer.json +++ b/composer.json @@ -58,12 +58,6 @@ "TheCodingMachine\\GraphQLite\\Bundle\\" : "" } }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/fogrye/graphqlite-symfony-validator-bridge.git" - } - ], "extra": { "branch-alias": { "dev-master": "6.0.x-dev" From f489d4c40605706bf9514746b6bd1c2d3dae4267 Mon Sep 17 00:00:00 2001 From: Yurii <141632421+fogrye@users.noreply.github.com> Date: Fri, 29 Mar 2024 14:34:44 +0100 Subject: [PATCH 05/11] Update composer.json Co-authored-by: homersimpsons --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 1629d43..ad5265b 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,6 @@ "composer/package-versions-deprecated": "^1.8" }, "conflict": { - "thecodingmachine/graphqlite": "<7.0", "symfony/event-dispatcher": "<4.3", "symfony/security-core": "<4.3", "symfony/routing": "<4.3", From 3bb6569516b5ee2036c6581507de380830e4318f Mon Sep 17 00:00:00 2001 From: Yurii Kuvshynov <141632421+fogrye@users.noreply.github.com> Date: Fri, 29 Mar 2024 16:09:45 +0100 Subject: [PATCH 06/11] fix: typing --- DependencyInjection/GraphQLiteCompilerPass.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/GraphQLiteCompilerPass.php b/DependencyInjection/GraphQLiteCompilerPass.php index af4b9dd..691dff5 100644 --- a/DependencyInjection/GraphQLiteCompilerPass.php +++ b/DependencyInjection/GraphQLiteCompilerPass.php @@ -480,9 +480,9 @@ private function getCodeCache(): ClassBoundCacheContractInterface * Only instantiable classes are returned. * * @param string $namespace - * @return array>|Generator Key: fully qualified class name + * @return Generator, void, void> */ - private function getClassList(string $namespace): array|Generator + private function getClassList(string $namespace): Generator { $finder = new ComposerFinder(); foreach ($finder->inNamespace($namespace) as $class) { From 6bf83513b20c3f2e344b6e5586d9db54ac977fa3 Mon Sep 17 00:00:00 2001 From: Yurii Kuvshynov <141632421+fogrye@users.noreply.github.com> Date: Fri, 29 Mar 2024 18:04:24 +0100 Subject: [PATCH 07/11] fix: assertion --- DependencyInjection/GraphQLiteCompilerPass.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/DependencyInjection/GraphQLiteCompilerPass.php b/DependencyInjection/GraphQLiteCompilerPass.php index 691dff5..a13be84 100644 --- a/DependencyInjection/GraphQLiteCompilerPass.php +++ b/DependencyInjection/GraphQLiteCompilerPass.php @@ -486,9 +486,7 @@ private function getClassList(string $namespace): Generator { $finder = new ComposerFinder(); foreach ($finder->inNamespace($namespace) as $class) { - if (!$class instanceof ReflectionClass){ - continue; - } + assert($class instanceof ReflectionClass); yield $class->getName() => $class; } } From d8002cdc30b3801719d330f1c73b74bff33c7f76 Mon Sep 17 00:00:00 2001 From: Yurii Kuvshynov <141632421+fogrye@users.noreply.github.com> Date: Sat, 13 Apr 2024 21:45:35 +0200 Subject: [PATCH 08/11] chore: correct validator version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ad5265b..61201f0 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php" : ">=8.1", "ext-json": "*", "thecodingmachine/graphqlite" : "^7.0", - "thecodingmachine/graphqlite-symfony-validator-bridge": "dev-master", + "thecodingmachine/graphqlite-symfony-validator-bridge": "^6.0 || ^7.0", "symfony/framework-bundle": "^6.0 || ^7.0", "symfony/validator": "^6.0 || ^7.0", "symfony/translation": "^6.0 || ^7.0", From 0fab790c1b5d3e979952dd7b82f143144dfa258e Mon Sep 17 00:00:00 2001 From: Yurii Kuvshynov <141632421+fogrye@users.noreply.github.com> Date: Sat, 13 Apr 2024 21:57:33 +0200 Subject: [PATCH 09/11] fix: unnecessary phpdoc --- DependencyInjection/Configuration.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 3ea06eb..1991328 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -8,9 +8,6 @@ class Configuration implements ConfigurationInterface { - /** - * @return TreeBuilder - */ public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('graphqlite'); From a41d88d93047433fcf7a7460f12a9ffd98a58c33 Mon Sep 17 00:00:00 2001 From: Yurii <141632421+fogrye@users.noreply.github.com> Date: Sat, 4 May 2024 10:46:45 +0200 Subject: [PATCH 10/11] chore: bump php version to satisfy symfony packages --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 61201f0..1ec2def 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require" : { - "php" : ">=8.1", + "php" : ">=8.2", "ext-json": "*", "thecodingmachine/graphqlite" : "^7.0", "thecodingmachine/graphqlite-symfony-validator-bridge": "^6.0 || ^7.0", From 88cf5a41e75a9ea6ac6cbb5e6dfa3c650d93658a Mon Sep 17 00:00:00 2001 From: Yurii <141632421+fogrye@users.noreply.github.com> Date: Sun, 5 May 2024 10:57:51 +0200 Subject: [PATCH 11/11] fix(ci): bump ci php version --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9cbdc20..a406edf 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -12,7 +12,7 @@ jobs: strategy: matrix: install-args: [''] - php-version: ['8.1'] + php-version: ['8.2'] fail-fast: false steps: # Cancel previous runs of the same branch