Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Configuration implements ConfigurationInterface
/**
* @return TreeBuilder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('graphqlite');
$rootNode = $treeBuilder->getRootNode();
Expand Down
34 changes: 9 additions & 25 deletions DependencyInjection/GraphQLiteCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -479,34 +479,18 @@ private function getCodeCache(): ClassBoundCacheContractInterface
* Returns the array of globbed classes.
* Only instantiable classes are returned.
*
* @return array<string,ReflectionClass<object>> Key: fully qualified class name
* @param string $namespace
* @return array<class-string, ReflectionClass<object>>|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;
}

}
4 changes: 2 additions & 2 deletions DependencyInjection/GraphQLiteExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand All @@ -57,7 +57,7 @@ function($namespace): string {
}
$namespaceType = array_map(
function($namespace): string {
return rtrim($namespace, '\\') . '\\';
return rtrim($namespace, '\\');
},
$types
);
Expand Down
24 changes: 12 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down