Skip to content

Commit f7ed117

Browse files
Stephan Wentzpl-github
authored andcommitted
fix: Upgrade to phpstan 2, phpunit 12 and allow safe 3
1 parent 6dc6ce7 commit f7ed117

17 files changed

+109
-67
lines changed

composer.json

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
{
22
"name": "brainbits/functional-test-helpers",
3-
"type": "library",
43
"description": "brainbits controlling functional test helpers",
54
"license": "MIT",
5+
"type": "library",
66
"require": {
77
"php": "^8.3",
8-
"thecodingmachine/safe": "^2.0"
8+
"thecodingmachine/safe": "^2.0 || ^3.0"
99
},
1010
"require-dev": {
1111
"ext-dom": "*",
1212
"ext-iconv": "*",
1313
"ext-mbstring": "*",
1414
"ext-simplexml": "*",
1515
"ext-tidy": "*",
16-
"brainbits/phpcs-standard": "^7.0",
17-
"brainbits/phpstan-rules": "^3.1.2",
18-
"dama/doctrine-test-bundle": "^8.0",
19-
"doctrine/dbal": "^3.4",
20-
"ergebnis/phpstan-rules": "^2.5.2",
21-
"gemorroj/archive7z": "^5.3",
22-
"jangregor/phpstan-prophecy": "^1.0.2",
23-
"mikey179/vfsstream": "^1.6.11",
24-
"monolog/monolog": "^2.3|^3.0",
25-
"phpstan/phpstan": "^1.12.15",
26-
"phpstan/phpstan-phpunit": "^1.4.2",
27-
"phpstan/phpstan-symfony": "^1.4.13",
28-
"phpunit/phpunit": "^11.4",
16+
"brainbits/phpcs-standard": "^7.0.1",
17+
"brainbits/phpstan-rules": "^4.0",
18+
"dama/doctrine-test-bundle": "^8.2",
19+
"doctrine/dbal": "^3.9",
20+
"ergebnis/phpstan-rules": "^2.6",
21+
"gemorroj/archive7z": "^5.7",
22+
"mikey179/vfsstream": "^1.6.12",
23+
"monolog/monolog": "^2.0 || ^3.0",
24+
"phpstan/phpstan": "^2.1.4",
25+
"phpstan/phpstan-phpunit": "^2.0.4",
26+
"phpstan/phpstan-symfony": "^2.0.2",
27+
"phpunit/phpunit": "^12.0.2",
2928
"psr/http-message": "^2.0",
3029
"riverline/multipart-parser": "^2.1",
31-
"slam/phpstan-extensions": "^6.5.0",
32-
"squizlabs/php_codesniffer": "^3.10",
30+
"slam/phpstan-extensions": "^6.6.0",
31+
"squizlabs/php_codesniffer": "^3.11.3",
3332
"symfony/browser-kit": "^7.0",
3433
"symfony/console": "^7.0",
3534
"symfony/dependency-injection": "^7.0",
@@ -41,40 +40,30 @@
4140
"symfony/security-core": "^7.0",
4241
"symfony/security-csrf": "^7.0",
4342
"symfony/uid": "^7.0",
44-
"thecodingmachine/phpstan-safe-rule": "^1.2",
45-
"thecodingmachine/phpstan-strict-rules": "^1.0"
43+
"thecodingmachine/phpstan-safe-rule": "^1.4"
4644
},
4745
"suggest": {
4846
"ext-dom": "For mocking xml requests",
4947
"ext-iconv": "For asserting zip files",
50-
"ext-mbstring": "For asserting zip files",
5148
"ext-json": "For json snapshot tests",
49+
"ext-mbstring": "For asserting zip files",
5250
"ext-simplexml": "For mocking xml requests",
5351
"ext-tidy": "For html snapshots",
52+
"dama/doctrine-test-bundle": "For schema trait, when using DAMA Static Driver",
5453
"doctrine/dbal": "For schema trait",
5554
"doctrine/event-manager": "For schema trait",
56-
"dama/doctrine-test-bundle": "For schema trait, when using DAMA Static Driver",
5755
"gemorroj/archive7z": "For 7z file support",
5856
"monolog/monolog": "For http client mock trait",
5957
"riverline/multipart-parser": "For multipart file uploads",
6058
"symfony/browser-kit": "For request trait",
6159
"symfony/console": "For console trait",
6260
"symfony/filesystem": "For request trait",
61+
"symfony/framework-bundle": "For request trait, when using authLogin(). Requires version >= 7.0",
6362
"symfony/http-client": "For http client mock trait",
6463
"symfony/http-foundation": "For request trait",
65-
"symfony/framework-bundle": "For request trait, when using authLogin(). Requires version >= 5.1",
6664
"symfony/security-core": "For request trait",
6765
"symfony/uid": "For uuid trait"
6866
},
69-
"config": {
70-
"preferred-install": {
71-
"*": "dist"
72-
},
73-
"sort-packages": true,
74-
"allow-plugins": {
75-
"dealerdirect/phpcodesniffer-composer-installer": true
76-
}
77-
},
7867
"autoload": {
7968
"psr-4": {
8069
"Brainbits\\FunctionalTestHelpers\\": "src/"
@@ -84,5 +73,14 @@
8473
"psr-4": {
8574
"Brainbits\\FunctionalTestHelpers\\Tests\\": "tests/"
8675
}
76+
},
77+
"config": {
78+
"allow-plugins": {
79+
"dealerdirect/phpcodesniffer-composer-installer": true
80+
},
81+
"preferred-install": {
82+
"*": "dist"
83+
},
84+
"sort-packages": true
8785
}
8886
}

phpstan.neon.dist

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
parameters:
22
level: 6
3+
treatPhpDocTypesAsCertain: false
34
paths:
45
- src
56
- tests
67
excludePaths:
7-
- src/Kernel.php
8-
- tests/bootstrap.php
98
- src/HttpClientMock/CallbackHandler.php # needed because of unknown classes when installed with monolog 2.x
10-
- src/HttpClientMock/LegacyCallbackHandler.php # needed because of unknown classes when installed with monolog 2.x
119
ignoreErrors:
1210
- '#Constructor in .* has parameter .* with default value#'
13-
- '#In method "Brainbits\\FunctionalTestHelpers\\Snapshot\\IsXml::.*", caught "Throwable" must be rethrown. Either catch a more specific exception or add a "throw" clause in the "catch" block to propagate the exception.#'
14-
- '#In method "Brainbits\\FunctionalTestHelpers\\Tests\\Uuid\\UuidTraitTest::.*", caught "Throwable" must be rethrown. Either catch a more specific exception or add a "throw" clause in the "catch" block to propagate the exception.#'
15-
- '#Safe\\DateTimeImmutable#'
1611
- '#SchemaBuilder::foo\(\)#'
1712
ergebnis:
1813
noNullableReturnTypeDeclaration:
@@ -31,9 +26,8 @@ parameters:
3126
includes:
3227
- %rootDir%/../../brainbits/phpstan-rules/rules.neon
3328
- %rootDir%/../../ergebnis/phpstan-rules/rules.neon
34-
- %rootDir%/../../jangregor/phpstan-prophecy/extension.neon
3529
- %rootDir%/../../phpstan/phpstan-phpunit/extension.neon
3630
- %rootDir%/../../phpstan/phpstan-phpunit/rules.neon
3731
- %rootDir%/../../phpstan/phpstan-symfony/extension.neon
38-
- %rootDir%/../../thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
39-
- %rootDir%/../../thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
32+
# - %rootDir%/../../thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
33+
# - %rootDir%/../../thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon

src/HttpClientMock/Matcher/CatchAllMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
final readonly class CatchAllMatcher implements Matcher
1010
{
11-
public function __invoke(RealRequest $realRequest): Hit|Mismatch|Missing
11+
public function __invoke(RealRequest $realRequest): Hit
1212
{
1313
return Hit::catchAll();
1414
}

src/HttpClientMock/Matcher/ContentMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function __construct(string|callable $content)
1818
$this->content = $content;
1919
}
2020

21-
public function __invoke(RealRequest $realRequest): Hit|Mismatch|Missing
21+
public function __invoke(RealRequest $realRequest): Hit|Mismatch
2222
{
2323
$expectedContent = $this->content;
2424
$realContent = $realRequest->getContent();

src/HttpClientMock/Matcher/JsonMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct(array|callable $json)
2121
$this->json = $json;
2222
}
2323

24-
public function __invoke(RealRequest $realRequest): Hit|Mismatch|Missing
24+
public function __invoke(RealRequest $realRequest): Hit|Mismatch
2525
{
2626
$expectedJson = $this->json;
2727
$realJson = $realRequest->getJson();

src/HttpClientMock/Matcher/MethodMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __construct(string|callable $method)
1919
$this->method = $method;
2020
}
2121

22-
public function __invoke(RealRequest $realRequest): Hit|Mismatch|Missing
22+
public function __invoke(RealRequest $realRequest): Hit|Mismatch
2323
{
2424
$expectedMethod = $this->method;
2525
$realMethod = $realRequest->getMethod();

src/HttpClientMock/Matcher/ThatMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function __construct(callable $that)
1515
$this->that = $that;
1616
}
1717

18-
public function __invoke(RealRequest $realRequest): Hit|Mismatch|Missing
18+
public function __invoke(RealRequest $realRequest): Hit|Mismatch
1919
{
2020
if (($this->that)($realRequest) === false) {
2121
return Mismatch::mismatchingThat('returned false');

src/HttpClientMock/Matcher/UriMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(string|callable $uri, private UriParams $uriParams)
2424
$this->uri = $uri;
2525
}
2626

27-
public function __invoke(RealRequest $realRequest): Hit|Mismatch|Missing
27+
public function __invoke(RealRequest $realRequest): Hit|Mismatch
2828
{
2929
$realUri = $realRequest->getUri();
3030

src/HttpClientMock/Matcher/XmlMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(string|callable $xml)
2828
$this->xml = $xml;
2929
}
3030

31-
public function __invoke(RealRequest $realRequest): Hit|Mismatch|Missing
31+
public function __invoke(RealRequest $realRequest): Hit|Mismatch
3232
{
3333
$expectedXml = $this->xml;
3434
$realXml = $realRequest->getContent();

src/HttpClientMock/MockRequestBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public function hasResponse(): bool
306306
return !$this->responses->isEmpty();
307307
}
308308

309-
public function nextResponse(): MockResponseBuilder|Throwable|null
309+
public function nextResponse(): MockResponseBuilder|Throwable
310310
{
311311
try {
312312
return $this->responses->next();

0 commit comments

Comments
 (0)