From d516a0a9c133557b773f3289b2e00c1b1b14e68f Mon Sep 17 00:00:00 2001 From: Tobias Weichart Date: Tue, 30 Jul 2019 11:59:28 +0100 Subject: [PATCH 1/3] added type declarations where possible * added type declarations for method parameters * added type declarations for return types * removed docBlocks where replaceable by type declarations * replaced void returns by null where necessary * replaced manual exceptionHandler switch through setter * added throw documentation to docBlock --- .../ErrorHandler/BufferingLogger.php | 4 +- src/Symfony/Component/ErrorHandler/Debug.php | 4 +- .../ErrorHandler/DebugClassLoader.php | 38 ++++++++-------- .../Component/ErrorHandler/ErrorHandler.php | 43 +++++++------------ .../Exception/FatalErrorException.php | 2 +- .../Exception/SilencedErrorContext.php | 10 ++--- .../ClassNotFoundFatalErrorHandler.php | 7 +-- .../UndefinedFunctionFatalErrorHandler.php | 8 ++-- .../UndefinedMethodFatalErrorHandler.php | 4 +- .../Fixtures/LoggerThatSetAnErrorHandler.php | 2 +- 10 files changed, 54 insertions(+), 68 deletions(-) diff --git a/src/Symfony/Component/ErrorHandler/BufferingLogger.php b/src/Symfony/Component/ErrorHandler/BufferingLogger.php index fef10d16e5a16..49c838f272cd0 100644 --- a/src/Symfony/Component/ErrorHandler/BufferingLogger.php +++ b/src/Symfony/Component/ErrorHandler/BufferingLogger.php @@ -22,12 +22,12 @@ class BufferingLogger extends AbstractLogger { private $logs = []; - public function log($level, $message, array $context = []) + public function log($level, $message, array $context = []): void { $this->logs[] = [$level, $message, $context]; } - public function cleanLogs() + public function cleanLogs(): array { $logs = $this->logs; $this->logs = []; diff --git a/src/Symfony/Component/ErrorHandler/Debug.php b/src/Symfony/Component/ErrorHandler/Debug.php index e3bb55c0a0741..8d3114896d1b9 100644 --- a/src/Symfony/Component/ErrorHandler/Debug.php +++ b/src/Symfony/Component/ErrorHandler/Debug.php @@ -25,10 +25,8 @@ class Debug * * This method registers an error handler and an exception handler. * - * @param int $errorReportingLevel The level of error reporting you want - * @param bool $displayErrors Whether to display errors (for development) or just log them (for production) */ - public static function enable($errorReportingLevel = E_ALL, $displayErrors = true) + public static function enable(int $errorReportingLevel = E_ALL, bool $displayErrors = true): void { if (static::$enabled) { return; diff --git a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php index e1108a51bbc7a..1b6c84541a0a4 100644 --- a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php +++ b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php @@ -75,7 +75,7 @@ public function __construct(callable $classLoader) * * @return callable The wrapped class loader */ - public function getClassLoader() + public function getClassLoader(): callable { return $this->classLoader; } @@ -83,7 +83,7 @@ public function getClassLoader() /** * Wraps all autoloaders. */ - public static function enable() + public static function enable(): void { // Ensures we don't hit https://bugs.php.net/42098 class_exists('Symfony\Component\ErrorHandler\ErrorHandler'); @@ -109,7 +109,7 @@ class_exists('Psr\Log\LogLevel'); /** * Disables the wrapping. */ - public static function disable() + public static function disable(): void { if (!\is_array($functions = spl_autoload_functions())) { return; @@ -128,22 +128,17 @@ public static function disable() } } - /** - * @return string|null - */ - public function findFile($class) + public function findFile(string $class): ?string { - return $this->isFinder ? $this->classLoader[0]->findFile($class) ?: null : null; + return $this->isFinder ? ( $this->classLoader[0]->findFile($class) ?: null ) : null; } /** * Loads the given class or interface. * - * @param string $class The name of the class - * * @throws \RuntimeException */ - public function loadClass($class) + public function loadClass(string $class): void { $e = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR); @@ -170,7 +165,7 @@ public function loadClass($class) $this->checkClass($class, $file); } - private function checkClass($class, $file = null) + private function checkClass(string $class, $file = null): void { $exists = null === $file || class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false); @@ -218,7 +213,7 @@ private function checkClass($class, $file = null) } } - public function checkAnnotations(\ReflectionClass $refl, $class) + public function checkAnnotations(\ReflectionClass $refl, string $class): array { $deprecations = []; @@ -395,7 +390,7 @@ public function checkAnnotations(\ReflectionClass $refl, $class) return $deprecations; } - public function checkCase(\ReflectionClass $refl, $file, $class) + public function checkCase(\ReflectionClass $refl, $file, string $class): ?array { $real = explode('\\', $class.strrchr($file, '.')); $tail = explode(\DIRECTORY_SEPARATOR, str_replace('/', \DIRECTORY_SEPARATOR, $file)); @@ -411,7 +406,7 @@ public function checkCase(\ReflectionClass $refl, $file, $class) array_splice($tail, 0, $i + 1); if (!$tail) { - return; + return null; } $tail = \DIRECTORY_SEPARATOR.implode(\DIRECTORY_SEPARATOR, $tail); @@ -427,12 +422,13 @@ public function checkCase(\ReflectionClass $refl, $file, $class) ) { return [substr($tail, -$tailLen + 1), substr($real, -$tailLen + 1), substr($real, 0, -$tailLen + 1)]; } + return null; } /** * `realpath` on MacOSX doesn't normalize the case of characters. */ - private function darwinRealpath($real) + private function darwinRealpath($real): string { $i = 1 + strrpos($real, '/'); $file = substr($real, $i); @@ -504,18 +500,20 @@ private function darwinRealpath($real) * * @return string[] */ - private function getOwnInterfaces($class, $parent) + private function getOwnInterfaces(string $class, $parent): array { $ownInterfaces = class_implements($class, false); + if ($ownInterfaces === false){ + return []; + } if ($parent) { foreach (class_implements($parent, false) as $interface) { unset($ownInterfaces[$interface]); } } - - foreach ($ownInterfaces as $interface) { - foreach (class_implements($interface) as $interface) { + foreach ($ownInterfaces as $ownInterface) { + foreach (class_implements($ownInterface) as $interface) { unset($ownInterfaces[$interface]); } } diff --git a/src/Symfony/Component/ErrorHandler/ErrorHandler.php b/src/Symfony/Component/ErrorHandler/ErrorHandler.php index fa54ac90ac588..730a104dfad38 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/ErrorHandler.php @@ -106,12 +106,8 @@ class ErrorHandler /** * Registers the error handler. * - * @param self|null $handler The handler to register - * @param bool $replace Whether to replace or not any existing handler - * - * @return self The registered error handler */ - public static function register(self $handler = null, $replace = true) + public static function register(self $handler = null, bool $replace = true): self { if (null === self::$reservedMemory) { self::$reservedMemory = str_repeat('x', 10240); @@ -175,7 +171,7 @@ public function __construct(BufferingLogger $bootstrappingLogger = null) * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants * @param bool $replace Whether to replace or not any existing logger */ - public function setDefaultLogger(LoggerInterface $logger, $levels = E_ALL, $replace = false) + public function setDefaultLogger(LoggerInterface $logger, $levels = E_ALL, bool $replace = false): void { $loggers = []; @@ -209,7 +205,7 @@ public function setDefaultLogger(LoggerInterface $logger, $levels = E_ALL, $repl * * @throws \InvalidArgumentException */ - public function setLoggers(array $loggers) + public function setLoggers(array $loggers): array { $prevLogged = $this->loggedErrors; $prev = $this->loggers; @@ -260,7 +256,7 @@ public function setLoggers(array $loggers) * * @return callable|null The previous exception handler */ - public function setExceptionHandler(callable $handler = null) + public function setExceptionHandler(?callable $handler = null): ?callable { $prev = $this->exceptionHandler; $this->exceptionHandler = $handler; @@ -276,7 +272,7 @@ public function setExceptionHandler(callable $handler = null) * * @return int The previous value */ - public function throwAt($levels, $replace = false) + public function throwAt($levels, bool $replace = false): int { $prev = $this->thrownErrors; $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED; @@ -296,7 +292,7 @@ public function throwAt($levels, $replace = false) * * @return int The previous value */ - public function scopeAt($levels, $replace = false) + public function scopeAt($levels, bool $replace = false): int { $prev = $this->scopedErrors; $this->scopedErrors = (int) $levels; @@ -315,7 +311,7 @@ public function scopeAt($levels, $replace = false) * * @return int The previous value */ - public function traceAt($levels, $replace = false) + public function traceAt($levels, bool $replace = false): int { $prev = $this->tracedErrors; $this->tracedErrors = (int) $levels; @@ -334,7 +330,7 @@ public function traceAt($levels, $replace = false) * * @return int The previous value */ - public function screamAt($levels, $replace = false) + public function screamAt($levels, bool $replace = false): int { $prev = $this->screamedErrors; $this->screamedErrors = (int) $levels; @@ -348,7 +344,7 @@ public function screamAt($levels, $replace = false) /** * Re-registers as a PHP error handler if levels changed. */ - private function reRegister($prev) + private function reRegister($prev): void { if ($prev !== $this->thrownErrors | $this->loggedErrors) { $handler = set_error_handler('var_dump'); @@ -368,18 +364,12 @@ private function reRegister($prev) /** * Handles errors by filtering then logging them according to the configured bit fields. * - * @param int $type One of the E_* constants - * @param string $message - * @param string $file - * @param int $line - * - * @return bool Returns false when no handling happens so that the PHP engine can handle the error itself - * * @throws \ErrorException When $this->thrownErrors requests so + * @throws \Throwable * * @internal */ - public function handleError($type, $message, $file, $line) + public function handleError(int $type, string $message, string $file, int $line): ?bool { // @deprecated to be removed in Symfony 5.0 if (\PHP_VERSION_ID >= 70300 && $message && '"' === $message[0] && 0 === strpos($message, '"continue') && preg_match('/^"continue(?: \d++)?" targeting switch is equivalent to "break(?: \d++)?"\. Did you mean to use "continue(?: \d++)?"\?$/', $message)) { @@ -442,7 +432,7 @@ public function handleError($type, $message, $file, $line) self::$silencedErrorCache[$id][$message] = $errorAsException; } if (null === $lightTrace) { - return; + return null; } } else { $errorAsException = new \ErrorException($logMessage, 0, $type, $file, $line); @@ -571,8 +561,7 @@ public function handleException($exception, array $error = null) } } } - $exceptionHandler = $this->exceptionHandler; - $this->exceptionHandler = null; + $exceptionHandler = $this->setExceptionHandler(); try { if (null !== $exceptionHandler) { return $exceptionHandler($exception); @@ -594,7 +583,7 @@ public function handleException($exception, array $error = null) * * @internal */ - public static function handleFatalError(array $error = null) + public static function handleFatalError(array $error = null): void { if (null === self::$reservedMemory) { return; @@ -674,7 +663,7 @@ public static function handleFatalError(array $error = null) * * @return FatalErrorHandlerInterface[] An array of FatalErrorHandlerInterface */ - protected function getFatalErrorHandlers() + protected function getFatalErrorHandlers(): array { return [ new UndefinedFunctionFatalErrorHandler(), @@ -686,7 +675,7 @@ protected function getFatalErrorHandlers() /** * Cleans the trace by removing function arguments and the frames added by the error handler and DebugClassLoader. */ - private function cleanTrace($backtrace, $type, $file, $line, $throw) + private function cleanTrace(array $backtrace, int $type, string $file, int $line, bool $throw): array { $lightTrace = $backtrace; diff --git a/src/Symfony/Component/ErrorHandler/Exception/FatalErrorException.php b/src/Symfony/Component/ErrorHandler/Exception/FatalErrorException.php index 4269356d5724d..3ea04e88f2209 100644 --- a/src/Symfony/Component/ErrorHandler/Exception/FatalErrorException.php +++ b/src/Symfony/Component/ErrorHandler/Exception/FatalErrorException.php @@ -68,7 +68,7 @@ public function __construct(string $message, int $code, int $severity, string $f } } - protected function setTrace($trace) + protected function setTrace($trace): void { $traceReflector = new \ReflectionProperty('Exception', 'trace'); $traceReflector->setAccessible(true); diff --git a/src/Symfony/Component/ErrorHandler/Exception/SilencedErrorContext.php b/src/Symfony/Component/ErrorHandler/Exception/SilencedErrorContext.php index 2c4ae69db419d..bff45831302db 100644 --- a/src/Symfony/Component/ErrorHandler/Exception/SilencedErrorContext.php +++ b/src/Symfony/Component/ErrorHandler/Exception/SilencedErrorContext.php @@ -34,27 +34,27 @@ public function __construct(int $severity, string $file, int $line, array $trace $this->count = $count; } - public function getSeverity() + public function getSeverity(): int { return $this->severity; } - public function getFile() + public function getFile(): string { return $this->file; } - public function getLine() + public function getLine(): int { return $this->line; } - public function getTrace() + public function getTrace(): array { return $this->trace; } - public function JsonSerialize() + public function JsonSerialize(): array { return [ 'severity' => $this->severity, diff --git a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php index b59b0d4517375..ce0c2dd6daa44 100644 --- a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php @@ -27,17 +27,17 @@ class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface /** * {@inheritdoc} */ - public function handleError(array $error, FatalErrorException $exception) + public function handleError(array $error, FatalErrorException $exception): ?ClassNotFoundException { $messageLen = \strlen($error['message']); $notFoundSuffix = '\' not found'; $notFoundSuffixLen = \strlen($notFoundSuffix); if ($notFoundSuffixLen > $messageLen) { - return; + return null; } if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { - return; + return null; } foreach (['class', 'interface', 'trait'] as $typeName) { @@ -71,6 +71,7 @@ public function handleError(array $error, FatalErrorException $exception) return new ClassNotFoundException($message, $exception); } + return null; } /** diff --git a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php index 9e3affb14dbac..eafe79e052cd1 100644 --- a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php @@ -24,23 +24,23 @@ class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface /** * {@inheritdoc} */ - public function handleError(array $error, FatalErrorException $exception) + public function handleError(array $error, FatalErrorException $exception): ?UndefinedFunctionException { $messageLen = \strlen($error['message']); $notFoundSuffix = '()'; $notFoundSuffixLen = \strlen($notFoundSuffix); if ($notFoundSuffixLen > $messageLen) { - return; + return null; } if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { - return; + return null; } $prefix = 'Call to undefined function '; $prefixLen = \strlen($prefix); if (0 !== strpos($error['message'], $prefix)) { - return; + return null; } $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen); diff --git a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php index 49de27446945a..ab20c402ac9b7 100644 --- a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php @@ -24,11 +24,11 @@ class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface /** * {@inheritdoc} */ - public function handleError(array $error, FatalErrorException $exception) + public function handleError(array $error, FatalErrorException $exception): ?UndefinedMethodException { preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches); if (!$matches) { - return; + return null; } $className = $matches[1]; diff --git a/src/Symfony/Component/ErrorHandler/Tests/Fixtures/LoggerThatSetAnErrorHandler.php b/src/Symfony/Component/ErrorHandler/Tests/Fixtures/LoggerThatSetAnErrorHandler.php index eaf41582a32f0..7938c30e00315 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/Fixtures/LoggerThatSetAnErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/Tests/Fixtures/LoggerThatSetAnErrorHandler.php @@ -6,7 +6,7 @@ class LoggerThatSetAnErrorHandler extends BufferingLogger { - public function log($level, $message, array $context = []) + public function log($level, $message, array $context = []): void { set_error_handler('is_string'); parent::log($level, $message, $context); From 8c35e643b59400febfc46c2c34f0e9358758f387 Mon Sep 17 00:00:00 2001 From: Tobias Weichart Date: Tue, 30 Jul 2019 12:10:04 +0100 Subject: [PATCH 2/3] reverted return types for fatal error handler --- .../FatalErrorHandler/ClassNotFoundFatalErrorHandler.php | 7 +++---- .../UndefinedFunctionFatalErrorHandler.php | 8 ++++---- .../UndefinedMethodFatalErrorHandler.php | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php index ce0c2dd6daa44..b59b0d4517375 100644 --- a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php @@ -27,17 +27,17 @@ class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface /** * {@inheritdoc} */ - public function handleError(array $error, FatalErrorException $exception): ?ClassNotFoundException + public function handleError(array $error, FatalErrorException $exception) { $messageLen = \strlen($error['message']); $notFoundSuffix = '\' not found'; $notFoundSuffixLen = \strlen($notFoundSuffix); if ($notFoundSuffixLen > $messageLen) { - return null; + return; } if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { - return null; + return; } foreach (['class', 'interface', 'trait'] as $typeName) { @@ -71,7 +71,6 @@ public function handleError(array $error, FatalErrorException $exception): ?Clas return new ClassNotFoundException($message, $exception); } - return null; } /** diff --git a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php index eafe79e052cd1..9e3affb14dbac 100644 --- a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php @@ -24,23 +24,23 @@ class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface /** * {@inheritdoc} */ - public function handleError(array $error, FatalErrorException $exception): ?UndefinedFunctionException + public function handleError(array $error, FatalErrorException $exception) { $messageLen = \strlen($error['message']); $notFoundSuffix = '()'; $notFoundSuffixLen = \strlen($notFoundSuffix); if ($notFoundSuffixLen > $messageLen) { - return null; + return; } if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { - return null; + return; } $prefix = 'Call to undefined function '; $prefixLen = \strlen($prefix); if (0 !== strpos($error['message'], $prefix)) { - return null; + return; } $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen); diff --git a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php index ab20c402ac9b7..49de27446945a 100644 --- a/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/FatalErrorHandler/UndefinedMethodFatalErrorHandler.php @@ -24,11 +24,11 @@ class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface /** * {@inheritdoc} */ - public function handleError(array $error, FatalErrorException $exception): ?UndefinedMethodException + public function handleError(array $error, FatalErrorException $exception) { preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches); if (!$matches) { - return null; + return; } $className = $matches[1]; From 82168f18c5a38ded856326d01f98eddc23a39c6f Mon Sep 17 00:00:00 2001 From: Tobias Weichart Date: Tue, 30 Jul 2019 12:12:31 +0100 Subject: [PATCH 3/3] fixed coding standard errors --- src/Symfony/Component/ErrorHandler/Debug.php | 1 - src/Symfony/Component/ErrorHandler/DebugClassLoader.php | 5 +++-- src/Symfony/Component/ErrorHandler/ErrorHandler.php | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/ErrorHandler/Debug.php b/src/Symfony/Component/ErrorHandler/Debug.php index 8d3114896d1b9..6f75dbf60e38a 100644 --- a/src/Symfony/Component/ErrorHandler/Debug.php +++ b/src/Symfony/Component/ErrorHandler/Debug.php @@ -24,7 +24,6 @@ class Debug * Enables the debug tools. * * This method registers an error handler and an exception handler. - * */ public static function enable(int $errorReportingLevel = E_ALL, bool $displayErrors = true): void { diff --git a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php index 1b6c84541a0a4..d3aff3d97b565 100644 --- a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php +++ b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php @@ -130,7 +130,7 @@ public static function disable(): void public function findFile(string $class): ?string { - return $this->isFinder ? ( $this->classLoader[0]->findFile($class) ?: null ) : null; + return $this->isFinder ? ($this->classLoader[0]->findFile($class) ?: null) : null; } /** @@ -422,6 +422,7 @@ public function checkCase(\ReflectionClass $refl, $file, string $class): ?array ) { return [substr($tail, -$tailLen + 1), substr($real, -$tailLen + 1), substr($real, 0, -$tailLen + 1)]; } + return null; } @@ -503,7 +504,7 @@ private function darwinRealpath($real): string private function getOwnInterfaces(string $class, $parent): array { $ownInterfaces = class_implements($class, false); - if ($ownInterfaces === false){ + if (false === $ownInterfaces) { return []; } diff --git a/src/Symfony/Component/ErrorHandler/ErrorHandler.php b/src/Symfony/Component/ErrorHandler/ErrorHandler.php index 730a104dfad38..c0be313624a09 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/ErrorHandler.php @@ -105,7 +105,6 @@ class ErrorHandler /** * Registers the error handler. - * */ public static function register(self $handler = null, bool $replace = true): self {