From f5ff85589d707df4f851a6ed440e59dfb7e431c6 Mon Sep 17 00:00:00 2001 From: Attila Fulop <1162360+fulopattila122@users.noreply.github.com> Date: Tue, 4 Mar 2025 12:15:00 +0200 Subject: [PATCH] Fixed PHP 8.4 deprecation notices on implicitly nullable method arguments --- Changelog.md | 5 +++++ src/Acl/ResourcePermissionMapper.php | 4 ++-- src/Acl/ResourcePermissions.php | 2 +- src/Helpers/DateHelper.php | 6 +++--- src/Support/helpers.php | 6 +++--- src/Support/icon.php | 2 +- src/Widgets/Filter.php | 2 +- src/Widgets/Table/HasTableCellAttributes.php | 2 +- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Changelog.md b/Changelog.md index c9ad12c3..147f81cd 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ # AppShell Changelog +## Unreleased +##### 2025-XX-YY + +- Fixed PHP 8.4 deprecation notices on implicitly nullable method arguments + ## 4.9.0 ##### 2025-03-03 diff --git a/src/Acl/ResourcePermissionMapper.php b/src/Acl/ResourcePermissionMapper.php index 23fd34d8..12e3bcbd 100644 --- a/src/Acl/ResourcePermissionMapper.php +++ b/src/Acl/ResourcePermissionMapper.php @@ -41,7 +41,7 @@ final class ResourcePermissionMapper private ?array $aliases = null; - public function __construct(array $aliases = null) + public function __construct(?array $aliases = null) { if (null !== $aliases) { $this->loadAliases($aliases); @@ -140,7 +140,7 @@ private function plural(string $word): string return $this->customPluralForms[$word] ?? Str::plural($word); } - private function loadAliases(array $aliases = null): void + private function loadAliases(?array $aliases = null): void { if (null !== $this->aliases) { return; diff --git a/src/Acl/ResourcePermissions.php b/src/Acl/ResourcePermissions.php index 199c7545..6dd56354 100644 --- a/src/Acl/ResourcePermissions.php +++ b/src/Acl/ResourcePermissions.php @@ -42,7 +42,7 @@ final class ResourcePermissions * * @return \Illuminate\Support\Collection */ - public static function createPermissionsForResource($resources, string $guard = null) + public static function createPermissionsForResource($resources, ?string $guard = null) { $resources = is_array($resources) ? $resources : [$resources]; $result = collect(); diff --git a/src/Helpers/DateHelper.php b/src/Helpers/DateHelper.php index c4acadcb..182cd19f 100644 --- a/src/Helpers/DateHelper.php +++ b/src/Helpers/DateHelper.php @@ -28,7 +28,7 @@ class DateHelper * * @return string */ - public function showDate($date, string $unknownDateText = '', string $format = null): string + public function showDate($date, string $unknownDateText = '', ?string $format = null): string { $carbon = $this->toCarbon($date); @@ -52,7 +52,7 @@ public function showDate($date, string $unknownDateText = '', string $format = n * * @return string */ - public function showDateTime($datetime, string $unknownDateTimeText = '', string $format = null): string + public function showDateTime($datetime, string $unknownDateTimeText = '', ?string $format = null): string { $carbon = $this->toCarbon($datetime); @@ -76,7 +76,7 @@ public function showDateTime($datetime, string $unknownDateTimeText = '', string * * @return string */ - public function showTime($datetime, string $unknownTimeText = '', string $format = null): string + public function showTime($datetime, string $unknownTimeText = '', ?string $format = null): string { $carbon = $this->toCarbon($datetime); diff --git a/src/Support/helpers.php b/src/Support/helpers.php index aa225f6f..f3d55ee6 100644 --- a/src/Support/helpers.php +++ b/src/Support/helpers.php @@ -67,7 +67,7 @@ function coloring(): ColorHelper * * @return string */ - function show_date($date, string $unknownDateText = '', string $format = null): string + function show_date($date, string $unknownDateText = '', ?string $format = null): string { return helper('date')->showDate($date, $unknownDateText, $format); } @@ -81,7 +81,7 @@ function show_date($date, string $unknownDateText = '', string $format = null): * * @return string */ - function show_datetime($datetime, string $unknownDateTimeText = '', string $format = null): string + function show_datetime($datetime, string $unknownDateTimeText = '', ?string $format = null): string { return helper('date')->showDateTime($datetime, $unknownDateTimeText, $format); } @@ -95,7 +95,7 @@ function show_datetime($datetime, string $unknownDateTimeText = '', string $form * * @return string */ - function show_time($datetime, string $unknownTimeText = '', string $format = null): string + function show_time($datetime, string $unknownTimeText = '', ?string $format = null): string { return helper('date')->showTime($datetime, $unknownTimeText, $format); } diff --git a/src/Support/icon.php b/src/Support/icon.php index fc31ba37..eb731452 100644 --- a/src/Support/icon.php +++ b/src/Support/icon.php @@ -25,7 +25,7 @@ function enum_icon(Enum $enum): string /** * Renders an icon using the selected Icon theme */ -function icon(string $name, string $color = null, array $attributes = []): string +function icon(string $name, ?string $color = null, array $attributes = []): string { return icon_theme()->render($name, ThemeColor::create($color), $attributes); } diff --git a/src/Widgets/Filter.php b/src/Widgets/Filter.php index c62fb20a..fbd23ba6 100644 --- a/src/Widgets/Filter.php +++ b/src/Widgets/Filter.php @@ -40,7 +40,7 @@ class Filter implements Widget private $criteria = null; - public function __construct(Theme $theme, string $id, FilterType $type, string $title = null) + public function __construct(Theme $theme, string $id, FilterType $type, ?string $title = null) { $this->theme = $theme; $this->id = $id; diff --git a/src/Widgets/Table/HasTableCellAttributes.php b/src/Widgets/Table/HasTableCellAttributes.php index e8f9a362..fbdd7625 100644 --- a/src/Widgets/Table/HasTableCellAttributes.php +++ b/src/Widgets/Table/HasTableCellAttributes.php @@ -69,7 +69,7 @@ private function getSpecifiedAttributes(array $attributes): array return $result; } - private function toCssRule(array $def, string $key, string $cssKey = null): string + private function toCssRule(array $def, string $key, ?string $cssKey = null): string { if (!isset($def[$key])) { return '';