From c39d17e0e0ed88d232cc55d6d118e8f558e42a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20Eugon=C3=A9?= Date: Tue, 31 May 2022 10:46:18 +0200 Subject: [PATCH] Compatibility with Symfony 6.x (#49) * Compatibility with Symfony 6.x * Updated phpstan to avoid parsing issues and fix most new errors --- .github/workflows/tests.yml | 16 +++++++------ composer.json | 6 ++--- phpstan-baseline.neon | 35 +++++++++++++++++++++++++++++ src/Entity/Token.php | 2 +- src/Manager/DoctrineUserManager.php | 4 +++- 5 files changed, 51 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5cd3983..e453db3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,12 +16,14 @@ jobs: include: - php-version: 7.4 symfony-version: 4.4.* - - php-version: 8.0 + - php-version: 8.1 symfony-version: 4.4.* - php-version: 7.4 - symfony-version: 5.3.* - - php-version: 8.0 - symfony-version: 5.3.* + symfony-version: 5.4.* + - php-version: 8.1 + symfony-version: 5.4.* + - php-version: 8.1 + symfony-version: 6.1.* steps: - name: "Checkout" @@ -48,7 +50,7 @@ jobs: strategy: matrix: include: - - php-version: 8.0 + - php-version: 8.1 steps: - name: "Checkout" @@ -73,7 +75,7 @@ jobs: strategy: matrix: include: - - php-version: 8.0 + - php-version: 8.1 steps: - name: "Checkout" @@ -98,7 +100,7 @@ jobs: strategy: matrix: include: - - php-version: 8.0 + - php-version: 8.1 steps: - name: "Checkout" diff --git a/composer.json b/composer.json index 4c7ff1d..ca8d761 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "require": { "php": "^7.4|^8.0", "ext-openssl": "*", - "symfony/framework-bundle": "^4.4|^5.0", + "symfony/framework-bundle": "^4.4|^5.0|^6.0", "doctrine/orm": "^2.7", "doctrine/doctrine-bundle": "^2.0", "yokai/dependency-injection": "^1.0" @@ -19,8 +19,8 @@ "require-dev": { "phpunit/phpunit": "^9.5", "phpspec/prophecy-phpunit": "^2.0", - "symfony/yaml": "^4.4|^5.2", - "phpstan/phpstan": "^0.12", + "symfony/yaml": "^4.4|^5.2|^6.0", + "phpstan/phpstan": "^1.7", "squizlabs/php_codesniffer": "^3.6" }, "autoload": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9d48677..d1cff5a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -15,3 +15,38 @@ parameters: count: 1 path: src/DependencyInjection/Configuration.php + - + message: "#^Method Yokai\\\\SecurityTokenBundle\\\\Entity\\\\Token\\:\\:getLastUsage\\(\\) should return Yokai\\\\SecurityTokenBundle\\\\Entity\\\\TokenUsage\\|null but returns mixed\\.$#" + count: 1 + path: src/Entity/Token.php + + - + message: "#^Method Yokai\\\\SecurityTokenBundle\\\\Entity\\\\Token\\:\\:getUsages\\(\\) should return array\\ but returns array\\.$#" + count: 1 + path: src/Entity/Token.php + + - + message: "#^Property Yokai\\\\SecurityTokenBundle\\\\Entity\\\\Token\\:\\:\\$id is never written, only read\\.$#" + count: 1 + path: src/Entity/Token.php + + - + message: "#^Property Yokai\\\\SecurityTokenBundle\\\\Entity\\\\TokenUsage\\:\\:\\$id is never written, only read\\.$#" + count: 1 + path: src/Entity/TokenUsage.php + + - + message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpFoundation\\\\RequestStack\\:\\:getMasterRequest\\(\\)\\.$#" + count: 1 + path: src/InformationGuesser/InformationGuesser.php + + - + message: "#^Cannot cast mixed to string\\.$#" + count: 1 + path: src/Manager/ChainUserManager.php + + - + message: "#^Cannot cast mixed to string\\.$#" + count: 1 + path: src/Manager/DoctrineUserManager.php + diff --git a/src/Entity/Token.php b/src/Entity/Token.php index 00545ca..02bce12 100644 --- a/src/Entity/Token.php +++ b/src/Entity/Token.php @@ -70,7 +70,7 @@ class Token private $keepUntil; /** - * @var Collection|TokenUsage[] + * @var Collection */ private $usages; diff --git a/src/Manager/DoctrineUserManager.php b/src/Manager/DoctrineUserManager.php index 01b95b3..8fd60ee 100644 --- a/src/Manager/DoctrineUserManager.php +++ b/src/Manager/DoctrineUserManager.php @@ -77,6 +77,8 @@ public function getClass($user): string */ public function getId($user): string { + /** @var object $user */ + /** @var class-string $class */ $class = $this->getClass($user); $identifiers = $this->getManagerFor($class)->getClassMetadata($class)->getIdentifierValues($user); @@ -90,7 +92,7 @@ public function getId($user): string /** * Get doctrine object manager for a class. * - * @param string $class The user class + * @param class-string $class The user class * * @return ObjectManager */