Skip to content

Commit 1170e99

Browse files
authored
Merge pull request #62 from codebyray/php_84_adjustments
fix: resolve PHP 8.4 implicitly nullable param deprecations
2 parents b80d6d8 + 068d04f commit 1170e99

4 files changed

Lines changed: 300 additions & 156 deletions

File tree

src/Contracts/ReviewRateableContract.php

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,61 +26,65 @@ public function addReview(array $data, ?int $userId = null): mixed;
2626
/**
2727
* Update a review by its ID.
2828
*
29-
* @param int $reviewId
30-
* @param array $data
29+
* @param int|null $reviewId
30+
* @param array|null $data
3131
* @return bool
3232
*/
33-
public function updateReview(int $reviewId = null, array $data = null): bool;
33+
public function updateReview(?int $reviewId = null, ?array $data = null): bool;
3434

3535
/**
3636
* Mark a review as approved by its ID.
3737
*
38-
* @param int $reviewId
38+
* @param int|null $reviewId
3939
* @return bool
4040
*/
41-
public function approveReview(int $reviewId = null): bool;
41+
public function approveReview(?int $reviewId = null): bool;
4242

4343
/**
4444
* Get the average rating for a given key.
4545
*
46-
* @param string $key
47-
* @param bool $approved
46+
* @param string|null $key
47+
* @param bool $approved
4848
* @return float|null
4949
*/
50-
public function averageRating(string $key = null, bool $approved = true): ?float;
50+
public function averageRating(?string $key = null, bool $approved = true): ?float;
5151

5252
/**
5353
* Get overall average ratings for all keys.
5454
*
55-
* @param bool $approved
55+
* @param bool $approved
5656
* @return array
5757
*/
5858
public function averageRatings(bool $approved = true): array;
5959

6060
/**
6161
* Get the average rating for a given key within a department.
6262
*
63-
* @param string $department
64-
* @param string $key
65-
* @param bool $approved
63+
* @param string $department
64+
* @param string|null $key
65+
* @param bool $approved
6666
* @return float|null
6767
*/
68-
public function averageRatingByDepartment(string $department = "default", string $key = null, bool $approved = true): ?float;
68+
public function averageRatingByDepartment(
69+
string $department = "default",
70+
?string $key = null,
71+
bool $approved = true
72+
): ?float;
6973

7074
/**
7175
* Get overall average ratings for all keys within a department.
7276
*
73-
* @param string $department
74-
* @param bool $approved
77+
* @param string $department
78+
* @param bool $approved
7579
* @return array
7680
*/
7781
public function averageRatingsByDepartment(string $department = "default", bool $approved = true): array;
7882

7983
/**
8084
* Get all reviews (with attached ratings) for the attached model.
8185
*
82-
* @param bool $approved
83-
* @param bool $withRatings
86+
* @param bool $approved
87+
* @param bool $withRatings
8488
* @return Collection
8589
*/
8690
public function getReviews(bool $approved = true, bool $withRatings = true): Collection;
@@ -89,52 +93,56 @@ public function getReviews(bool $approved = true, bool $withRatings = true): Col
8993
* Get all reviews (with attached ratings) for a department,
9094
* filtered by the approved status.
9195
*
92-
* @param string $department
93-
* @param bool $approved
94-
* @param bool $withRatings
96+
* @param string $department
97+
* @param bool $approved
98+
* @param bool $withRatings
9599
* @return Collection
96100
*/
97-
public function getReviewsByDepartment(string $department = "default", bool $approved = true, bool $withRatings = true): Collection;
101+
public function getReviewsByDepartment(
102+
string $department = "default",
103+
bool $approved = true,
104+
bool $withRatings = true
105+
): Collection;
98106

99107
/**
100108
* Get the total number of reviews for the attached model.
101109
*
102-
* @param bool $approved
110+
* @param bool $approved
103111
* @return int
104112
*/
105113
public function totalReviews(bool $approved = true): int;
106114

107115
/**
108116
* Get the total number of reviews for the model by department.
109117
*
110-
* @param string $department
111-
* @param bool $approved
118+
* @param string $department
119+
* @param bool $approved
112120
* @return int
113121
*/
114122
public function totalDepartmentReviews(string $department = "default", bool $approved = true): int;
115123

116124
/**
117125
* Get the overall average rating for all ratings attached to the model.
118126
*
119-
* @param bool $approved
127+
* @param bool $approved
120128
* @return float|null
121129
*/
122130
public function overallAverageRating(bool $approved = true): ?float;
123131

124132
/**
125133
* Delete a review.
126134
*
127-
* @param int $reviewId
135+
* @param int|null $reviewId
128136
* @return bool
129137
*/
130-
public function deleteReview(int $reviewId = null): bool;
138+
public function deleteReview(?int $reviewId = null): bool;
131139

132140
/**
133141
* Return an array of rating value ⇒ count, for the full model
134142
* or for a given department.
135143
*
136-
* @param string|null $department
137-
* @param bool $approved
144+
* @param string|null $department
145+
* @param bool $approved
138146
* @return array
139147
*/
140148
public function ratingCounts(?string $department = "default", bool $approved = true): array;
@@ -145,20 +153,25 @@ public function ratingCounts(?string $department = "default", bool $approved = t
145153
* • percentages: [1 => pct1, …, 5 => pct5]
146154
* • total: total number of ratings
147155
*
148-
* @param string|null $department
149-
* @param bool $approved
156+
* @param string|null $department
157+
* @param bool $approved
150158
* @return array
151159
*/
152160
public function ratingStats(?string $department = "default", bool $approved = true): array;
153161

154162
/**
155163
* Return reviews based on star ratings.
156164
*
157-
* @param int|null $starValue
158-
* @param string $department
159-
* @param bool $approved
160-
* @param bool $withRatings
165+
* @param int|null $starValue
166+
* @param string $department
167+
* @param bool $approved
168+
* @param bool $withRatings
161169
* @return Collection
162170
*/
163-
public function getReviewsByRating(int $starValue = null, string $department = "default", bool $approved = true, bool $withRatings = true): Collection;
171+
public function getReviewsByRating(
172+
?int $starValue = null,
173+
string $department = "default",
174+
bool $approved = true,
175+
bool $withRatings = true
176+
): Collection;
164177
}

0 commit comments

Comments
 (0)