Skip to content

Commit 91bab7a

Browse files
authored
Adapt to PHP 8.4 (#139)
Co-authored-by: vjik <[email protected]>
1 parent b5c1568 commit 91bab7a

21 files changed

+72
-36
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
os: >-
3232
['ubuntu-latest', 'windows-latest']
3333
php: >-
34-
['8.1', '8.2', '8.3']
34+
['8.1', '8.2', '8.3', '8.4']

.github/workflows/composer-require-checker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
os: >-
3232
['ubuntu-latest']
3333
php: >-
34-
['8.1', '8.2', '8.3']
34+
['8.1', '8.2', '8.3', '8.4']

.github/workflows/rector.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
os: >-
2222
['ubuntu-latest']
2323
php: >-
24-
['8.3']
24+
['8.4']

.github/workflows/static.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
os: >-
3030
['ubuntu-latest']
3131
php: >-
32-
['8.1', '8.2', '8.3']
32+
['8.1', '8.2', '8.3', '8.4']

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
class (@olegbaturin)
99
- Chg #137: Add separate parameters for each of `HtmlRenderer` settings in constructor. Mark `$settings` parameter as
1010
deprecated (@vjik)
11-
- Enh #138: Raise the minimum PHP version to 8.1 and minor refactoring (@vjik)
11+
- Enh #138, #139: Raise the minimum PHP version to 8.1 and minor refactoring (@vjik)
12+
- Chg #139: Change PHP constraint in `composer.json` to `~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0` (@vjik)
13+
- Bug #139: Explicitly mark nullable parameters (@vjik)
1214

1315
## 3.3.0 July 11, 2024
1416

composer.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
}
3232
],
3333
"require": {
34-
"php": "^8.1",
34+
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
3535
"ext-dom": "*",
3636
"ext-mbstring": "*",
3737
"alexkart/curl-builder": "^1.0",
@@ -47,14 +47,14 @@
4747
"yiisoft/injector": "^1.0"
4848
},
4949
"require-dev": {
50+
"bamarni/composer-bin-plugin": "^1.8",
5051
"httpsoft/http-message": "^1.1.6",
51-
"maglnet/composer-require-checker": "^4.7.1",
5252
"phpunit/phpunit": "^10.5.44",
5353
"psr/event-dispatcher": "^1.0",
5454
"rector/rector": "^2.0.7",
5555
"roave/infection-static-analysis-plugin": "^1.35",
5656
"spatie/phpunit-watcher": "^1.24",
57-
"vimeo/psalm": "^5.26.1|^6",
57+
"vimeo/psalm": "^5.26.1|^6.2",
5858
"yiisoft/di": "^1.3",
5959
"yiisoft/test-support": "^3.0.1"
6060
},
@@ -69,6 +69,11 @@
6969
}
7070
},
7171
"extra": {
72+
"bamarni-bin": {
73+
"bin-links": true,
74+
"target-directory": "tools",
75+
"forward-command": true
76+
},
7277
"config-plugin-options": {
7378
"source-directory": "config"
7479
},
@@ -80,8 +85,9 @@
8085
"sort-packages": true,
8186
"bump-after-update": "dev",
8287
"allow-plugins": {
83-
"infection/extension-installer": true,
84-
"composer/package-versions-deprecated": true
88+
"bamarni/composer-bin-plugin": true,
89+
"composer/package-versions-deprecated": true,
90+
"infection/extension-installer": true
8591
}
8692
},
8793
"scripts": {

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
executionOrder="random"
1010
failOnRisky="true"
1111
failOnWarning="true"
12+
failOnDeprecation="true"
1213
stopOnFailure="false"
1314
colors="true"
1415
displayDetailsOnPhpunitDeprecations="true"

rector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Rector\Config\RectorConfig;
77
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
88
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
9+
use Rector\Php81\Rector\ClassMethod\NewInInitializerRector;
910
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
1011

1112
return RectorConfig::configure()
@@ -21,4 +22,5 @@
2122
ClosureToArrowFunctionRector::class,
2223
NullToStrictStringFuncCallArgRector::class,
2324
RemoveExtraParametersRector::class,
25+
NewInInitializerRector::class,
2426
]);

src/ErrorHandler.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public function __construct(
6262
*/
6363
public function handle(
6464
Throwable $t,
65-
ThrowableRendererInterface $renderer = null,
66-
ServerRequestInterface $request = null
65+
?ThrowableRendererInterface $renderer = null,
66+
?ServerRequestInterface $request = null
6767
): ErrorData {
6868
$renderer ??= $this->defaultRenderer;
6969

@@ -192,6 +192,9 @@ private function initializeOnce(): void
192192
});
193193

194194
if (!(PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg')) {
195+
/**
196+
* @var string
197+
*/
195198
$this->workingDirectory = getcwd();
196199
}
197200

src/Exception/ErrorException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ class ErrorException extends \ErrorException implements FriendlyExceptionInterfa
3333
E_USER_ERROR => 'PHP User Error',
3434
E_USER_WARNING => 'PHP User Warning',
3535
E_USER_NOTICE => 'PHP User Notice',
36-
E_STRICT => 'PHP Strict Warning',
36+
2048 => 'PHP Strict Warning', // E_STRICT
3737
E_RECOVERABLE_ERROR => 'PHP Recoverable Error',
3838
E_DEPRECATED => 'PHP Deprecated Warning',
3939
E_USER_DEPRECATED => 'PHP User Deprecated Warning',
4040
];
4141

4242
/** @psalm-param DebugBacktraceType $backtrace */
43-
public function __construct(string $message = '', int $code = 0, int $severity = 1, string $filename = __FILE__, int $line = __LINE__, Exception $previous = null, private readonly array $backtrace = [])
43+
public function __construct(string $message = '', int $code = 0, int $severity = 1, string $filename = __FILE__, int $line = __LINE__, ?Exception $previous = null, private readonly array $backtrace = [])
4444
{
4545
parent::__construct($message, $code, $severity, $filename, $line, $previous);
4646
$this->addXDebugTraceToFatalIfAvailable();
@@ -149,6 +149,6 @@ private function isXdebugStackAvailable(): bool
149149
}
150150

151151
// Xdebug 3 and later, proper mode is required
152-
return str_contains(ini_get('xdebug.mode'), 'develop');
152+
return str_contains((string) \ini_get('xdebug.mode'), 'develop');
153153
}
154154
}

0 commit comments

Comments
 (0)