From f6d1dc54bb37e56b5e26a8a8f952cc2d5211bbc8 Mon Sep 17 00:00:00 2001 From: Prajapati Kaushik Date: Tue, 14 Feb 2023 14:00:30 +0000 Subject: [PATCH 1/2] chore: support php8 and symfony6 #6867 --- composer.json | 22 ++++++---- src/Server.php | 8 ++-- .../DependencyInjection/ContainerFactory.php | 42 +++++++++++++++---- 3 files changed, 49 insertions(+), 23 deletions(-) diff --git a/composer.json b/composer.json index a06b68d..c652949 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,11 @@ "name": "linkorb/graphael", "description": "Graphael: GraphQL Server builder", "homepage": "http://www.github.com/linkorb/graphael", - "keywords": ["graphael", "graphql", "linkorb"], + "keywords": [ + "graphael", + "graphql", + "linkorb" + ], "type": "application", "authors": [ { @@ -13,20 +17,20 @@ ], "require": { "php": ">=7.2", - "symfony/options-resolver": "~3.0", - "symfony/dependency-injection": "~3.3", - "webonyx/graphql-php": "^0.13.8", - "linkorb/connector": "~1.0", + "symfony/options-resolver": "^5.0 || ^6.0", + "symfony/dependency-injection": " ^5.0 || ^6.0", + "webonyx/graphql-php": "^14.0.0", + "linkorb/connector": "^1.0", "firebase/php-jwt": "~5.0", "pwa/time-elapsed": "^1.0", - "symfony/security-core": "^4.2 || ^5.0 ", - "symfony/http-foundation": "^4.2 || ^5.0", + "symfony/security-core": "^6.0", + "symfony/http-foundation": " ^5.0 || ^6.0", "ext-pdo": "*", - "doctrine/cache": "^1.10" + "doctrine/cache": "^2.0" }, "autoload": { "psr-4": { - "Graphael\\": "src/" + "Graphael\\": "src/" } }, "license": "MIT" diff --git a/src/Server.php b/src/Server.php index 848f353..8d58677 100644 --- a/src/Server.php +++ b/src/Server.php @@ -3,10 +3,10 @@ namespace Graphael; use Graphael\Services\FieldResolver; +use GraphQL\Error\DebugFlag; use GraphQL\Server\StandardServer; use GraphQL\Type\Definition\ObjectType; use GraphQL\Type\Schema; -use GraphQL\Error\Debug; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; class Server extends StandardServer @@ -23,8 +23,7 @@ public function __construct( AuthorizationCheckerInterface $authorizationChecker, string $adminRole, $request - ) - { + ) { $schema = new Schema( [ 'query' => $queryType, @@ -35,7 +34,7 @@ public function __construct( $config = [ 'schema' => $schema, - 'debug' => Debug::INCLUDE_DEBUG_MESSAGE | Debug::INCLUDE_TRACE, + 'debugFlag' => DebugFlag::INCLUDE_DEBUG_MESSAGE | DebugFlag::INCLUDE_TRACE, 'rootValue' => $rootValue, 'fieldResolver' => [new FieldResolver(), 'resolve'], 'context' => [ @@ -45,7 +44,6 @@ public function __construct( ], ]; - parent::__construct($config); } } diff --git a/src/Services/DependencyInjection/ContainerFactory.php b/src/Services/DependencyInjection/ContainerFactory.php index 5169b90..c101386 100644 --- a/src/Services/DependencyInjection/ContainerFactory.php +++ b/src/Services/DependencyInjection/ContainerFactory.php @@ -2,6 +2,7 @@ namespace Graphael\Services\DependencyInjection; +use Connector\Connector; use Graphael\Security\Authorization\UsernameVoter; use Graphael\Security\JwtCertManager\JwtCertManager; use Graphael\Security\JwtCertManager\JwtCertManagerInterface; @@ -14,15 +15,10 @@ use Graphael\Server; use Graphael\Services\Error\ErrorHandler; use Graphael\Services\Error\ErrorHandlerInterface; -use PDO; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -use Connector\Connector; -use ReflectionClass; -use RuntimeException; -use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager; use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver; use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface; @@ -173,15 +169,22 @@ private static function registerSecurityServices(ContainerBuilder $container, ar $container->register(TokenStorageInterface::class, TokenStorage::class) ->setPublic(true); + /* $authenticationManager = $container->register( AuthenticationManagerInterface::class, AuthenticationProviderManager::class ); + */ + $authenticationManager = $container->register( + AuthenticationTrustResolverInterface::class, + AuthenticationTrustResolver::class + ); + $authenticationManager->addArgument([new Reference(JwtAuthProvider::class)]); $container->register(AccessDecisionManagerInterface::class, AccessDecisionManager::class) ->addArgument(static::normalizedVoters($config[static::AUTH_VOTERS])) - ->addArgument(AccessDecisionManager::STRATEGY_AFFIRMATIVE) + // ->addArgument(AccessDecisionManager::STRATEGY_AFFIRMATIVE) ->addArgument(false); static::autoRegisterClass($container, SecurityFacade::class) @@ -269,8 +272,29 @@ private static function autoRegisterClass(ContainerBuilder $container, $classNam $reflectionClass = new ReflectionClass($className); $constructor = $reflectionClass->getConstructor(); $definition = $container->register($className, $className); + + /* + if (!$constructor) { + var_dump($className); + exit; + } + */ + + if (!$constructor) { + // $reflectionClass = $reflectionClass->gettype(); + if ($reflectionClass) { + $definition->addArgument($reflectionClass->getName()); + } + + return $definition; + } + foreach ($constructor->getParameters() as $p) { - $reflectionClass = $p->getClass(); + // $reflectionClass = $p->getClass(); + + $reflectionClass = $p->getType() && !$p->getType()->isBuiltin() + ? new \ReflectionClass($p->getType()->getName()) + : null; if ($reflectionClass) { $definition->addArgument(new Reference($reflectionClass->getName())); } From f5a50bcb5de07808d6bec4129b82bf1ffba17fff Mon Sep 17 00:00:00 2001 From: Prajapati Kaushik Date: Mon, 20 Feb 2023 08:00:06 +0000 Subject: [PATCH 2/2] chore: support php8 and symfony6 #6867 --- .../DependencyInjection/ContainerFactory.php | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/Services/DependencyInjection/ContainerFactory.php b/src/Services/DependencyInjection/ContainerFactory.php index c101386..6a8935e 100644 --- a/src/Services/DependencyInjection/ContainerFactory.php +++ b/src/Services/DependencyInjection/ContainerFactory.php @@ -169,12 +169,6 @@ private static function registerSecurityServices(ContainerBuilder $container, ar $container->register(TokenStorageInterface::class, TokenStorage::class) ->setPublic(true); - /* - $authenticationManager = $container->register( - AuthenticationManagerInterface::class, - AuthenticationProviderManager::class - ); - */ $authenticationManager = $container->register( AuthenticationTrustResolverInterface::class, AuthenticationTrustResolver::class @@ -184,7 +178,7 @@ private static function registerSecurityServices(ContainerBuilder $container, ar $container->register(AccessDecisionManagerInterface::class, AccessDecisionManager::class) ->addArgument(static::normalizedVoters($config[static::AUTH_VOTERS])) - // ->addArgument(AccessDecisionManager::STRATEGY_AFFIRMATIVE) + ->addArgument(AccessDecisionManager::STRATEGY_AFFIRMATIVE) ->addArgument(false); static::autoRegisterClass($container, SecurityFacade::class) @@ -273,22 +267,6 @@ private static function autoRegisterClass(ContainerBuilder $container, $classNam $constructor = $reflectionClass->getConstructor(); $definition = $container->register($className, $className); - /* - if (!$constructor) { - var_dump($className); - exit; - } - */ - - if (!$constructor) { - // $reflectionClass = $reflectionClass->gettype(); - if ($reflectionClass) { - $definition->addArgument($reflectionClass->getName()); - } - - return $definition; - } - foreach ($constructor->getParameters() as $p) { // $reflectionClass = $p->getClass();