From 32c9fce792a5ae2dc0455fc79fec2de07032ca60 Mon Sep 17 00:00:00 2001 From: Lung Date: Sat, 9 Sep 2023 12:26:13 +0200 Subject: [PATCH] updated php-di to v7 by changing annotations to attributes --- composer.json | 1 - composer.lock | 119 +++++++++----------------- src/AbstractController.php | 23 ++--- src/Application/ApplicationGetter.php | 2 +- src/User/UserController.php | 2 +- 5 files changed, 48 insertions(+), 99 deletions(-) diff --git a/composer.json b/composer.json index 232d4e37..a2e3c0e3 100755 --- a/composer.json +++ b/composer.json @@ -38,7 +38,6 @@ "middlewares/negotiation": "^2.0", "middlewares/trailing-slash": "^2.0", "monolog/monolog": "^1.25", - "php-di/php-di": "^6.0", "php-di/slim-bridge": "^3", "phpmailer/phpmailer": "^6.0", "robmorgan/phinx": "^0.12.5", diff --git a/composer.lock b/composer.lock index b5e54dad..539f714e 100755 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cbd69e50b6dcc5a09a05a69f8b823ee9", + "content-hash": "13b370ec842eeca506abd9a28544bf97", "packages": [ { "name": "aws/aws-crt-php", @@ -2423,39 +2423,36 @@ }, { "name": "php-di/php-di", - "version": "6.4.0", + "version": "7.0.5", "source": { "type": "git", "url": "https://github.com/PHP-DI/PHP-DI.git", - "reference": "ae0f1b3b03d8b29dff81747063cbfd6276246cc4" + "reference": "9ea40a5a6970bf1ca5cbe148bc16cbad6ca3db6c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-DI/PHP-DI/zipball/ae0f1b3b03d8b29dff81747063cbfd6276246cc4", - "reference": "ae0f1b3b03d8b29dff81747063cbfd6276246cc4", + "url": "https://api.github.com/repos/PHP-DI/PHP-DI/zipball/9ea40a5a6970bf1ca5cbe148bc16cbad6ca3db6c", + "reference": "9ea40a5a6970bf1ca5cbe148bc16cbad6ca3db6c", "shasum": "" }, "require": { "laravel/serializable-closure": "^1.0", - "php": ">=7.4.0", + "php": ">=8.0", "php-di/invoker": "^2.0", - "php-di/phpdoc-reader": "^2.0.1", - "psr/container": "^1.0" + "psr/container": "^1.1 || ^2.0" }, "provide": { "psr/container-implementation": "^1.0" }, "require-dev": { - "doctrine/annotations": "~1.10", - "friendsofphp/php-cs-fixer": "^2.4", - "mnapoli/phpunit-easymock": "^1.2", - "ocramius/proxy-manager": "^2.11.2", - "phpstan/phpstan": "^0.12", - "phpunit/phpunit": "^9.5" + "friendsofphp/php-cs-fixer": "^3", + "friendsofphp/proxy-manager-lts": "^1", + "mnapoli/phpunit-easymock": "^1.3", + "phpunit/phpunit": "^9.5", + "vimeo/psalm": "^4.6" }, "suggest": { - "doctrine/annotations": "Install it if you want to use annotations (version ~1.2)", - "ocramius/proxy-manager": "Install it if you want to use lazy injection (version ~2.0)" + "friendsofphp/proxy-manager-lts": "Install it if you want to use lazy injection (version ^1)" }, "type": "library", "autoload": { @@ -2483,7 +2480,7 @@ ], "support": { "issues": "https://github.com/PHP-DI/PHP-DI/issues", - "source": "https://github.com/PHP-DI/PHP-DI/tree/6.4.0" + "source": "https://github.com/PHP-DI/PHP-DI/tree/7.0.5" }, "funding": [ { @@ -2495,49 +2492,7 @@ "type": "tidelift" } ], - "time": "2022-04-09T16:46:38+00:00" - }, - { - "name": "php-di/phpdoc-reader", - "version": "2.2.1", - "source": { - "type": "git", - "url": "https://github.com/PHP-DI/PhpDocReader.git", - "reference": "66daff34cbd2627740ffec9469ffbac9f8c8185c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-DI/PhpDocReader/zipball/66daff34cbd2627740ffec9469ffbac9f8c8185c", - "reference": "66daff34cbd2627740ffec9469ffbac9f8c8185c", - "shasum": "" - }, - "require": { - "php": ">=7.2.0" - }, - "require-dev": { - "mnapoli/hard-mode": "~0.3.0", - "phpunit/phpunit": "^8.5|^9.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "PhpDocReader\\": "src/PhpDocReader" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PhpDocReader parses @var and @param values in PHP docblocks (supports namespaced class names with the same resolution rules as PHP)", - "keywords": [ - "phpdoc", - "reflection" - ], - "support": { - "issues": "https://github.com/PHP-DI/PhpDocReader/issues", - "source": "https://github.com/PHP-DI/PhpDocReader/tree/2.2.1" - }, - "time": "2020-10-12T12:39:22+00:00" + "time": "2023-08-10T14:57:56+00:00" }, { "name": "php-di/slim-bridge", @@ -3171,22 +3126,27 @@ }, { "name": "psr/container", - "version": "1.1.2", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", "shasum": "" }, "require": { "php": ">=7.4.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -3213,9 +3173,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" + "source": "https://github.com/php-fig/container/tree/2.0.2" }, - "time": "2021-11-05T16:50:12+00:00" + "time": "2021-11-05T16:47:00+00:00" }, { "name": "psr/event-dispatcher", @@ -5749,33 +5709,29 @@ }, { "name": "symfony/service-contracts", - "version": "v2.5.2", + "version": "v3.3.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c" + "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/4b426aac47d6427cc1a1d0f7e2ac724627f5966c", - "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", + "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", "shasum": "" }, "require": { - "php": ">=7.2.5", - "psr/container": "^1.1", - "symfony/deprecation-contracts": "^2.1|^3" + "php": ">=8.1", + "psr/container": "^2.0" }, "conflict": { "ext-psr": "<1.1|>=2" }, - "suggest": { - "symfony/service-implementation": "" - }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.5-dev" + "dev-main": "3.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -5785,7 +5741,10 @@ "autoload": { "psr-4": { "Symfony\\Contracts\\Service\\": "" - } + }, + "exclude-from-classmap": [ + "/Test/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -5812,7 +5771,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/service-contracts/tree/v3.3.0" }, "funding": [ { @@ -5828,7 +5787,7 @@ "type": "tidelift" } ], - "time": "2022-05-30T19:17:29+00:00" + "time": "2023-05-23T14:45:45+00:00" }, { "name": "symfony/string", diff --git a/src/AbstractController.php b/src/AbstractController.php index 1525202a..7a5e9802 100755 --- a/src/AbstractController.php +++ b/src/AbstractController.php @@ -4,7 +4,7 @@ namespace kissj; -use DI\Annotation\Inject; +use DI\Attribute\Inject; use kissj\Event\Event; use kissj\FileHandler\FileHandler; use kissj\FlashMessages\FlashMessagesBySession; @@ -15,32 +15,23 @@ use Slim\Routing\RouteContext; use Slim\Views\Twig; use Symfony\Contracts\Translation\TranslatorInterface; +use Psr\Log\LoggerInterface; abstract class AbstractController { - /** - * @Inject() - */ + #[Inject] protected FlashMessagesBySession $flashMessages; - /** - * @Inject("Psr\Log\LoggerInterface") - */ + #[Inject(LoggerInterface::class)] protected Logger $logger; - /** - * @Inject() - */ + #[Inject] protected Twig $view; - /** - * @Inject() - */ + #[Inject] protected TranslatorInterface $translator; - /** - * @Inject() - */ + #[Inject] protected FileHandler $fileHandler; /** diff --git a/src/Application/ApplicationGetter.php b/src/Application/ApplicationGetter.php index 3184af2b..23687482 100644 --- a/src/Application/ApplicationGetter.php +++ b/src/Application/ApplicationGetter.php @@ -14,7 +14,7 @@ public function getApp( $envPath, $envFilename, )); - $containerBuilder->useAnnotations(true); // used in AbstractController + $containerBuilder->useAttributes(true); // used in AbstractController if ($_ENV['DEBUG'] === 'false') { // TODO add autowired definitions into container to get more performace // https://php-di.org/doc/performances.html#optimizing-for-compilation diff --git a/src/User/UserController.php b/src/User/UserController.php index 7580a72f..06cd1ca3 100755 --- a/src/User/UserController.php +++ b/src/User/UserController.php @@ -117,7 +117,7 @@ public function getDashboard(User $user, Request $request, Response $response): UserRole::ContingentAdminPl, UserRole::ContingentAdminHu, UserRole::ContingentAdminEu, - UserRole::ContingentAdminRo, + UserRole::ContingentAdminRo => $this->redirect($request, $response, 'admin-dashboard', $routerEventSlug), }; }