From 5bf467ab90b9226d07bad53900d84d33f55acbe4 Mon Sep 17 00:00:00 2001 From: Victor Bocharsky Date: Wed, 22 Nov 2023 20:40:26 +0100 Subject: [PATCH] Allow Symfony 7 --- composer.json | 10 +++---- psalm.xml | 26 +++---------------- .../SymfonyCastsResetPasswordExtension.php | 3 +++ src/Model/ResetPasswordToken.php | 3 +++ .../ResetPasswordTestFixtureRequest.php | 8 ++++++ .../Entity/ResetPasswordTestFixtureUser.php | 4 +++ tests/ResetPasswordTestKernel.php | 7 ++++- 7 files changed, 33 insertions(+), 28 deletions(-) diff --git a/composer.json b/composer.json index 04f3d554..9ecd0dc2 100644 --- a/composer.json +++ b/composer.json @@ -7,15 +7,15 @@ "require": { "php": ">=7.2.5", "ext-json": "*", - "symfony/config": "^5.4 | ^6.0", - "symfony/dependency-injection": "^5.4 | ^6.0", + "symfony/config": "^5.4 | ^6.0 | ^7.0", + "symfony/dependency-injection": "^5.4 | ^6.0 | ^7.0", "symfony/deprecation-contracts": "^2.2 | ^3.0", - "symfony/http-kernel": "^5.4 | ^6.0" + "symfony/http-kernel": "^5.4 | ^6.0 | ^7.0" }, "require-dev": { "doctrine/orm": "^2.7", - "symfony/framework-bundle": "^5.4 | ^6.0", - "symfony/phpunit-bridge": "^5.4 | ^6.0", + "symfony/framework-bundle": "^5.4 | ^6.0 | ^7.0", + "symfony/phpunit-bridge": "^5.4 | ^6.0 | ^7.0", "doctrine/doctrine-bundle": "^2.0.3", "doctrine/annotations": "^1.0" }, diff --git a/psalm.xml b/psalm.xml index 812a1b3e..c8a05478 100644 --- a/psalm.xml +++ b/psalm.xml @@ -51,30 +51,12 @@ - - - - - - + + + - - - - - - - - - - - - - - - - + diff --git a/src/DependencyInjection/SymfonyCastsResetPasswordExtension.php b/src/DependencyInjection/SymfonyCastsResetPasswordExtension.php index 27adeb17..34c86c79 100644 --- a/src/DependencyInjection/SymfonyCastsResetPasswordExtension.php +++ b/src/DependencyInjection/SymfonyCastsResetPasswordExtension.php @@ -27,6 +27,9 @@ public function load(array $configs, ContainerBuilder $container): void $loader->load('reset_password_services.xml'); $configuration = $this->getConfiguration($configs, $container); + if (!$configuration) { + throw new \Exception('Configuration is not expected to be null'); + } $config = $this->processConfiguration($configuration, $configs); diff --git a/src/Model/ResetPasswordToken.php b/src/Model/ResetPasswordToken.php index 46f67674..ad87b0cf 100644 --- a/src/Model/ResetPasswordToken.php +++ b/src/Model/ResetPasswordToken.php @@ -143,6 +143,9 @@ public function getExpiresAtIntervalInstance(): \DateInterval return $this->expiresAt->diff($createdAtTime); } + /** + * @psalm-suppress UndefinedFunction + */ private function triggerDeprecation(): void { trigger_deprecation( diff --git a/tests/Fixtures/Entity/ResetPasswordTestFixtureRequest.php b/tests/Fixtures/Entity/ResetPasswordTestFixtureRequest.php index 328aae7a..4149d97c 100644 --- a/tests/Fixtures/Entity/ResetPasswordTestFixtureRequest.php +++ b/tests/Fixtures/Entity/ResetPasswordTestFixtureRequest.php @@ -20,6 +20,7 @@ * * @ORM\Entity(repositoryClass="SymfonyCasts\Bundle\ResetPassword\Tests\Fixtures\ResetPasswordTestFixtureRequestRepository") */ +#[ORM\Entity(repositoryClass: "SymfonyCasts\Bundle\ResetPassword\Tests\Fixtures\ResetPasswordTestFixtureRequestRepository")] final class ResetPasswordTestFixtureRequest implements ResetPasswordRequestInterface { /** @@ -29,26 +30,33 @@ final class ResetPasswordTestFixtureRequest implements ResetPasswordRequestInter * * @ORM\Column(type="integer") */ + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: 'integer')] public $id; /** * @ORM\Column(type="string", nullable=true) */ + #[ORM\Column(type: 'string', nullable: true)] public $selector; /** * @ORM\Column(type="datetime_immutable", nullable=true) */ + #[ORM\Column(type: 'datetime_immutable', nullable: true)] public $expiresAt; /** * @ORM\Column(type="datetime_immutable", nullable=true) */ + #[ORM\Column(type: 'datetime_immutable', nullable: true)] public $requestedAt; /** * @ORM\ManyToOne(targetEntity="ResetPasswordTestFixtureUser") */ + #[ORM\ManyToOne(targetEntity: 'ResetPasswordTestFixtureUser')] public $user; public function getRequestedAt(): \DateTimeInterface diff --git a/tests/Fixtures/Entity/ResetPasswordTestFixtureUser.php b/tests/Fixtures/Entity/ResetPasswordTestFixtureUser.php index 52079c5d..19da7fa3 100644 --- a/tests/Fixtures/Entity/ResetPasswordTestFixtureUser.php +++ b/tests/Fixtures/Entity/ResetPasswordTestFixtureUser.php @@ -19,6 +19,7 @@ * * @ORM\Entity() */ +#[ORM\Entity] final class ResetPasswordTestFixtureUser { /** @@ -28,5 +29,8 @@ final class ResetPasswordTestFixtureUser * * @ORM\Column(type="integer") */ + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: 'integer')] private $id; } diff --git a/tests/ResetPasswordTestKernel.php b/tests/ResetPasswordTestKernel.php index eca3dd08..1e99786f 100644 --- a/tests/ResetPasswordTestKernel.php +++ b/tests/ResetPasswordTestKernel.php @@ -91,7 +91,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void 'mappings' => [ 'App' => [ 'is_bundle' => false, - 'type' => 'annotation', + 'type' => self::shouldUseAttributes() ? 'attribute' : 'annotation', 'dir' => 'tests/Fixtures/Entity/', 'prefix' => 'SymfonyCasts\Bundle\ResetPassword\Tests\Fixtures\Entity', 'alias' => 'App', @@ -141,4 +141,9 @@ public function getLogDir(): string { return sys_get_temp_dir().'/logs'.spl_object_hash($this); } + + public static function shouldUseAttributes(): bool + { + return Kernel::VERSION_ID >= 70000; + } }