From 56c9c7d3e8366789740f4075de892119e054965c Mon Sep 17 00:00:00 2001 From: Patrick Hesselberg Date: Fri, 12 May 2023 17:52:06 +0200 Subject: [PATCH] [10.x] Add the ability to extend the generic types for DatabaseNotificationCollection (#47048) * Add the ability to extend the generic types * Update DatabaseNotificationCollection.php * Remove unused * Add tests * Fix style * rm lb * Updates localtion of type tests --------- Co-authored-by: Nuno Maduro --- .../DatabaseNotificationCollection.php | 6 +++++ .../DatabaseNotificationCollection.php | 25 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 types/Notifications/DatabaseNotificationCollection.php diff --git a/src/Illuminate/Notifications/DatabaseNotificationCollection.php b/src/Illuminate/Notifications/DatabaseNotificationCollection.php index 05924ec67220..5bac0272dd7b 100644 --- a/src/Illuminate/Notifications/DatabaseNotificationCollection.php +++ b/src/Illuminate/Notifications/DatabaseNotificationCollection.php @@ -4,6 +4,12 @@ use Illuminate\Database\Eloquent\Collection; +/** + * @template TKey of array-key + * @template TModel of DatabaseNotification + * + * @extends \Illuminate\Database\Eloquent\Collection + */ class DatabaseNotificationCollection extends Collection { /** diff --git a/types/Notifications/DatabaseNotificationCollection.php b/types/Notifications/DatabaseNotificationCollection.php new file mode 100644 index 000000000000..f2ab9453484d --- /dev/null +++ b/types/Notifications/DatabaseNotificationCollection.php @@ -0,0 +1,25 @@ + + */ +class CustomNotificationCollection extends DatabaseNotificationCollection +{ + // +} + +$databaseNotificationsCollection = DatabaseNotification::all(); +assertType('Illuminate\Database\Eloquent\Collection', $databaseNotificationsCollection); + +$customNotificationsCollection = CustomNotification::all(); +assertType('Illuminate\Database\Eloquent\Collection', $customNotificationsCollection);