Skip to content
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

New Symfony and GraphQLite versions #203

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

class Configuration implements ConfigurationInterface
{
/**
* @return TreeBuilder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('graphqlite');
$rootNode = $treeBuilder->getRootNode();
Expand Down
36 changes: 9 additions & 27 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;
homersimpsons marked this conversation as resolved.
Show resolved Hide resolved
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;
homersimpsons marked this conversation as resolved.
Show resolved Hide resolved
use TheCodingMachine\GraphQLite\AggregateControllerQueryProviderFactory;
use TheCodingMachine\GraphQLite\AnnotationReader;
use TheCodingMachine\GraphQLite\Annotations\Autowire;
Expand Down Expand Up @@ -479,34 +479,16 @@ 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 Generator<class-string, ReflectionClass<object>, void, void>
*/
private function getClassList(string $namespace, int $globTtl = 2, bool $recursive = true): array
private function getClassList(string $namespace): 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()) {
continue;
}
$classes[$className] = $refClass;
$finder = new ComposerFinder();
foreach ($finder->inNamespace($namespace) as $class) {
assert($class instanceof ReflectionClass);
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
25 changes: 12 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,31 @@
}
],
"require" : {
"php" : ">=8.1",
"php" : ">=8.2",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this upgraded? Is it just for symfony 7? In this case it may be possible to keep it to 8.1 as it is still supported.

Suggested change
"php" : ">=8.2",
"php" : ">=8.1",

Copy link
Author

Choose a reason for hiding this comment

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

the problem is symfony/validator itself

"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": "^6.0 || ^7.0",
"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",
fogrye marked this conversation as resolved.
Show resolved Hide resolved
"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",
"symfony/event-dispatcher": "<4.3",
"symfony/security-core": "<4.3",
"symfony/routing": "<4.3",
Expand Down