Skip to content

Commit f8e1009

Browse files
derrabusnicolas-grekas
authored andcommitted
Switched to non-null defaults in exception constructors
1 parent 8054d1d commit f8e1009

File tree

44 files changed

+131
-114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+131
-114
lines changed

src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function load($resource, $type = null)
7777
// - this handles the case and prevents the second fatal error
7878
// by triggering an exception beforehand.
7979

80-
throw new LoaderLoadException($resource, null, null, null, $type);
80+
throw new LoaderLoadException($resource, null, 0, null, $type);
8181
}
8282
$this->loading = true;
8383

src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class FileLoaderImportCircularReferenceException extends LoaderLoadException
2020
{
21-
public function __construct(array $resources, int $code = null, \Throwable $previous = null)
21+
public function __construct(array $resources, ?int $code = 0, \Throwable $previous = null)
2222
{
2323
$message = sprintf('Circular reference detected in "%s" ("%s" > "%s").', $this->varToString($resources[0]), implode('" > "', $resources), $resources[0]);
2424

src/Symfony/Component/Config/Exception/FileLoaderLoadException.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
class FileLoaderLoadException extends \Exception
2222
{
2323
/**
24-
* @param string $resource The resource that could not be imported
25-
* @param string $sourceResource The original resource importing the new resource
26-
* @param int $code The error code
27-
* @param \Throwable $previous A previous exception
28-
* @param string $type The type of resource
24+
* @param string $resource The resource that could not be imported
25+
* @param string|null $sourceResource The original resource importing the new resource
26+
* @param int|null $code The error code
27+
* @param \Throwable|null $previous A previous exception
28+
* @param string|null $type The type of resource
2929
*/
30-
public function __construct(string $resource, string $sourceResource = null, int $code = null, \Throwable $previous = null, string $type = null)
30+
public function __construct(string $resource, string $sourceResource = null, ?int $code = 0, \Throwable $previous = null, string $type = null)
3131
{
3232
$message = '';
3333
if ($previous) {

src/Symfony/Component/Config/Loader/DelegatingLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(LoaderResolverInterface $resolver)
3434
public function load($resource, $type = null)
3535
{
3636
if (false === $loader = $this->resolver->resolve($resource, $type)) {
37-
throw new LoaderLoadException($resource, null, null, null, $type);
37+
throw new LoaderLoadException($resource, null, 0, null, $type);
3838
}
3939

4040
return $loader->load($resource, $type);

src/Symfony/Component/Config/Loader/FileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private function doImport($resource, string $type = null, bool $ignoreErrors = f
177177
throw $e;
178178
}
179179

180-
throw new LoaderLoadException($resource, $sourceResource, null, $e, $type);
180+
throw new LoaderLoadException($resource, $sourceResource, 0, $e, $type);
181181
}
182182
}
183183

src/Symfony/Component/Config/Loader/Loader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function resolve($resource, $type = null)
7070
$loader = null === $this->resolver ? false : $this->resolver->resolve($resource, $type);
7171

7272
if (false === $loader) {
73-
throw new LoaderLoadException($resource, null, null, null, $type);
73+
throw new LoaderLoadException($resource, null, 0, null, $type);
7474
}
7575

7676
return $loader;

src/Symfony/Component/Config/Tests/Exception/LoaderLoadExceptionTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public function testMessageCannotLoadResource()
2424

2525
public function testMessageCannotLoadResourceWithType()
2626
{
27-
$exception = new LoaderLoadException('resource', null, null, null, 'foobar');
27+
$exception = new LoaderLoadException('resource', null, 0, null, 'foobar');
2828
$this->assertEquals('Cannot load resource "resource". Make sure there is a loader supporting the "foobar" type.', $exception->getMessage());
2929
}
3030

3131
public function testMessageCannotLoadResourceWithAnnotationType()
3232
{
33-
$exception = new LoaderLoadException('resource', null, null, null, 'annotation');
33+
$exception = new LoaderLoadException('resource', null, 0, null, 'annotation');
3434
$this->assertEquals('Cannot load resource "resource". Make sure annotations are installed and enabled.', $exception->getMessage());
3535
}
3636

@@ -56,7 +56,7 @@ public function testMessageHasPreviousErrorWithDotAndUnableToLoad()
5656
$exception = new LoaderLoadException(
5757
'resource',
5858
null,
59-
null,
59+
0,
6060
new \Exception('There was a previous error with an ending dot.')
6161
);
6262
$this->assertEquals(
@@ -70,7 +70,7 @@ public function testMessageHasPreviousErrorWithoutDotAndUnableToLoad()
7070
$exception = new LoaderLoadException(
7171
'resource',
7272
null,
73-
null,
73+
0,
7474
new \Exception('There was a previous error with no ending dot')
7575
);
7676
$this->assertEquals(
@@ -84,7 +84,7 @@ public function testMessageHasPreviousErrorAndUnableToLoadBundle()
8484
$exception = new LoaderLoadException(
8585
'@resource',
8686
null,
87-
null,
87+
0,
8888
new \Exception('There was a previous error with an ending dot.')
8989
);
9090
$this->assertEquals(

src/Symfony/Component/Console/Exception/CommandNotFoundException.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ class CommandNotFoundException extends \InvalidArgumentException implements Exce
2121
private $alternatives;
2222

2323
/**
24-
* @param string $message Exception message to throw
25-
* @param array $alternatives List of similar defined names
26-
* @param int $code Exception code
27-
* @param \Throwable $previous Previous exception used for the exception chaining
24+
* @param string $message Exception message to throw
25+
* @param string[] $alternatives List of similar defined names
26+
* @param int $code Exception code
27+
* @param \Throwable|null $previous Previous exception used for the exception chaining
2828
*/
2929
public function __construct(string $message, array $alternatives = [], int $code = 0, \Throwable $previous = null)
3030
{
@@ -34,7 +34,7 @@ public function __construct(string $message, array $alternatives = [], int $code
3434
}
3535

3636
/**
37-
* @return array A list of similar defined names
37+
* @return string[] A list of similar defined names
3838
*/
3939
public function getAlternatives()
4040
{

src/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
class AccessDeniedHttpException extends HttpException
1919
{
2020
/**
21-
* @param string $message The internal exception message
22-
* @param \Throwable $previous The previous exception
23-
* @param int $code The internal exception code
21+
* @param string|null $message The internal exception message
22+
* @param \Throwable|null $previous The previous exception
23+
* @param int $code The internal exception code
2424
*/
25-
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
25+
public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = [])
2626
{
2727
parent::__construct(403, $message, $previous, $headers, $code);
2828
}

src/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
class BadRequestHttpException extends HttpException
1818
{
1919
/**
20-
* @param string $message The internal exception message
21-
* @param \Throwable $previous The previous exception
22-
* @param int $code The internal exception code
20+
* @param string|null $message The internal exception message
21+
* @param \Throwable|null $previous The previous exception
22+
* @param int $code The internal exception code
2323
*/
24-
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
24+
public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = [])
2525
{
2626
parent::__construct(400, $message, $previous, $headers, $code);
2727
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy