Skip to content

Commit f679bd1

Browse files
authored
Drop Symfony 5.x, Allow Symfony 8.0 (#59)
* Drop Symfony 5.x, Allow Symfony 8.0 * Fixed PhpStan issues
1 parent 85e5f10 commit f679bd1

22 files changed

+326
-358
lines changed

.github/workflows/tests.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ jobs:
1414
matrix:
1515
include:
1616
- php-version: '8.1'
17-
symfony-version: '5.4.*'
17+
symfony-version: '6.4.*'
18+
- php-version: '8.4'
19+
symfony-version: '6.4.*'
1820
- php-version: '8.2'
19-
symfony-version: '5.4.*'
20-
- php-version: '8.1'
21-
symfony-version: '6.3.*'
22-
- php-version: '8.2'
23-
symfony-version: '6.3.*'
21+
symfony-version: '7.4.*'
22+
- php-version: '8.4'
23+
symfony-version: '7.4.*'
24+
- php-version: '8.4'
25+
symfony-version: '8.0.*'
2426
steps:
2527
- name: "Checkout"
2628
uses: actions/checkout@v2
@@ -41,8 +43,8 @@ jobs:
4143
- name: "Setup env & install dependencies"
4244
uses: ./.github/actions/install
4345
with:
44-
php-version: '8.1'
45-
symfony-version: '6.1.*'
46+
php-version: '8.4'
47+
symfony-version: '8.0.*'
4648
- name: "Run static analyzis with phpstan/phpstan"
4749
run: vendor/bin/phpstan analyze
4850

@@ -55,8 +57,8 @@ jobs:
5557
- name: "Setup env & install dependencies"
5658
uses: ./.github/actions/install
5759
with:
58-
php-version: '8.1'
59-
symfony-version: '6.1.*'
60+
php-version: '8.4'
61+
symfony-version: '8.0.*'
6062
- name: "Run checkstyle with symplify/easy-coding-standard"
6163
run: vendor/bin/ecs
6264

@@ -69,8 +71,8 @@ jobs:
6971
- name: "Setup env & install dependencies"
7072
uses: ./.github/actions/install
7173
with:
72-
php-version: '8.1'
73-
symfony-version: '6.1.*'
74+
php-version: '8.4'
75+
symfony-version: '8.0.*'
7476
coverage-mode: 'xdebug'
7577
- name: "Run tests with phpunit/phpunit"
7678
env:

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
"require": {
1212
"php": "^8.1",
1313
"ext-openssl": "*",
14-
"symfony/framework-bundle": "^5.4|^6.0",
15-
"doctrine/orm": "^2.7",
16-
"doctrine/doctrine-bundle": "^2.0",
14+
"symfony/framework-bundle": "^6.4|^7.4|^8.0",
15+
"doctrine/common": "^3.0",
16+
"doctrine/orm": "^3.0",
17+
"doctrine/doctrine-bundle": "^2.0|^3.0",
1718
"yokai/dependency-injection": "^1.0"
1819
},
1920
"require-dev": {
2021
"phpunit/phpunit": "^9.5",
21-
"phpspec/prophecy-phpunit": "^2.0",
22-
"symfony/yaml": "^5.4|^6.0",
22+
"symfony/yaml": "^6.4|^7.4|^8.0",
2323
"phpstan/phpstan": "^1.7",
2424
"symplify/easy-coding-standard": "^11.3"
2525
},

phpstan-baseline.neon

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
11
parameters:
22
ignoreErrors:
3-
-
4-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:addDefaultsIfNotSet\\(\\)\\.$#"
5-
count: 2
6-
path: src/DependencyInjection/Configuration.php
7-
8-
-
9-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
10-
count: 2
11-
path: src/DependencyInjection/Configuration.php
12-
13-
-
14-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:useAttributeAsKey\\(\\)\\.$#"
15-
count: 1
16-
path: src/DependencyInjection/Configuration.php
17-
18-
-
19-
message: "#^Method Yokai\\\\SecurityTokenBundle\\\\Entity\\\\Token\\:\\:getLastUsage\\(\\) should return Yokai\\\\SecurityTokenBundle\\\\Entity\\\\TokenUsage\\|null but returns mixed\\.$#"
20-
count: 1
21-
path: src/Entity/Token.php
22-
23-
-
24-
message: "#^Method Yokai\\\\SecurityTokenBundle\\\\Entity\\\\Token\\:\\:getUsages\\(\\) should return array\\<Yokai\\\\SecurityTokenBundle\\\\Entity\\\\TokenUsage\\> but returns array\\.$#"
25-
count: 1
26-
path: src/Entity/Token.php
27-
283
-
294
message: "#^Property Yokai\\\\SecurityTokenBundle\\\\Entity\\\\Token\\:\\:\\$id is never written, only read\\.$#"
305
count: 1
@@ -35,13 +10,3 @@ parameters:
3510
count: 1
3611
path: src/Entity/TokenUsage.php
3712

38-
-
39-
message: "#^Cannot cast mixed to string\\.$#"
40-
count: 1
41-
path: src/Manager/ChainUserManager.php
42-
43-
-
44-
message: "#^Cannot cast mixed to string\\.$#"
45-
count: 1
46-
path: src/Manager/DoctrineUserManager.php
47-

phpstan.neon

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ includes:
22
- phpstan-baseline.neon
33
parameters:
44
level: max
5-
checkMissingIterableValueType: false
6-
checkGenericClassInNonGenericObjectType: false
5+
ignoreErrors:
6+
- identifier: missingType.generics
7+
- identifier: missingType.iterableValue
78
paths:
89
- src/

src/Archive/ArchivistInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ interface ArchivistInterface
1818
*
1919
* @return integer
2020
*/
21-
public function archive(string $purpose = null): int;
21+
public function archive(string|null $purpose = null): int;
2222
}

src/Archive/DeleteArchivist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(EntityRepository $tokenRepository)
2727
$this->tokenRepository = $tokenRepository;
2828
}
2929

30-
public function archive(string $purpose = null): int
30+
public function archive(string|null $purpose = null): int
3131
{
3232
$builder = $this->tokenRepository->createQueryBuilder('token')
3333
->delete($this->tokenRepository->getClassName(), 'token');

src/Entity/Token.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Token
7070
private $keepUntil;
7171

7272
/**
73-
* @var Collection<TokenUsage>
73+
* @var Collection<int, TokenUsage>
7474
*/
7575
private $usages;
7676

@@ -192,15 +192,15 @@ public function getUsages(): array
192192
return $this->usages->toArray();
193193
}
194194

195-
public function getLastUsage(): ?TokenUsage
195+
public function getLastUsage(): TokenUsage|null
196196
{
197-
return $this->usages->last();
197+
return $this->usages->last() ?: null;
198198
}
199199

200200
/**
201201
* @throws LogicException
202202
*/
203-
public function consume(array $information, DateTime $date = null): void
203+
public function consume(array $information, DateTime|null $date = null): void
204204
{
205205
if ($this->isConsumed()) {
206206
throw new LogicException(

src/Entity/TokenUsage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TokenUsage
3131
/**
3232
* @param array<string, mixed> $information
3333
*/
34-
public function __construct(Token $token, array $information, DateTime $createdAt = null)
34+
public function __construct(Token $token, array $information, DateTime|null $createdAt = null)
3535
{
3636
$this->token = $token;
3737
$this->information = $information;

src/EventDispatcher.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function tokenCreated(Token $token): TokenCreatedEvent
5353
return $event;
5454
}
5555

56-
public function consumeToken(Token $token, DateTime $at = null, array $information = []): ConsumeTokenEvent
56+
public function consumeToken(Token $token, DateTime|null $at = null, array $information = []): ConsumeTokenEvent
5757
{
5858
$this->eventDispatcher->dispatch(
5959
$event = new ConsumeTokenEvent($token, $at, $information)
@@ -71,7 +71,6 @@ public function tokenConsumed(Token $token): TokenConsumedEvent
7171
return $event;
7272
}
7373

74-
7574
public function tokenTotallyConsumed(Token $token): TokenTotallyConsumedEvent
7675
{
7776
$this->eventDispatcher->dispatch(

src/Manager/ChainUserManager.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,18 @@ private function getManagerForUser($user): UserManagerInterface
108108
$tries[] = get_class($manager);
109109
}
110110

111-
if (is_object($user) && !method_exists($user, '__toString')) {
112-
$userAsString = sprintf('%s::%s', get_class($user), spl_object_hash($user));
111+
if (is_object($user)) {
112+
if (!method_exists($user, '__toString')) {
113+
$userAsString = sprintf('%s::%s', get_class($user), spl_object_hash($user));
114+
} else {
115+
$userAsString = (string)$user;
116+
}
113117
} else {
114-
$userAsString = (string)$user;
118+
if (is_scalar($user)) {
119+
$userAsString = (string)$user;
120+
} else {
121+
$userAsString = get_debug_type($user);
122+
}
115123
}
116124

117125
throw new \InvalidArgumentException(

0 commit comments

Comments
 (0)