Skip to content
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

[PHP 8.4] Fixes for implicit nullability deprecation #337

Merged
merged 1 commit into from
Apr 23, 2024
Merged
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
6 changes: 3 additions & 3 deletions lib/Assert/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class Assert
* The assertion chain can be stateful, that means be careful when you reuse
* it. You should never pass around the chain.
*/
public static function that($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
public static function that($value, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
{
$assertionChain = new AssertionChain($value, $defaultMessage, $defaultPropertyPath);

Expand All @@ -55,7 +55,7 @@ public static function that($value, $defaultMessage = null, string $defaultPrope
* @param mixed $values
* @param string|callable|null $defaultMessage
*/
public static function thatAll($values, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
public static function thatAll($values, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
{
return static::that($values, $defaultMessage, $defaultPropertyPath)->all();
}
Expand All @@ -66,7 +66,7 @@ public static function thatAll($values, $defaultMessage = null, string $defaultP
* @param mixed $value
* @param string|callable|null $defaultMessage
*/
public static function thatNullOr($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
public static function thatNullOr($value, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
{
return static::that($value, $defaultMessage, $defaultPropertyPath)->nullOr();
}
Expand Down
178 changes: 89 additions & 89 deletions lib/Assert/Assertion.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/Assert/AssertionChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class AssertionChain
* @param mixed $value
* @param string|callable|null $defaultMessage
*/
public function __construct($value, $defaultMessage = null, string $defaultPropertyPath = null)
public function __construct($value, $defaultMessage = null, ?string $defaultPropertyPath = null)
{
$this->value = $value;
$this->defaultMessage = $defaultMessage;
Expand Down
2 changes: 1 addition & 1 deletion lib/Assert/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class InvalidArgumentException extends \InvalidArgumentException implements Asse
*/
private $constraints;

public function __construct($message, $code, string $propertyPath = null, $value = null, array $constraints = [])
public function __construct($message, $code, ?string $propertyPath = null, $value = null, array $constraints = [])
{
parent::__construct($message, $code);

Expand Down
2 changes: 1 addition & 1 deletion lib/Assert/LazyAssertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class LazyAssertion
*
* @return static
*/
public function that($value, string $propertyPath = null, $defaultMessage = null)
public function that($value, ?string $propertyPath = null, $defaultMessage = null)
{
$this->currentChainFailed = false;
$this->thisChainTryAll = false;
Expand Down
6 changes: 3 additions & 3 deletions lib/Assert/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* The assertion chain can be stateful, that means be careful when you reuse
* it. You should never pass around the chain.
*/
function that($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
function that($value, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
{
return Assert::that($value, $defaultMessage, $defaultPropertyPath);
}
Expand All @@ -44,7 +44,7 @@ function that($value, $defaultMessage = null, string $defaultPropertyPath = null
* @param string|callable|null $defaultMessage
* @param string $defaultPropertyPath
*/
function thatAll($values, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
function thatAll($values, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
{
return Assert::thatAll($values, $defaultMessage, $defaultPropertyPath);
}
Expand All @@ -58,7 +58,7 @@ function thatAll($values, $defaultMessage = null, string $defaultPropertyPath =
*
* @deprecated In favour of Assert::thatNullOr($value, $defaultMessage = null, $defaultPropertyPath = null)
*/
function thatNullOr($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
function thatNullOr($value, $defaultMessage = null, ?string $defaultPropertyPath = null): AssertionChain
{
return Assert::thatNullOr($value, $defaultMessage, $defaultPropertyPath);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Assert/Tests/Fixtures/CustomAssertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static function getCalls()
return self::$calls;
}

public static function string($value, $message = null, string $propertyPath = null): bool
public static function string($value, $message = null, ?string $propertyPath = null): bool
{
self::$calls[] = ['string', $value];

Expand Down