Skip to content

Commit 2b42822

Browse files
committed
feature #274 Allow Symfony 7 (bocharsky-bw)
This PR was squashed before being merged into the main branch. Discussion ---------- Allow Symfony 7 Commits ------- 5bf467a Allow Symfony 7
2 parents 9906ceb + 5bf467a commit 2b42822

File tree

7 files changed

+33
-28
lines changed

7 files changed

+33
-28
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
"require": {
88
"php": ">=7.2.5",
99
"ext-json": "*",
10-
"symfony/config": "^5.4 | ^6.0",
11-
"symfony/dependency-injection": "^5.4 | ^6.0",
10+
"symfony/config": "^5.4 | ^6.0 | ^7.0",
11+
"symfony/dependency-injection": "^5.4 | ^6.0 | ^7.0",
1212
"symfony/deprecation-contracts": "^2.2 | ^3.0",
13-
"symfony/http-kernel": "^5.4 | ^6.0"
13+
"symfony/http-kernel": "^5.4 | ^6.0 | ^7.0"
1414
},
1515
"require-dev": {
1616
"doctrine/orm": "^2.7",
17-
"symfony/framework-bundle": "^5.4 | ^6.0",
18-
"symfony/phpunit-bridge": "^5.4 | ^6.0",
17+
"symfony/framework-bundle": "^5.4 | ^6.0 | ^7.0",
18+
"symfony/phpunit-bridge": "^5.4 | ^6.0 | ^7.0",
1919
"doctrine/doctrine-bundle": "^2.0.3",
2020
"doctrine/annotations": "^1.0"
2121
},

psalm.xml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,12 @@
5151
<RawObjectIteration errorLevel="info"/>
5252

5353
<InvalidStringClass errorLevel="info"/>
54-
<PossiblyUndefinedMethod>
55-
<errorLevel type="suppress">
56-
<file name="src/DependencyInjection/Configuration.php"/>
57-
</errorLevel>
58-
</PossiblyUndefinedMethod>
59-
<PossiblyNullReference>
54+
55+
<UndefinedInterfaceMethod>
6056
<errorLevel type="suppress">
6157
<file name="src/DependencyInjection/Configuration.php"/>
58+
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeParentInterface::integerNode" />
6259
</errorLevel>
63-
</PossiblyNullReference>
64-
<PossiblyNullArgument>
65-
<errorLevel type="suppress">
66-
<file name="src/DependencyInjection/SymfonyCastsResetPasswordExtension.php"/>
67-
</errorLevel>
68-
</PossiblyNullArgument>
69-
<InvalidReturnType>
70-
<errorLevel type="suppress">
71-
<file name="src/Persistence/Fake/FakeResetPasswordInternalRepository.php"/>
72-
</errorLevel>
73-
</InvalidReturnType>
74-
<TooManyArguments>
75-
<errorLevel type="suppress">
76-
<file name="src/Model/ResetPasswordToken.php"/>
77-
</errorLevel>
78-
</TooManyArguments>
60+
</UndefinedInterfaceMethod>
7961
</issueHandlers>
8062
</psalm>

src/DependencyInjection/SymfonyCastsResetPasswordExtension.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public function load(array $configs, ContainerBuilder $container): void
2727
$loader->load('reset_password_services.xml');
2828

2929
$configuration = $this->getConfiguration($configs, $container);
30+
if (!$configuration) {
31+
throw new \Exception('Configuration is not expected to be null');
32+
}
3033

3134
$config = $this->processConfiguration($configuration, $configs);
3235

src/Model/ResetPasswordToken.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ public function getExpiresAtIntervalInstance(): \DateInterval
143143
return $this->expiresAt->diff($createdAtTime);
144144
}
145145

146+
/**
147+
* @psalm-suppress UndefinedFunction
148+
*/
146149
private function triggerDeprecation(): void
147150
{
148151
trigger_deprecation(

tests/Fixtures/Entity/ResetPasswordTestFixtureRequest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*
2121
* @ORM\Entity(repositoryClass="SymfonyCasts\Bundle\ResetPassword\Tests\Fixtures\ResetPasswordTestFixtureRequestRepository")
2222
*/
23+
#[ORM\Entity(repositoryClass: "SymfonyCasts\Bundle\ResetPassword\Tests\Fixtures\ResetPasswordTestFixtureRequestRepository")]
2324
final class ResetPasswordTestFixtureRequest implements ResetPasswordRequestInterface
2425
{
2526
/**
@@ -29,26 +30,33 @@ final class ResetPasswordTestFixtureRequest implements ResetPasswordRequestInter
2930
*
3031
* @ORM\Column(type="integer")
3132
*/
33+
#[ORM\Id]
34+
#[ORM\GeneratedValue]
35+
#[ORM\Column(type: 'integer')]
3236
public $id;
3337

3438
/**
3539
* @ORM\Column(type="string", nullable=true)
3640
*/
41+
#[ORM\Column(type: 'string', nullable: true)]
3742
public $selector;
3843

3944
/**
4045
* @ORM\Column(type="datetime_immutable", nullable=true)
4146
*/
47+
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
4248
public $expiresAt;
4349

4450
/**
4551
* @ORM\Column(type="datetime_immutable", nullable=true)
4652
*/
53+
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
4754
public $requestedAt;
4855

4956
/**
5057
* @ORM\ManyToOne(targetEntity="ResetPasswordTestFixtureUser")
5158
*/
59+
#[ORM\ManyToOne(targetEntity: 'ResetPasswordTestFixtureUser')]
5260
public $user;
5361

5462
public function getRequestedAt(): \DateTimeInterface

tests/Fixtures/Entity/ResetPasswordTestFixtureUser.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*
2020
* @ORM\Entity()
2121
*/
22+
#[ORM\Entity]
2223
final class ResetPasswordTestFixtureUser
2324
{
2425
/**
@@ -28,5 +29,8 @@ final class ResetPasswordTestFixtureUser
2829
*
2930
* @ORM\Column(type="integer")
3031
*/
32+
#[ORM\Id]
33+
#[ORM\GeneratedValue]
34+
#[ORM\Column(type: 'integer')]
3135
private $id;
3236
}

tests/ResetPasswordTestKernel.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
9191
'mappings' => [
9292
'App' => [
9393
'is_bundle' => false,
94-
'type' => 'annotation',
94+
'type' => self::shouldUseAttributes() ? 'attribute' : 'annotation',
9595
'dir' => 'tests/Fixtures/Entity/',
9696
'prefix' => 'SymfonyCasts\Bundle\ResetPassword\Tests\Fixtures\Entity',
9797
'alias' => 'App',
@@ -141,4 +141,9 @@ public function getLogDir(): string
141141
{
142142
return sys_get_temp_dir().'/logs'.spl_object_hash($this);
143143
}
144+
145+
public static function shouldUseAttributes(): bool
146+
{
147+
return Kernel::VERSION_ID >= 70000;
148+
}
144149
}

0 commit comments

Comments
 (0)