Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b0e323

Browse files
author
Matthew Smeets
committed
[Debug] Add scalar typehints where possible
1 parent c10ad18 commit 6b0e323

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

src/Symfony/Component/Debug/Debug.php

Lines changed: 1 addition & 1 deletion
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(int $errorReportingLevel = E_ALL, bool $displayErrors = true)
3232
{
3333
if (static::$enabled) {
3434
return;

src/Symfony/Component/Debug/DebugClassLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public static function disable()
131131
/**
132132
* @return string|null
133133
*/
134-
public function findFile($class)
134+
public function findFile(string $class = null)
135135
{
136136
return $this->isFinder ? $this->classLoader[0]->findFile($class) ?: null : null;
137137
}
@@ -143,7 +143,7 @@ public function findFile($class)
143143
*
144144
* @throws \RuntimeException
145145
*/
146-
public function loadClass($class)
146+
public function loadClass(string $class)
147147
{
148148
$e = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
149149

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class ErrorHandler
112112
*
113113
* @return self The registered error handler
114114
*/
115-
public static function register(self $handler = null, $replace = true): self
115+
public static function register(self $handler = null, bool $replace = true): self
116116
{
117117
if (null === self::$reservedMemory) {
118118
self::$reservedMemory = str_repeat('x', 10240);
@@ -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, bool $replace = false)
180180
{
181181
$loggers = [];
182182

@@ -277,7 +277,7 @@ public function setExceptionHandler(callable $handler = null): ?callable
277277
*
278278
* @return int The previous value
279279
*/
280-
public function throwAt($levels, $replace = false): int
280+
public function throwAt($levels, bool $replace = false): int
281281
{
282282
$prev = $this->thrownErrors;
283283
$this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
@@ -297,7 +297,7 @@ public function throwAt($levels, $replace = false): int
297297
*
298298
* @return int The previous value
299299
*/
300-
public function scopeAt($levels, $replace = false): int
300+
public function scopeAt($levels, bool $replace = false): int
301301
{
302302
$prev = $this->scopedErrors;
303303
$this->scopedErrors = (int) $levels;
@@ -316,7 +316,7 @@ public function scopeAt($levels, $replace = false): int
316316
*
317317
* @return int The previous value
318318
*/
319-
public function traceAt($levels, $replace = false): int
319+
public function traceAt($levels, bool $replace = false): int
320320
{
321321
$prev = $this->tracedErrors;
322322
$this->tracedErrors = (int) $levels;
@@ -335,7 +335,7 @@ public function traceAt($levels, $replace = false): int
335335
*
336336
* @return int The previous value
337337
*/
338-
public function screamAt($levels, $replace = false): int
338+
public function screamAt($levels, bool $replace = false): int
339339
{
340340
$prev = $this->screamedErrors;
341341
$this->screamedErrors = (int) $levels;
@@ -516,7 +516,7 @@ public function handleError(int $type, string $message, string $file, int $line)
516516
*
517517
* @internal
518518
*/
519-
public function handleException($exception, array $error = null)
519+
public function handleException(\Throwable $exception, array $error = null)
520520
{
521521
if (null === $error) {
522522
self::$exitCode = 255;

src/Symfony/Component/Debug/Exception/FlattenException.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function getStatusCode()
9494
/**
9595
* @return $this
9696
*/
97-
public function setStatusCode($code)
97+
public function setStatusCode(int $code)
9898
{
9999
$this->statusCode = $code;
100100

@@ -124,7 +124,7 @@ public function getClass()
124124
/**
125125
* @return $this
126126
*/
127-
public function setClass($class)
127+
public function setClass(string $class)
128128
{
129129
$this->class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class;
130130

@@ -139,7 +139,7 @@ public function getFile()
139139
/**
140140
* @return $this
141141
*/
142-
public function setFile($file)
142+
public function setFile(string $file)
143143
{
144144
$this->file = $file;
145145

@@ -154,7 +154,7 @@ public function getLine()
154154
/**
155155
* @return $this
156156
*/
157-
public function setLine($line)
157+
public function setLine(int $line)
158158
{
159159
$this->line = $line;
160160

@@ -169,7 +169,7 @@ public function getMessage()
169169
/**
170170
* @return $this
171171
*/
172-
public function setMessage($message)
172+
public function setMessage(string $message)
173173
{
174174
if (false !== strpos($message, "class@anonymous\0")) {
175175
$message = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
@@ -190,7 +190,7 @@ public function getCode()
190190
/**
191191
* @return $this
192192
*/
193-
public function setCode($code)
193+
public function setCode(int $code)
194194
{
195195
$this->code = $code;
196196

@@ -238,7 +238,7 @@ public function setTraceFromThrowable(\Throwable $throwable)
238238
/**
239239
* @return $this
240240
*/
241-
public function setTrace($trace, $file, $line)
241+
public function setTrace(array $trace, string $file, int $line)
242242
{
243243
$this->trace = [];
244244
$this->trace[] = [
@@ -275,7 +275,7 @@ public function setTrace($trace, $file, $line)
275275
return $this;
276276
}
277277

278-
private function flattenArgs($args, $level = 0, &$count = 0)
278+
private function flattenArgs(array $args, int $level = 0, int &$count = 0)
279279
{
280280
$result = [];
281281
foreach ($args as $key => $value) {

src/Symfony/Component/Debug/ExceptionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __construct(bool $debug = true, string $charset = null, $fileLin
6464
*
6565
* @return static
6666
*/
67-
public static function register($debug = true, $charset = null, $fileLinkFormat = null)
67+
public static function register(bool $debug = true, string $charset = null, string $fileLinkFormat = null)
6868
{
6969
$handler = new static($debug, $charset, $fileLinkFormat);
7070

0 commit comments

Comments
 (0)