Skip to content

Commit 78aa6be

Browse files
authored
[PHP 8.4] Fixes for implicit nullability deprecation (#337)
Fixes all issues that emit deprecation notices on PHP 8.4 for implicit nullable parameter type declarations. See: - [RFC](https://wiki.php.net/rfc/deprecate-implicitly-nullable-types) - [PHP 8.4: Implicitly nullable parameter declarations deprecated](https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated)
1 parent 9eb17b7 commit 78aa6be

File tree

7 files changed

+99
-99
lines changed

7 files changed

+99
-99
lines changed

lib/Assert/Assert.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ abstract class Assert
4242
* The assertion chain can be stateful, that means be careful when you reuse
4343
* it. You should never pass around the chain.
4444
*/
45-
public static function that($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
45+
public static function that($value, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
4646
{
4747
$assertionChain = new AssertionChain($value, $defaultMessage, $defaultPropertyPath);
4848

@@ -55,7 +55,7 @@ public static function that($value, $defaultMessage = null, string $defaultPrope
5555
* @param mixed $values
5656
* @param string|callable|null $defaultMessage
5757
*/
58-
public static function thatAll($values, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
58+
public static function thatAll($values, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
5959
{
6060
return static::that($values, $defaultMessage, $defaultPropertyPath)->all();
6161
}
@@ -66,7 +66,7 @@ public static function thatAll($values, $defaultMessage = null, string $defaultP
6666
* @param mixed $value
6767
* @param string|callable|null $defaultMessage
6868
*/
69-
public static function thatNullOr($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
69+
public static function thatNullOr($value, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
7070
{
7171
return static::that($value, $defaultMessage, $defaultPropertyPath)->nullOr();
7272
}

lib/Assert/Assertion.php

Lines changed: 89 additions & 89 deletions
Large diffs are not rendered by default.

lib/Assert/AssertionChain.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class AssertionChain
151151
* @param mixed $value
152152
* @param string|callable|null $defaultMessage
153153
*/
154-
public function __construct($value, $defaultMessage = null, string $defaultPropertyPath = null)
154+
public function __construct($value, $defaultMessage = null, ?string $defaultPropertyPath = null)
155155
{
156156
$this->value = $value;
157157
$this->defaultMessage = $defaultMessage;

lib/Assert/InvalidArgumentException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class InvalidArgumentException extends \InvalidArgumentException implements Asse
3131
*/
3232
private $constraints;
3333

34-
public function __construct($message, $code, string $propertyPath = null, $value = null, array $constraints = [])
34+
public function __construct($message, $code, ?string $propertyPath = null, $value = null, array $constraints = [])
3535
{
3636
parent::__construct($message, $code);
3737

lib/Assert/LazyAssertion.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class LazyAssertion
133133
*
134134
* @return static
135135
*/
136-
public function that($value, string $propertyPath = null, $defaultMessage = null)
136+
public function that($value, ?string $propertyPath = null, $defaultMessage = null)
137137
{
138138
$this->currentChainFailed = false;
139139
$this->thisChainTryAll = false;

lib/Assert/functions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* The assertion chain can be stateful, that means be careful when you reuse
3333
* it. You should never pass around the chain.
3434
*/
35-
function that($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
35+
function that($value, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
3636
{
3737
return Assert::that($value, $defaultMessage, $defaultPropertyPath);
3838
}
@@ -44,7 +44,7 @@ function that($value, $defaultMessage = null, string $defaultPropertyPath = null
4444
* @param string|callable|null $defaultMessage
4545
* @param string $defaultPropertyPath
4646
*/
47-
function thatAll($values, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
47+
function thatAll($values, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
4848
{
4949
return Assert::thatAll($values, $defaultMessage, $defaultPropertyPath);
5050
}
@@ -58,7 +58,7 @@ function thatAll($values, $defaultMessage = null, string $defaultPropertyPath =
5858
*
5959
* @deprecated In favour of Assert::thatNullOr($value, $defaultMessage = null, $defaultPropertyPath = null)
6060
*/
61-
function thatNullOr($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
61+
function thatNullOr($value, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
6262
{
6363
return Assert::thatNullOr($value, $defaultMessage, $defaultPropertyPath);
6464
}

tests/Assert/Tests/Fixtures/CustomAssertion.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static function getCalls()
3131
return self::$calls;
3232
}
3333

34-
public static function string($value, $message = null, string $propertyPath = null): bool
34+
public static function string($value, $message = null, ?string $propertyPath = null): bool
3535
{
3636
self::$calls[] = ['string', $value];
3737

0 commit comments

Comments
 (0)