From e3c3e65337939f01cc88431a7a6ed1f11e9a14f2 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 28 Nov 2025 07:52:12 +0100 Subject: [PATCH] Use the new Symfony 7.4 features --- composer.lock | 137 ++++++++++++++++++------------------- src/Entity/Tag.php | 2 +- src/Security/PostVoter.php | 13 +++- 3 files changed, 81 insertions(+), 71 deletions(-) diff --git a/composer.lock b/composer.lock index 47e0ff995..151361bb7 100644 --- a/composer.lock +++ b/composer.lock @@ -246,16 +246,16 @@ }, { "name": "doctrine/dbal", - "version": "4.3.4", + "version": "4.4.1", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "1a2fbd0e93b8dec7c3d1ac2b6396a7b929b130dc" + "reference": "3d544473fb93f5c25b483ea4f4ce99f8c4d9d44c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/1a2fbd0e93b8dec7c3d1ac2b6396a7b929b130dc", - "reference": "1a2fbd0e93b8dec7c3d1ac2b6396a7b929b130dc", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/3d544473fb93f5c25b483ea4f4ce99f8c4d9d44c", + "reference": "3d544473fb93f5c25b483ea4f4ce99f8c4d9d44c", "shasum": "" }, "require": { @@ -274,8 +274,8 @@ "phpunit/phpunit": "11.5.23", "slevomat/coding-standard": "8.24.0", "squizlabs/php_codesniffer": "4.0.0", - "symfony/cache": "^6.3.8|^7.0", - "symfony/console": "^5.4|^6.3|^7.0" + "symfony/cache": "^6.3.8|^7.0|^8.0", + "symfony/console": "^5.4|^6.3|^7.0|^8.0" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -332,7 +332,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/4.3.4" + "source": "https://github.com/doctrine/dbal/tree/4.4.1" }, "funding": [ { @@ -348,7 +348,7 @@ "type": "tidelift" } ], - "time": "2025-10-09T09:11:36+00:00" + "time": "2025-12-04T10:11:03+00:00" }, { "name": "doctrine/deprecations", @@ -1037,16 +1037,16 @@ }, { "name": "doctrine/orm", - "version": "3.5.7", + "version": "3.5.8", "source": { "type": "git", "url": "https://github.com/doctrine/orm.git", - "reference": "f18de9d569f00ed6eb9dac4b33c7844d705d17da" + "reference": "78dd074266e8b47a83bcf60ab5fe06c91a639168" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/orm/zipball/f18de9d569f00ed6eb9dac4b33c7844d705d17da", - "reference": "f18de9d569f00ed6eb9dac4b33c7844d705d17da", + "url": "https://api.github.com/repos/doctrine/orm/zipball/78dd074266e8b47a83bcf60ab5fe06c91a639168", + "reference": "78dd074266e8b47a83bcf60ab5fe06c91a639168", "shasum": "" }, "require": { @@ -1062,19 +1062,18 @@ "ext-ctype": "*", "php": "^8.1", "psr/cache": "^1 || ^2 || ^3", - "symfony/console": "^5.4 || ^6.0 || ^7.0", - "symfony/var-exporter": "^6.3.9 || ^7.0" + "symfony/console": "^5.4 || ^6.0 || ^7.0 || ^8.0", + "symfony/var-exporter": "^6.3.9 || ^7.0 || ^8.0" }, "require-dev": { "doctrine/coding-standard": "^14.0", "phpbench/phpbench": "^1.0", - "phpdocumentor/guides-cli": "^1.4", "phpstan/extension-installer": "^1.4", "phpstan/phpstan": "2.1.23", "phpstan/phpstan-deprecation-rules": "^2", "phpunit/phpunit": "^10.5.0 || ^11.5", "psr/log": "^1 || ^2 || ^3", - "symfony/cache": "^5.4 || ^6.2 || ^7.0" + "symfony/cache": "^5.4 || ^6.2 || ^7.0 || ^8.0" }, "suggest": { "ext-dom": "Provides support for XSD validation for XML mapping files", @@ -1120,9 +1119,9 @@ ], "support": { "issues": "https://github.com/doctrine/orm/issues", - "source": "https://github.com/doctrine/orm/tree/3.5.7" + "source": "https://github.com/doctrine/orm/tree/3.5.8" }, - "time": "2025-11-11T18:27:40+00:00" + "time": "2025-11-29T23:11:02+00:00" }, { "name": "doctrine/persistence", @@ -1947,20 +1946,20 @@ }, { "name": "nette/utils", - "version": "v4.0.9", + "version": "v4.1.0", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "505a30ad386daa5211f08a318e47015b501cad30" + "reference": "fa1f0b8261ed150447979eb22e373b7b7ad5a8e0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/505a30ad386daa5211f08a318e47015b501cad30", - "reference": "505a30ad386daa5211f08a318e47015b501cad30", + "url": "https://api.github.com/repos/nette/utils/zipball/fa1f0b8261ed150447979eb22e373b7b7ad5a8e0", + "reference": "fa1f0b8261ed150447979eb22e373b7b7ad5a8e0", "shasum": "" }, "require": { - "php": "8.0 - 8.5" + "php": "8.2 - 8.5" }, "conflict": { "nette/finder": "<3", @@ -1983,7 +1982,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "4.1-dev" } }, "autoload": { @@ -2030,9 +2029,9 @@ ], "support": { "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v4.0.9" + "source": "https://github.com/nette/utils/tree/v4.1.0" }, - "time": "2025-10-31T00:45:47+00:00" + "time": "2025-12-01T17:49:23+00:00" }, { "name": "psr/cache", @@ -8420,16 +8419,16 @@ }, { "name": "twig/twig", - "version": "v3.22.0", + "version": "v3.22.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "4509984193026de413baf4ba80f68590a7f2c51d" + "reference": "1de2ec1fc43ab58a4b7e80b214b96bfc895750f3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/4509984193026de413baf4ba80f68590a7f2c51d", - "reference": "4509984193026de413baf4ba80f68590a7f2c51d", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/1de2ec1fc43ab58a4b7e80b214b96bfc895750f3", + "reference": "1de2ec1fc43ab58a4b7e80b214b96bfc895750f3", "shasum": "" }, "require": { @@ -8483,7 +8482,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.22.0" + "source": "https://github.com/twigphp/Twig/tree/v3.22.1" }, "funding": [ { @@ -8495,7 +8494,7 @@ "type": "tidelift" } ], - "time": "2025-10-29T15:56:47+00:00" + "time": "2025-11-16T16:01:12+00:00" } ], "packages-dev": [ @@ -8653,16 +8652,16 @@ }, { "name": "doctrine/doctrine-fixtures-bundle", - "version": "4.3.0", + "version": "4.3.1", "source": { "type": "git", "url": "https://github.com/doctrine/DoctrineFixturesBundle.git", - "reference": "11941deb6f2899b91e8b8680b07ffe63899d864b" + "reference": "9e013ed10d49bf7746b07204d336384a7d9b5a4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/DoctrineFixturesBundle/zipball/11941deb6f2899b91e8b8680b07ffe63899d864b", - "reference": "11941deb6f2899b91e8b8680b07ffe63899d864b", + "url": "https://api.github.com/repos/doctrine/DoctrineFixturesBundle/zipball/9e013ed10d49bf7746b07204d336384a7d9b5a4d", + "reference": "9e013ed10d49bf7746b07204d336384a7d9b5a4d", "shasum": "" }, "require": { @@ -8672,12 +8671,12 @@ "doctrine/persistence": "^2.4 || ^3.0 || ^4.0", "php": "^8.1", "psr/log": "^2 || ^3", - "symfony/config": "^6.4 || ^7.0", - "symfony/console": "^6.4 || ^7.0", - "symfony/dependency-injection": "^6.4 || ^7.0", + "symfony/config": "^6.4 || ^7.0 || ^8.0", + "symfony/console": "^6.4 || ^7.0 || ^8.0", + "symfony/dependency-injection": "^6.4 || ^7.0 || ^8.0", "symfony/deprecation-contracts": "^2.1 || ^3", - "symfony/doctrine-bridge": "^6.4.16 || ^7.1.9", - "symfony/http-kernel": "^6.4 || ^7.0" + "symfony/doctrine-bridge": "^6.4.16 || ^7.1.9 || ^8.0", + "symfony/http-kernel": "^6.4 || ^7.0 || ^8.0" }, "conflict": { "doctrine/dbal": "< 3" @@ -8719,7 +8718,7 @@ ], "support": { "issues": "https://github.com/doctrine/DoctrineFixturesBundle/issues", - "source": "https://github.com/doctrine/DoctrineFixturesBundle/tree/4.3.0" + "source": "https://github.com/doctrine/DoctrineFixturesBundle/tree/4.3.1" }, "funding": [ { @@ -8735,7 +8734,7 @@ "type": "tidelift" } ], - "time": "2025-10-20T06:18:40+00:00" + "time": "2025-12-03T16:05:42+00:00" }, { "name": "myclabs/deep-copy", @@ -9028,16 +9027,16 @@ }, { "name": "phpstan/phpstan-doctrine", - "version": "2.0.11", + "version": "2.0.12", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-doctrine.git", - "reference": "368ad1c713a6d95763890bc2292694a603ece7c8" + "reference": "d20ee0373d22735271f1eb4d631856b5f847d399" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/368ad1c713a6d95763890bc2292694a603ece7c8", - "reference": "368ad1c713a6d95763890bc2292694a603ece7c8", + "url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/d20ee0373d22735271f1eb4d631856b5f847d399", + "reference": "d20ee0373d22735271f1eb4d631856b5f847d399", "shasum": "" }, "require": { @@ -9095,22 +9094,22 @@ "description": "Doctrine extensions for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-doctrine/issues", - "source": "https://github.com/phpstan/phpstan-doctrine/tree/2.0.11" + "source": "https://github.com/phpstan/phpstan-doctrine/tree/2.0.12" }, - "time": "2025-11-04T09:55:35+00:00" + "time": "2025-12-01T11:34:02+00:00" }, { "name": "phpstan/phpstan-symfony", - "version": "2.0.8", + "version": "2.0.9", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-symfony.git", - "reference": "8820c22d785c235f69bb48da3d41e688bc8a1796" + "reference": "24d8c157aa483141b0579d705ef0aac9e1b95436" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/8820c22d785c235f69bb48da3d41e688bc8a1796", - "reference": "8820c22d785c235f69bb48da3d41e688bc8a1796", + "url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/24d8c157aa483141b0579d705ef0aac9e1b95436", + "reference": "24d8c157aa483141b0579d705ef0aac9e1b95436", "shasum": "" }, "require": { @@ -9123,7 +9122,7 @@ }, "require-dev": { "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-phpunit": "^2.0.8", "phpstan/phpstan-strict-rules": "^2.0", "phpunit/phpunit": "^9.6", "psr/container": "1.1.2", @@ -9166,9 +9165,9 @@ "description": "Symfony Framework extensions and rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-symfony/issues", - "source": "https://github.com/phpstan/phpstan-symfony/tree/2.0.8" + "source": "https://github.com/phpstan/phpstan-symfony/tree/2.0.9" }, - "time": "2025-09-07T06:55:50+00:00" + "time": "2025-11-29T11:17:28+00:00" }, { "name": "phpunit/php-code-coverage", @@ -9507,16 +9506,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.5.44", + "version": "11.5.45", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c346885c95423eda3f65d85a194aaa24873cda82" + "reference": "faf5fff4fb9beb290affa53f812b05380819c51a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c346885c95423eda3f65d85a194aaa24873cda82", - "reference": "c346885c95423eda3f65d85a194aaa24873cda82", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/faf5fff4fb9beb290affa53f812b05380819c51a", + "reference": "faf5fff4fb9beb290affa53f812b05380819c51a", "shasum": "" }, "require": { @@ -9588,7 +9587,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.44" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.45" }, "funding": [ { @@ -9612,7 +9611,7 @@ "type": "tidelift" } ], - "time": "2025-11-13T07:17:35+00:00" + "time": "2025-12-01T07:38:43+00:00" }, { "name": "sebastian/cli-parser", @@ -10943,16 +10942,16 @@ }, { "name": "symfony/maker-bundle", - "version": "v1.65.0", + "version": "v1.65.1", "source": { "type": "git", "url": "https://github.com/symfony/maker-bundle.git", - "reference": "9a0276d7486b29cae641b4a0a85d5e5cc149bff2" + "reference": "eba30452d212769c9a5bcf0716959fd8ba1e54e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/maker-bundle/zipball/9a0276d7486b29cae641b4a0a85d5e5cc149bff2", - "reference": "9a0276d7486b29cae641b4a0a85d5e5cc149bff2", + "url": "https://api.github.com/repos/symfony/maker-bundle/zipball/eba30452d212769c9a5bcf0716959fd8ba1e54e3", + "reference": "eba30452d212769c9a5bcf0716959fd8ba1e54e3", "shasum": "" }, "require": { @@ -11017,7 +11016,7 @@ ], "support": { "issues": "https://github.com/symfony/maker-bundle/issues", - "source": "https://github.com/symfony/maker-bundle/tree/v1.65.0" + "source": "https://github.com/symfony/maker-bundle/tree/v1.65.1" }, "funding": [ { @@ -11037,7 +11036,7 @@ "type": "tidelift" } ], - "time": "2025-11-24T15:41:51+00:00" + "time": "2025-12-02T07:14:37+00:00" }, { "name": "symfony/web-profiler-bundle", @@ -11195,5 +11194,5 @@ "platform-overrides": { "php": "8.2.0" }, - "plugin-api-version": "2.9.0" + "plugin-api-version": "2.6.0" } diff --git a/src/Entity/Tag.php b/src/Entity/Tag.php index 0979290f4..d587f6a52 100644 --- a/src/Entity/Tag.php +++ b/src/Entity/Tag.php @@ -23,7 +23,7 @@ */ #[ORM\Entity] #[ORM\Table(name: 'symfony_demo_tag')] -class Tag implements \JsonSerializable +class Tag implements \Stringable, \JsonSerializable { #[ORM\Id] #[ORM\GeneratedValue] diff --git a/src/Security/PostVoter.php b/src/Security/PostVoter.php index 5df5c3472..3d463de77 100644 --- a/src/Security/PostVoter.php +++ b/src/Security/PostVoter.php @@ -50,12 +50,23 @@ protected function voteOnAttribute(string $attribute, $post, TokenInterface $tok // the user must be logged in; if not, deny permission if (!$user instanceof User) { + // votes can include explanations about the decisions. These can be: + // * internal: not shown to the end user, but useful for logging or debugging (you can include technical details) + // * public: (as in this case) meant to be shown to the end user (make sure to not include sensitive information) + $vote?->addReason(\sprintf('There is no user logged in, so it\'s not possible to %s the blog post.', $attribute)); + return false; } // the logic of this voter is pretty simple: if the logged-in user is the // author of the given blog post, grant permission; otherwise, deny it. // (the supports() method guarantees that $post is a Post object) - return $user === $post->getAuthor(); + if ($user === $post->getAuthor()) { + return true; + } + + $vote?->addReason(\sprintf('You can\'t %s this blog post because you are not its author.', $attribute)); + + return false; } }