Skip to content
This repository was archived by the owner on Dec 9, 2023. It is now read-only.

Commit 093e4e5

Browse files
Enable "native_constant_invocation" CS rule
1 parent 0893a0b commit 093e4e5

9 files changed

+128
-128
lines changed

Debug.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Debug
2828
* @param int $errorReportingLevel The level of error reporting you want
2929
* @param bool $displayErrors Whether to display errors (for development) or just log them (for production)
3030
*/
31-
public static function enable($errorReportingLevel = E_ALL, $displayErrors = true)
31+
public static function enable($errorReportingLevel = \E_ALL, $displayErrors = true)
3232
{
3333
if (static::$enabled) {
3434
return;
@@ -39,13 +39,13 @@ public static function enable($errorReportingLevel = E_ALL, $displayErrors = tru
3939
if (null !== $errorReportingLevel) {
4040
error_reporting($errorReportingLevel);
4141
} else {
42-
error_reporting(E_ALL);
42+
error_reporting(\E_ALL);
4343
}
4444

4545
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
4646
ini_set('display_errors', 0);
4747
ExceptionHandler::register();
48-
} elseif ($displayErrors && (!filter_var(ini_get('log_errors'), FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
48+
} elseif ($displayErrors && (!filter_var(ini_get('log_errors'), \FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
4949
// CLI - display errors only if they're not already logged to STDERR
5050
ini_set('display_errors', 1);
5151
}

DebugClassLoader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function __construct(callable $classLoader)
5656
} elseif (substr($test, -\strlen($file)) === $file) {
5757
// filesystem is case insensitive and realpath() normalizes the case of characters
5858
self::$caseCheck = 1;
59-
} elseif (false !== stripos(PHP_OS, 'darwin')) {
59+
} elseif (false !== stripos(\PHP_OS, 'darwin')) {
6060
// on MacOSX, HFS+ is case insensitive but realpath() doesn't normalize the case of characters
6161
self::$caseCheck = 2;
6262
} else {
@@ -141,7 +141,7 @@ public function findFile($class)
141141
*/
142142
public function loadClass($class)
143143
{
144-
$e = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
144+
$e = error_reporting(error_reporting() | \E_PARSE | \E_ERROR | \E_CORE_ERROR | \E_COMPILE_ERROR);
145145

146146
try {
147147
if ($this->isFinder && !isset($this->loaded[$class])) {
@@ -197,7 +197,7 @@ private function checkClass($class, $file = null)
197197
}
198198

199199
foreach ($deprecations as $message) {
200-
@trigger_error($message, E_USER_DEPRECATED);
200+
@trigger_error($message, \E_USER_DEPRECATED);
201201
}
202202
}
203203

ErrorHandler.php

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -49,39 +49,39 @@
4949
class ErrorHandler
5050
{
5151
private $levels = [
52-
E_DEPRECATED => 'Deprecated',
53-
E_USER_DEPRECATED => 'User Deprecated',
54-
E_NOTICE => 'Notice',
55-
E_USER_NOTICE => 'User Notice',
56-
E_STRICT => 'Runtime Notice',
57-
E_WARNING => 'Warning',
58-
E_USER_WARNING => 'User Warning',
59-
E_COMPILE_WARNING => 'Compile Warning',
60-
E_CORE_WARNING => 'Core Warning',
61-
E_USER_ERROR => 'User Error',
62-
E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
63-
E_COMPILE_ERROR => 'Compile Error',
64-
E_PARSE => 'Parse Error',
65-
E_ERROR => 'Error',
66-
E_CORE_ERROR => 'Core Error',
52+
\E_DEPRECATED => 'Deprecated',
53+
\E_USER_DEPRECATED => 'User Deprecated',
54+
\E_NOTICE => 'Notice',
55+
\E_USER_NOTICE => 'User Notice',
56+
\E_STRICT => 'Runtime Notice',
57+
\E_WARNING => 'Warning',
58+
\E_USER_WARNING => 'User Warning',
59+
\E_COMPILE_WARNING => 'Compile Warning',
60+
\E_CORE_WARNING => 'Core Warning',
61+
\E_USER_ERROR => 'User Error',
62+
\E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
63+
\E_COMPILE_ERROR => 'Compile Error',
64+
\E_PARSE => 'Parse Error',
65+
\E_ERROR => 'Error',
66+
\E_CORE_ERROR => 'Core Error',
6767
];
6868

6969
private $loggers = [
70-
E_DEPRECATED => [null, LogLevel::INFO],
71-
E_USER_DEPRECATED => [null, LogLevel::INFO],
72-
E_NOTICE => [null, LogLevel::WARNING],
73-
E_USER_NOTICE => [null, LogLevel::WARNING],
74-
E_STRICT => [null, LogLevel::WARNING],
75-
E_WARNING => [null, LogLevel::WARNING],
76-
E_USER_WARNING => [null, LogLevel::WARNING],
77-
E_COMPILE_WARNING => [null, LogLevel::WARNING],
78-
E_CORE_WARNING => [null, LogLevel::WARNING],
79-
E_USER_ERROR => [null, LogLevel::CRITICAL],
80-
E_RECOVERABLE_ERROR => [null, LogLevel::CRITICAL],
81-
E_COMPILE_ERROR => [null, LogLevel::CRITICAL],
82-
E_PARSE => [null, LogLevel::CRITICAL],
83-
E_ERROR => [null, LogLevel::CRITICAL],
84-
E_CORE_ERROR => [null, LogLevel::CRITICAL],
70+
\E_DEPRECATED => [null, LogLevel::INFO],
71+
\E_USER_DEPRECATED => [null, LogLevel::INFO],
72+
\E_NOTICE => [null, LogLevel::WARNING],
73+
\E_USER_NOTICE => [null, LogLevel::WARNING],
74+
\E_STRICT => [null, LogLevel::WARNING],
75+
\E_WARNING => [null, LogLevel::WARNING],
76+
\E_USER_WARNING => [null, LogLevel::WARNING],
77+
\E_COMPILE_WARNING => [null, LogLevel::WARNING],
78+
\E_CORE_WARNING => [null, LogLevel::WARNING],
79+
\E_USER_ERROR => [null, LogLevel::CRITICAL],
80+
\E_RECOVERABLE_ERROR => [null, LogLevel::CRITICAL],
81+
\E_COMPILE_ERROR => [null, LogLevel::CRITICAL],
82+
\E_PARSE => [null, LogLevel::CRITICAL],
83+
\E_ERROR => [null, LogLevel::CRITICAL],
84+
\E_CORE_ERROR => [null, LogLevel::CRITICAL],
8585
];
8686

8787
private $thrownErrors = 0x1FFF; // E_ALL - E_DEPRECATED - E_USER_DEPRECATED
@@ -154,7 +154,7 @@ public static function register(self $handler = null, $replace = true)
154154
$handler->setExceptionHandler($prev);
155155
}
156156

157-
$handler->throwAt(E_ALL & $handler->thrownErrors, true);
157+
$handler->throwAt(\E_ALL & $handler->thrownErrors, true);
158158

159159
return $handler;
160160
}
@@ -176,7 +176,7 @@ public function __construct(BufferingLogger $bootstrappingLogger = null)
176176
* @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants
177177
* @param bool $replace Whether to replace or not any existing logger
178178
*/
179-
public function setDefaultLogger(LoggerInterface $logger, $levels = E_ALL, $replace = false)
179+
public function setDefaultLogger(LoggerInterface $logger, $levels = \E_ALL, $replace = false)
180180
{
181181
$loggers = [];
182182

@@ -188,7 +188,7 @@ public function setDefaultLogger(LoggerInterface $logger, $levels = E_ALL, $repl
188188
}
189189
} else {
190190
if (null === $levels) {
191-
$levels = E_ALL;
191+
$levels = \E_ALL;
192192
}
193193
foreach ($this->loggers as $type => $log) {
194194
if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) {
@@ -242,7 +242,7 @@ public function setLoggers(array $loggers)
242242

243243
if ($flush) {
244244
foreach ($this->bootstrappingLogger->cleanLogs() as $log) {
245-
$type = $log[2]['exception'] instanceof \ErrorException ? $log[2]['exception']->getSeverity() : E_ERROR;
245+
$type = $log[2]['exception'] instanceof \ErrorException ? $log[2]['exception']->getSeverity() : \E_ERROR;
246246
if (!isset($flush[$type])) {
247247
$this->bootstrappingLogger->log($log[0], $log[1], $log[2]);
248248
} elseif ($this->loggers[$type][0]) {
@@ -280,7 +280,7 @@ public function setExceptionHandler(callable $handler = null)
280280
public function throwAt($levels, $replace = false)
281281
{
282282
$prev = $this->thrownErrors;
283-
$this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
283+
$this->thrownErrors = ($levels | \E_RECOVERABLE_ERROR | \E_USER_ERROR) & ~\E_USER_DEPRECATED & ~\E_DEPRECATED;
284284
if (!$replace) {
285285
$this->thrownErrors |= $prev;
286286
}
@@ -382,15 +382,15 @@ private function reRegister($prev)
382382
*/
383383
public function handleError($type, $message, $file, $line)
384384
{
385-
if (\PHP_VERSION_ID >= 70300 && E_WARNING === $type && '"' === $message[0] && false !== strpos($message, '" targeting switch is equivalent to "break')) {
386-
$type = E_DEPRECATED;
385+
if (\PHP_VERSION_ID >= 70300 && \E_WARNING === $type && '"' === $message[0] && false !== strpos($message, '" targeting switch is equivalent to "break')) {
386+
$type = \E_DEPRECATED;
387387
}
388388

389389
// Level is the current error reporting level to manage silent error.
390390
$level = error_reporting();
391391
$silenced = 0 === ($level & $type);
392392
// Strong errors are not authorized to be silenced.
393-
$level |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
393+
$level |= \E_RECOVERABLE_ERROR | \E_USER_ERROR | \E_DEPRECATED | \E_USER_DEPRECATED;
394394
$log = $this->loggedErrors & $type;
395395
$throw = $this->thrownErrors & $type & $level;
396396
$type &= $level | $this->screamedErrors;
@@ -414,7 +414,7 @@ public function handleError($type, $message, $file, $line)
414414
$context = $e;
415415
}
416416

417-
if (null !== $backtrace && $type & E_ERROR) {
417+
if (null !== $backtrace && $type & \E_ERROR) {
418418
// E_ERROR fatal errors are triggered on HHVM when
419419
// hhvm.error_handling.call_user_handler_on_fatals=1
420420
// which is the way to get their backtrace.
@@ -430,7 +430,7 @@ public function handleError($type, $message, $file, $line)
430430
self::$toStringException = null;
431431
} elseif (!$throw && !($type & $level)) {
432432
if (!isset(self::$silencedErrorCache[$id = $file.':'.$line])) {
433-
$lightTrace = $this->tracedErrors & $type ? $this->cleanTrace(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3), $type, $file, $line, false) : [];
433+
$lightTrace = $this->tracedErrors & $type ? $this->cleanTrace(debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 3), $type, $file, $line, false) : [];
434434
$errorAsException = new SilencedErrorContext($type, $file, $line, $lightTrace);
435435
} elseif (isset(self::$silencedErrorCache[$id][$message])) {
436436
$lightTrace = null;
@@ -469,7 +469,7 @@ public function handleError($type, $message, $file, $line)
469469
}
470470

471471
if ($throw) {
472-
if (\PHP_VERSION_ID < 70400 && E_USER_ERROR & $type) {
472+
if (\PHP_VERSION_ID < 70400 && \E_USER_ERROR & $type) {
473473
for ($i = 1; isset($backtrace[$i]); ++$i) {
474474
if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function'])
475475
&& '__toString' === $backtrace[$i]['function']
@@ -558,7 +558,7 @@ public function handleException($exception, array $error = null)
558558
if (!$exception instanceof \Exception) {
559559
$exception = new FatalThrowableError($exception);
560560
}
561-
$type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR;
561+
$type = $exception instanceof FatalErrorException ? $exception->getSeverity() : \E_ERROR;
562562
$handlerException = null;
563563

564564
if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
@@ -674,7 +674,7 @@ public static function handleFatalError(array $error = null)
674674
// Handled below
675675
}
676676

677-
if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
677+
if ($error && $error['type'] &= \E_PARSE | \E_ERROR | \E_CORE_ERROR | \E_COMPILE_ERROR) {
678678
// Let's not throw anymore but keep logging
679679
$handler->throwAt(0, true);
680680
$trace = isset($error['backtrace']) ? $error['backtrace'] : null;
@@ -716,9 +716,9 @@ public static function handleFatalError(array $error = null)
716716
*/
717717
public static function stackErrors()
718718
{
719-
@trigger_error('Support for stacking errors is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED);
719+
@trigger_error('Support for stacking errors is deprecated since Symfony 3.4 and will be removed in 4.0.', \E_USER_DEPRECATED);
720720

721-
self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
721+
self::$stackedErrorLevels[] = error_reporting(error_reporting() | \E_PARSE | \E_ERROR | \E_CORE_ERROR | \E_COMPILE_ERROR);
722722
}
723723

724724
/**
@@ -728,13 +728,13 @@ public static function stackErrors()
728728
*/
729729
public static function unstackErrors()
730730
{
731-
@trigger_error('Support for unstacking errors is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED);
731+
@trigger_error('Support for unstacking errors is deprecated since Symfony 3.4 and will be removed in 4.0.', \E_USER_DEPRECATED);
732732

733733
$level = array_pop(self::$stackedErrorLevels);
734734

735735
if (null !== $level) {
736736
$errorReportingLevel = error_reporting($level);
737-
if ($errorReportingLevel !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) {
737+
if ($errorReportingLevel !== ($level | \E_PARSE | \E_ERROR | \E_CORE_ERROR | \E_COMPILE_ERROR)) {
738738
// If the user changed the error level, do not overwrite it
739739
error_reporting($errorReportingLevel);
740740
}

Exception/ContextErrorException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct($message, $code, $severity, $filename, $lineno, $con
3333
*/
3434
public function getContext()
3535
{
36-
@trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
36+
@trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0.', __CLASS__), \E_USER_DEPRECATED);
3737

3838
return $this->context;
3939
}

Exception/FatalThrowableError.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public function __construct(\Throwable $e)
2222
{
2323
if ($e instanceof \ParseError) {
2424
$message = 'Parse error: '.$e->getMessage();
25-
$severity = E_PARSE;
25+
$severity = \E_PARSE;
2626
} elseif ($e instanceof \TypeError) {
2727
$message = 'Type error: '.$e->getMessage();
28-
$severity = E_RECOVERABLE_ERROR;
28+
$severity = \E_RECOVERABLE_ERROR;
2929
} else {
3030
$message = $e->getMessage();
31-
$severity = E_ERROR;
31+
$severity = \E_ERROR;
3232
}
3333

3434
\ErrorException::__construct(

ExceptionHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ private function formatPath($path, $line)
377377

378378
if (\is_string($fmt)) {
379379
$i = strpos($f = $fmt, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: \strlen($f);
380-
$fmt = [substr($f, 0, $i)] + preg_split('/&([^>]++)>/', substr($f, $i), -1, PREG_SPLIT_DELIM_CAPTURE);
380+
$fmt = [substr($f, 0, $i)] + preg_split('/&([^>]++)>/', substr($f, $i), -1, \PREG_SPLIT_DELIM_CAPTURE);
381381

382382
for ($i = 1; isset($fmt[$i]); ++$i) {
383383
if (0 === strpos($path, $k = $fmt[$i++])) {
@@ -434,7 +434,7 @@ private function formatArgs(array $args)
434434
*/
435435
private function escapeHtml($str)
436436
{
437-
return htmlspecialchars($str, ENT_COMPAT | ENT_SUBSTITUTE, $this->charset);
437+
return htmlspecialchars($str, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset);
438438
}
439439

440440
private function getSymfonyGhostAsSvg()

0 commit comments

Comments
 (0)