Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[5.0] [Debug] Add parameter type-hints where possible #32217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/Debug/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Debug
* @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)
{
if (static::$enabled) {
return;
Expand Down
8 changes: 3 additions & 5 deletions 8 src/Symfony/Component/Debug/DebugClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,19 @@ public static function disable()
}

/**
* @return string|null
* @param string $class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong. You must not remove the the doc for the return type (and adding the doc for the param is useless now, as it duplicates the typehint)

*/
public function findFile($class)
public function findFile(string $class)
{
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)
{
$e = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);

Expand Down
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/Debug/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,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)
{
$loggers = [];

Expand Down Expand Up @@ -526,7 +526,7 @@ public function handleError($type, $message, $file, $line)
*
* @internal
*/
public function handleException($exception, array $error = null)
public function handleException(\Throwable $exception, array $error = null)
{
if (null === $error) {
self::$exitCode = 255;
Expand Down
16 changes: 8 additions & 8 deletions 16 src/Symfony/Component/Debug/Exception/FlattenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function getStatusCode()
/**
* @return $this
*/
public function setStatusCode($code)
public function setStatusCode(int $code)
{
$this->statusCode = $code;

Expand Down Expand Up @@ -133,7 +133,7 @@ public function getClass()
/**
* @return $this
*/
public function setClass($class)
public function setClass(string $class)
{
$this->class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class;

Expand All @@ -148,7 +148,7 @@ public function getFile()
/**
* @return $this
*/
public function setFile($file)
public function setFile(string $file)
{
$this->file = $file;

Expand All @@ -163,7 +163,7 @@ public function getLine()
/**
* @return $this
*/
public function setLine($line)
public function setLine(int $line)
{
$this->line = $line;

Expand All @@ -178,7 +178,7 @@ public function getMessage()
/**
* @return $this
*/
public function setMessage($message)
public function setMessage(string $message)
{
if (false !== strpos($message, "class@anonymous\0")) {
$message = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
Expand All @@ -199,7 +199,7 @@ public function getCode()
/**
* @return $this
*/
public function setCode($code)
public function setCode(int $code)
{
$this->code = $code;

Expand Down Expand Up @@ -257,7 +257,7 @@ public function setTraceFromThrowable(\Throwable $throwable)
/**
* @return $this
*/
public function setTrace($trace, $file, $line)
public function setTrace(array $trace, string $file, int $line)
{
$this->trace = [];
$this->trace[] = [
Expand Down Expand Up @@ -294,7 +294,7 @@ public function setTrace($trace, $file, $line)
return $this;
}

private function flattenArgs($args, $level = 0, &$count = 0)
private function flattenArgs(array $args, int $level = 0, int &$count = 0)
{
$result = [];
foreach ($args as $key => $value) {
Expand Down
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/Debug/ExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ public function __construct(bool $debug = true, string $charset = null, $fileLin
*
* @param bool $debug Enable/disable debug mode, where the stack trace is displayed
* @param string|null $charset The charset used by exception messages
* @param string|null $fileLinkFormat The IDE link template
* @param string|FileLinkFormatter|null $fileLinkFormat The IDE link template
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be added in older branches

*
* @return static
*/
public static function register($debug = true, $charset = null, $fileLinkFormat = null)
public static function register(bool $debug = true, string $charset = null, $fileLinkFormat = null)
{
$handler = new static($debug, $charset, $fileLinkFormat);

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.