From 296e05919f8aed93004402a6f786b6df34c22e43 Mon Sep 17 00:00:00 2001 From: Ronald Appelfelder Date: Mon, 18 Mar 2024 09:59:58 +0100 Subject: [PATCH 1/7] allow php 8.x --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1bb9fd9..d5bf7ac 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ } }, "require": { - "php": "8.0.*|8.1.*", + "php": "^8.0", "jms/serializer-bundle": "~4.0", "symfony/config": "~5.0", "symfony/dependency-injection": "~5.0", From 9d840a7fcf84b3425a7583bf26f3d8525e8d5602 Mon Sep 17 00:00:00 2001 From: Ronald Appelfelder Date: Mon, 18 Mar 2024 10:01:40 +0100 Subject: [PATCH 2/7] support doctrine/annotations 2.x --- tests/bootstrap.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d257f7e..db28202 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -11,4 +11,6 @@ $loader = require __DIR__ . '/../vendor/autoload.php'; -AnnotationRegistry::registerLoader(array($loader, 'loadClass')); +if (method_exists(AnnotationRegistry::class, 'registerLoader')) { + AnnotationRegistry::registerLoader([$loader, 'loadClass']); +} From ed36d74c3635ec23c011f294c8f314d069a7fb79 Mon Sep 17 00:00:00 2001 From: Ronald Appelfelder Date: Mon, 18 Mar 2024 10:06:32 +0100 Subject: [PATCH 3/7] upgrade jms/serializer-bundle to 5.x --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d5bf7ac..7ec35cc 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ }, "require": { "php": "^8.0", - "jms/serializer-bundle": "~4.0", + "jms/serializer-bundle": "^5.4", "symfony/config": "~5.0", "symfony/dependency-injection": "~5.0", "symfony/http-kernel": "~5.0", From 169f6da3bb280df0a09e6ad5fadc9b2e6912d4ca Mon Sep 17 00:00:00 2001 From: Ronald Appelfelder Date: Mon, 18 Mar 2024 10:15:22 +0100 Subject: [PATCH 4/7] drop symfony 5.x support, add symfony 6.4.x support, fix deprecations --- composer.json | 18 +++++++++--------- src/Controller/RouterController.php | 2 +- .../Compiler/AddExtDirectServicePass.php | 2 +- .../Compiler/ValidateSecurityPass.php | 2 +- .../TQExtDirectExtension.php | 2 +- src/Resources/config/extdirect.yml | 3 +++ src/TQExtDirectBundle.php | 2 +- tests/TQExtDirectBundleTest.php | 17 ++++------------- tests/TQExtDirectBundleTestConfig.yml | 10 ++++++++++ 9 files changed, 31 insertions(+), 27 deletions(-) diff --git a/composer.json b/composer.json index 7ec35cc..3dced41 100644 --- a/composer.json +++ b/composer.json @@ -28,20 +28,20 @@ "require": { "php": "^8.0", "jms/serializer-bundle": "^5.4", - "symfony/config": "~5.0", - "symfony/dependency-injection": "~5.0", - "symfony/http-kernel": "~5.0", - "symfony/routing": "~5.0", - "symfony/yaml": "~5.0", + "symfony/config": "6.4.*", + "symfony/dependency-injection": "6.4.*", + "symfony/http-kernel": "6.4.*", + "symfony/routing": "6.4.*", + "symfony/yaml": "6.4.*", "teqneers/ext-direct": "^5.0", "twig/twig": "~3.3" }, "require-dev": { "phpunit/phpunit": "^9.5", - "symfony/framework-bundle": "~5.0", - "symfony/phpunit-bridge": "~5.0", - "symfony/security-bundle": "~5.0", - "symfony/templating": "~5.0" + "symfony/framework-bundle": "6.4.*", + "symfony/phpunit-bridge": "6.4.*", + "symfony/security-bundle": "6.4.*", + "symfony/templating": "6.4.*" }, "extra": { "branch-alias": { diff --git a/src/Controller/RouterController.php b/src/Controller/RouterController.php index d085abc..8ae3378 100644 --- a/src/Controller/RouterController.php +++ b/src/Controller/RouterController.php @@ -44,7 +44,7 @@ public function __construct(EndpointManager $endpointManager) */ public function routerAction($endpoint, Request $request) { - $request->setRequestFormat($request->getContentType()); + $request->setRequestFormat($request->getContentTypeFormat()); if ($request->getMethod() !== Request::METHOD_POST) { throw new MethodNotAllowedHttpException(array(Request::METHOD_POST)); diff --git a/src/DependencyInjection/Compiler/AddExtDirectServicePass.php b/src/DependencyInjection/Compiler/AddExtDirectServicePass.php index 833f211..7d48eaa 100644 --- a/src/DependencyInjection/Compiler/AddExtDirectServicePass.php +++ b/src/DependencyInjection/Compiler/AddExtDirectServicePass.php @@ -21,7 +21,7 @@ class AddExtDirectServicePass implements CompilerPassInterface /** * {@inheritdoc} */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { $tagName = 'tq_extdirect.service'; $defaultEndpoint = $container->getParameter('tq_extdirect.endpoint.default'); diff --git a/src/DependencyInjection/Compiler/ValidateSecurityPass.php b/src/DependencyInjection/Compiler/ValidateSecurityPass.php index 83ca8bb..4277361 100644 --- a/src/DependencyInjection/Compiler/ValidateSecurityPass.php +++ b/src/DependencyInjection/Compiler/ValidateSecurityPass.php @@ -24,7 +24,7 @@ class ValidateSecurityPass implements CompilerPassInterface /** * {@inheritdoc} */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { if (!$container->hasDefinition('tq_extdirect.router.authorization_checker')) { // authorization listener not enabled or expression language not available diff --git a/src/DependencyInjection/TQExtDirectExtension.php b/src/DependencyInjection/TQExtDirectExtension.php index 8b6076d..7dc3ad8 100644 --- a/src/DependencyInjection/TQExtDirectExtension.php +++ b/src/DependencyInjection/TQExtDirectExtension.php @@ -31,7 +31,7 @@ class TQExtDirectExtension extends Extension /** * {@inheritdoc} */ - public function load(array $config, ContainerBuilder $container) + public function load(array $config, ContainerBuilder $container): void { $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('extdirect.yml'); diff --git a/src/Resources/config/extdirect.yml b/src/Resources/config/extdirect.yml index d462b1e..9482ab7 100644 --- a/src/Resources/config/extdirect.yml +++ b/src/Resources/config/extdirect.yml @@ -2,6 +2,9 @@ parameters: tq_extdirect.debug: false services: + Doctrine\Common\Annotations\AnnotationReader: + annotation_reader: '@Doctrine\Common\Annotations\AnnotationReader' + tq_extdirect.ext_direct_api_controller: class: TQ\Bundle\ExtDirectBundle\Controller\ApiController public: true diff --git a/src/TQExtDirectBundle.php b/src/TQExtDirectBundle.php index 6b30f37..952e2b7 100644 --- a/src/TQExtDirectBundle.php +++ b/src/TQExtDirectBundle.php @@ -26,7 +26,7 @@ class TQExtDirectBundle extends Bundle /** * {@inheritdoc} */ - public function build(ContainerBuilder $container) + public function build(ContainerBuilder $container): void { parent::build($container); diff --git a/tests/TQExtDirectBundleTest.php b/tests/TQExtDirectBundleTest.php index a48ed1c..f85148e 100644 --- a/tests/TQExtDirectBundleTest.php +++ b/tests/TQExtDirectBundleTest.php @@ -173,10 +173,7 @@ protected function clearTempDir() class AppKernel extends Kernel { - /** - * @return iterable - */ - public function registerBundles() + public function registerBundles(): \Traversable|array { return array( new FrameworkBundle(), @@ -188,23 +185,17 @@ public function registerBundles() /** * {@inheritdoc} */ - public function registerContainerConfiguration(LoaderInterface $loader) + public function registerContainerConfiguration(LoaderInterface $loader): void { $loader->load(__DIR__ . '/TQExtDirectBundleTestConfig.yml'); } - /** - * @return string - */ - public function getCacheDir() + public function getCacheDir(): string { return sys_get_temp_dir() . '/ext-direct-bundle/cache'; } - /** - * @return string - */ - public function getLogDir() + public function getLogDir(): string { return sys_get_temp_dir() . '/ext-direct-bundle/log'; } diff --git a/tests/TQExtDirectBundleTestConfig.yml b/tests/TQExtDirectBundleTestConfig.yml index 5e18915..4cf59d3 100644 --- a/tests/TQExtDirectBundleTestConfig.yml +++ b/tests/TQExtDirectBundleTestConfig.yml @@ -2,11 +2,21 @@ framework: secret: "Three can keep a secret, if two of them are dead." validation: enabled: true + email_validation_mode: html5 router: resource: "%kernel.project_dir%/tests/TQExtDirectBundleTestRouting.yml" strict_requirements: ~ utf8: true + http_method_override: false + handle_all_throwables: true + + php_errors: + log: true + + annotations: + enabled: false + tq_ext_direct: endpoints: api: From 6224c56afd1f8e11a09c0c1cb96a4344ecc8b271 Mon Sep 17 00:00:00 2001 From: Ronald Appelfelder Date: Mon, 18 Mar 2024 10:17:14 +0100 Subject: [PATCH 5/7] composer.json: add koriym/attributes to require-dev --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 3dced41..665ea92 100644 --- a/composer.json +++ b/composer.json @@ -37,6 +37,7 @@ "twig/twig": "~3.3" }, "require-dev": { + "koriym/attributes": "^1.0", "phpunit/phpunit": "^9.5", "symfony/framework-bundle": "6.4.*", "symfony/phpunit-bridge": "6.4.*", From 1d85fca4339aae3f373eb4c335c738990db79d1a Mon Sep 17 00:00:00 2001 From: Ronald Appelfelder Date: Mon, 18 Mar 2024 10:17:51 +0100 Subject: [PATCH 6/7] add attributes to test services --- tests/Services/Service1.php | 8 ++++---- tests/Services/Sub/Service1.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/Services/Service1.php b/tests/Services/Service1.php index b815115..00d4c1a 100644 --- a/tests/Services/Service1.php +++ b/tests/Services/Service1.php @@ -18,16 +18,16 @@ * * @Direct\Action() */ +#[Direct\Action()] class Service1 { /** * @Direct\Method() * @Direct\Parameter("a", { @Assert\NotNull(), @Assert\Type("string") }) - * - * @param string $a - * @return string */ - public function methodA($a) + #[Direct\Method()] + #[Direct\Parameter("a", [ new Assert\NotNull(), new Assert\Type("string") ])] + public function methodA(string $a): string { return $a; } diff --git a/tests/Services/Sub/Service1.php b/tests/Services/Sub/Service1.php index 051792f..6030356 100644 --- a/tests/Services/Sub/Service1.php +++ b/tests/Services/Sub/Service1.php @@ -18,16 +18,16 @@ * * @Direct\Action("app.direct.test1") */ +#[Direct\Action("app.direct.test1")] class Service1 { /** * @Direct\Method() * @Direct\Parameter("a", { @Assert\NotNull(), @Assert\Type("string") }) - * - * @param string $a - * @return string */ - public function methodA($a) + #[Direct\Method()] + #[Direct\Parameter("a", [ new Assert\NotNull(), new Assert\Type("string") ])] + public function methodA(string $a): string { return $a; } From 03a0547934ae57def48ec91dff4b222d24ecfa57 Mon Sep 17 00:00:00 2001 From: Ronald Appelfelder Date: Mon, 18 Mar 2024 12:46:48 +0100 Subject: [PATCH 7/7] move AnnotationReader config into test config --- src/Resources/config/extdirect.yml | 3 --- tests/TQExtDirectBundleTestConfig.yml | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Resources/config/extdirect.yml b/src/Resources/config/extdirect.yml index 9482ab7..d462b1e 100644 --- a/src/Resources/config/extdirect.yml +++ b/src/Resources/config/extdirect.yml @@ -2,9 +2,6 @@ parameters: tq_extdirect.debug: false services: - Doctrine\Common\Annotations\AnnotationReader: - annotation_reader: '@Doctrine\Common\Annotations\AnnotationReader' - tq_extdirect.ext_direct_api_controller: class: TQ\Bundle\ExtDirectBundle\Controller\ApiController public: true diff --git a/tests/TQExtDirectBundleTestConfig.yml b/tests/TQExtDirectBundleTestConfig.yml index 4cf59d3..0cf33ff 100644 --- a/tests/TQExtDirectBundleTestConfig.yml +++ b/tests/TQExtDirectBundleTestConfig.yml @@ -30,3 +30,6 @@ services: class: TQ\Bundle\ExtDirectBundle\Tests\Services\Service1 tags: - { name: tq_extdirect.service, endpoint: api } + + Doctrine\Common\Annotations\AnnotationReader: + annotation_reader: '@Doctrine\Common\Annotations\AnnotationReader'