Skip to content

Commit 989e5f5

Browse files
bug #57799 [ErrorHandler][VarDumper] Remove PHP 8.4 deprecations (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [ErrorHandler][VarDumper] Remove PHP 8.4 deprecations | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT [A new batch of deprecations](https://wiki.php.net/rfc/deprecations_php_8_4) is coming with PHP 8.4. There's a few things in the code to remove to be completely deprecation free in 5.4. Even if the vote is not finished yet, most deprecations are likely to pass barring a major turn of events. Commits ------- 74b0163 [ErrorHandler][VarDumper] Remove PHP 8.4 deprecations
2 parents e507619 + 74b0163 commit 989e5f5

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

src/Symfony/Component/ErrorHandler/ErrorHandler.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class ErrorHandler
5555
\E_USER_DEPRECATED => 'User Deprecated',
5656
\E_NOTICE => 'Notice',
5757
\E_USER_NOTICE => 'User Notice',
58-
\E_STRICT => 'Runtime Notice',
5958
\E_WARNING => 'Warning',
6059
\E_USER_WARNING => 'User Warning',
6160
\E_COMPILE_WARNING => 'Compile Warning',
@@ -73,7 +72,6 @@ class ErrorHandler
7372
\E_USER_DEPRECATED => [null, LogLevel::INFO],
7473
\E_NOTICE => [null, LogLevel::WARNING],
7574
\E_USER_NOTICE => [null, LogLevel::WARNING],
76-
\E_STRICT => [null, LogLevel::WARNING],
7775
\E_WARNING => [null, LogLevel::WARNING],
7876
\E_USER_WARNING => [null, LogLevel::WARNING],
7977
\E_COMPILE_WARNING => [null, LogLevel::WARNING],
@@ -183,6 +181,11 @@ public static function call(callable $function, ...$arguments)
183181

184182
public function __construct(?BufferingLogger $bootstrappingLogger = null, bool $debug = false)
185183
{
184+
if (\PHP_VERSION_ID < 80400) {
185+
$this->levels[\E_STRICT] = 'Runtime Notice';
186+
$this->loggers[\E_STRICT] = [null, LogLevel::WARNING];
187+
}
188+
186189
if ($bootstrappingLogger) {
187190
$this->bootstrappingLogger = $bootstrappingLogger;
188191
$this->setDefaultLogger($bootstrappingLogger);

src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ public function testDefaultLogger()
213213
\E_USER_DEPRECATED => [null, LogLevel::INFO],
214214
\E_NOTICE => [$logger, LogLevel::WARNING],
215215
\E_USER_NOTICE => [$logger, LogLevel::CRITICAL],
216-
\E_STRICT => [null, LogLevel::WARNING],
217216
\E_WARNING => [null, LogLevel::WARNING],
218217
\E_USER_WARNING => [null, LogLevel::WARNING],
219218
\E_COMPILE_WARNING => [null, LogLevel::WARNING],
@@ -225,6 +224,11 @@ public function testDefaultLogger()
225224
\E_ERROR => [null, LogLevel::CRITICAL],
226225
\E_CORE_ERROR => [null, LogLevel::CRITICAL],
227226
];
227+
228+
if (\PHP_VERSION_ID < 80400) {
229+
$loggers[\E_STRICT] = [null, LogLevel::WARNING];
230+
}
231+
228232
$this->assertSame($loggers, $handler->setLoggers([]));
229233
} finally {
230234
restore_error_handler();
@@ -478,7 +482,6 @@ public function testBootstrappingLogger()
478482
\E_USER_DEPRECATED => [$bootLogger, LogLevel::INFO],
479483
\E_NOTICE => [$bootLogger, LogLevel::WARNING],
480484
\E_USER_NOTICE => [$bootLogger, LogLevel::WARNING],
481-
\E_STRICT => [$bootLogger, LogLevel::WARNING],
482485
\E_WARNING => [$bootLogger, LogLevel::WARNING],
483486
\E_USER_WARNING => [$bootLogger, LogLevel::WARNING],
484487
\E_COMPILE_WARNING => [$bootLogger, LogLevel::WARNING],
@@ -491,6 +494,10 @@ public function testBootstrappingLogger()
491494
\E_CORE_ERROR => [$bootLogger, LogLevel::CRITICAL],
492495
];
493496

497+
if (\PHP_VERSION_ID < 80400) {
498+
$loggers[\E_STRICT] = [$bootLogger, LogLevel::WARNING];
499+
}
500+
494501
$this->assertSame($loggers, $handler->setLoggers([]));
495502

496503
$handler->handleError(\E_DEPRECATED, 'Foo message', __FILE__, 123, []);

src/Symfony/Component/VarDumper/Caster/DOMCaster.php

+1-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
class DOMCaster
2424
{
2525
private const ERROR_CODES = [
26-
\DOM_PHP_ERR => 'DOM_PHP_ERR',
26+
0 => 'DOM_PHP_ERR',
2727
\DOM_INDEX_SIZE_ERR => 'DOM_INDEX_SIZE_ERR',
2828
\DOMSTRING_SIZE_ERR => 'DOMSTRING_SIZE_ERR',
2929
\DOM_HIERARCHY_REQUEST_ERR => 'DOM_HIERARCHY_REQUEST_ERR',
@@ -138,16 +138,12 @@ public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, boo
138138
'doctype' => $dom->doctype,
139139
'implementation' => $dom->implementation,
140140
'documentElement' => new CutStub($dom->documentElement),
141-
'actualEncoding' => $dom->actualEncoding,
142141
'encoding' => $dom->encoding,
143142
'xmlEncoding' => $dom->xmlEncoding,
144-
'standalone' => $dom->standalone,
145143
'xmlStandalone' => $dom->xmlStandalone,
146-
'version' => $dom->version,
147144
'xmlVersion' => $dom->xmlVersion,
148145
'strictErrorChecking' => $dom->strictErrorChecking,
149146
'documentURI' => $dom->documentURI ? new LinkStub($dom->documentURI) : $dom->documentURI,
150-
'config' => $dom->config,
151147
'formatOutput' => $dom->formatOutput,
152148
'validateOnParse' => $dom->validateOnParse,
153149
'resolveExternals' => $dom->resolveExternals,
@@ -275,9 +271,6 @@ public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, bool $i
275271
'publicId' => $dom->publicId,
276272
'systemId' => $dom->systemId,
277273
'notationName' => $dom->notationName,
278-
'actualEncoding' => $dom->actualEncoding,
279-
'encoding' => $dom->encoding,
280-
'version' => $dom->version,
281274
];
282275

283276
return $a;

src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ExceptionCaster
4141
\E_USER_ERROR => 'E_USER_ERROR',
4242
\E_USER_WARNING => 'E_USER_WARNING',
4343
\E_USER_NOTICE => 'E_USER_NOTICE',
44-
\E_STRICT => 'E_STRICT',
44+
2048 => 'E_STRICT',
4545
];
4646

4747
private static $framesCache = [];

0 commit comments

Comments
 (0)