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

Handle default null for method parameters in php 8.4 #163

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 src/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function getKeyIndexes(): array
* @param string|null $key
* @return mixed
*/
public function getValue(string $key = null)
public function getValue(string|null $key = null)
{
if ($key && $this->isArrayAttribute()) {
$key = $this->resolveSiblingKey($key);
Expand Down
2 changes: 1 addition & 1 deletion src/ErrorBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ protected function isWildcardKey(string $key): bool
* @param mixed $ruleName
* @return array
*/
protected function filterMessagesForWildcardKey(string $key, $ruleName = null): array
protected function filterMessagesForWildcardKey(string $key, mixed $ruleName = null): array
{
$messages = $this->messages;
$pattern = preg_quote($key, '#');
Expand Down
6 changes: 3 additions & 3 deletions src/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function arrayHas(array $array, string $key): bool
* @param mixed $default
* @return mixed
*/
public static function arrayGet(array $array, $key, $default = null)
public static function arrayGet(array $array, string|null $key, mixed $default = null) : mixed
{
if (is_null($key)) {
return $array;
Expand Down Expand Up @@ -219,7 +219,7 @@ public static function snakeCase(string $value, string $delimiter = '_'): string
* @param string|null $lastSeparator
* @return string
*/
public static function join(array $pieces, string $separator, string $lastSeparator = null): string
public static function join(array $pieces, string $separator, string|null $lastSeparator = null): string
{
if (is_null($lastSeparator)) {
$lastSeparator = $separator;
Expand All @@ -245,7 +245,7 @@ public static function join(array $pieces, string $separator, string $lastSepara
* @param string|null $suffix
* @return array
*/
public static function wraps(array $strings, string $prefix, string $suffix = null): array
public static function wraps(array $strings, string $prefix, string|null $suffix = null): array
{
if (is_null($suffix)) {
$suffix = $prefix;
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function validateBasic($value): bool
* @param null $scheme
* @return bool
*/
public function validateCommonScheme($value, $scheme = null): bool
public function validateCommonScheme($value, mixed $scheme = null): bool
{
if (!$scheme) {
return $this->validateBasic($value) && (bool) preg_match("/^\w+:\/\//i", $value);
Expand Down
2 changes: 1 addition & 1 deletion tests/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ public function testEmptyArrayAssocValidation()
*
* @dataProvider rootAsteriskProvider
*/
public function testRootAsteriskValidation(array $data, array $rules, $errors = null)
public function testRootAsteriskValidation(array $data, array $rules, mixed $errors = null)
{
$validation = $this->validator->validate($data, $rules);
$this->assertSame(empty($errors), $validation->passes());
Expand Down