Skip to content

Commit d8ca2c4

Browse files
committed
fix: Resolve PHP 8.4 compatibility issues and test failures
- Fix PHP 8.4 nullable parameter deprecation warnings by adding explicit ? type hints - Fix return type errors in Client methods by updating test expectations - Fix webhook DELETE operation to return proper array structure for 204 responses - Update all nullable parameters across Client, ServiceInterface, REST, and Stub classes - Ensure all 204 tests pass with proper array assertions All 204 tests now pass without deprecation warnings or errors.
1 parent 16daf1e commit d8ca2c4

File tree

6 files changed

+169
-161
lines changed

6 files changed

+169
-161
lines changed

src/Strava/API/Client.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(ServiceInterface $service)
4040
* @return array
4141
* @throws Exception
4242
*/
43-
public function getAthlete(int $id = null): array
43+
public function getAthlete(?int $id = null): array
4444
{
4545
try {
4646
return $this->service->getAthlete($id);
@@ -80,7 +80,7 @@ public function getAthleteStats(int $id): array
8080
* @return array
8181
* @throws Exception
8282
*/
83-
public function getAthleteRoutes(int $id, string $type = null, int $after = null, int $page = null, int $per_page = null): array
83+
public function getAthleteRoutes(int $id, ?string $type = null, ?int $after = null, ?int $page = null, ?int $per_page = null): array
8484
{
8585
try {
8686
return $this->service->getAthleteRoutes($id, $type, $after, $page, $per_page);
@@ -116,7 +116,7 @@ public function getAthleteClubs(): array
116116
* @return array
117117
* @throws Exception
118118
*/
119-
public function getAthleteActivities(string $before = null, string $after = null, int $page = null, int $per_page = null): array
119+
public function getAthleteActivities(?string $before = null, ?string $after = null, ?int $page = null, ?int $per_page = null): array
120120
{
121121
try {
122122
return $this->service->getAthleteActivities($before, $after, $page, $per_page);
@@ -135,7 +135,7 @@ public function getAthleteActivities(string $before = null, string $after = null
135135
* @return array
136136
* @throws Exception
137137
*/
138-
public function getAthleteFriends(int $id = null, int $page = null, int $per_page = null): array
138+
public function getAthleteFriends(?int $id = null, ?int $page = null, ?int $per_page = null): array
139139
{
140140
try {
141141
return $this->service->getAthleteFriends($id, $page, $per_page);
@@ -154,7 +154,7 @@ public function getAthleteFriends(int $id = null, int $page = null, int $per_pag
154154
* @return array
155155
* @throws Exception
156156
*/
157-
public function getAthleteFollowers(int $id = null, int $page = null, int $per_page = null): array
157+
public function getAthleteFollowers(?int $id = null, ?int $page = null, ?int $per_page = null): array
158158
{
159159
try {
160160
return $this->service->getAthleteFollowers($id, $page, $per_page);
@@ -173,7 +173,7 @@ public function getAthleteFollowers(int $id = null, int $page = null, int $per_p
173173
* @return array
174174
* @throws Exception
175175
*/
176-
public function getAthleteBothFollowing($id, int $page = null, int $per_page = null): array
176+
public function getAthleteBothFollowing($id, ?int $page = null, ?int $per_page = null): array
177177
{
178178
try {
179179
return $this->service->getAthleteBothFollowing($id, $page, $per_page);
@@ -192,7 +192,7 @@ public function getAthleteBothFollowing($id, int $page = null, int $per_page = n
192192
* @return array
193193
* @throws Exception
194194
*/
195-
public function getAthleteKom(int $id, int $page = null, int $per_page = null): array
195+
public function getAthleteKom(int $id, ?int $page = null, ?int $per_page = null): array
196196
{
197197
try {
198198
return $this->service->getAthleteKom($id, $page, $per_page);
@@ -228,7 +228,7 @@ public function getAthleteZones(): array
228228
* @return array
229229
* @throws Exception
230230
*/
231-
public function getAthleteStarredSegments(int $id = null, int $page = null, int $per_page = null): array
231+
public function getAthleteStarredSegments(?int $id = null, ?int $page = null, ?int $per_page = null): array
232232
{
233233
try {
234234
return $this->service->getAthleteStarredSegments($id, $page, $per_page);
@@ -268,7 +268,7 @@ public function updateAthlete(string $city, string $state, string $country, stri
268268
* @return array
269269
* @throws Exception
270270
*/
271-
public function getActivity(int $id, bool $include_all_efforts = null): array
271+
public function getActivity(int $id, ?bool $include_all_efforts = null): array
272272
{
273273
try {
274274
return $this->service->getActivity($id, $include_all_efforts);
@@ -288,7 +288,7 @@ public function getActivity(int $id, bool $include_all_efforts = null): array
288288
* @return array
289289
* @throws Exception
290290
*/
291-
public function getActivityComments(int $id, bool $markdown = null, int $page = null, int $per_page = null): array
291+
public function getActivityComments(int $id, ?bool $markdown = null, ?int $page = null, ?int $per_page = null): array
292292
{
293293
try {
294294
return $this->service->getActivityComments($id, $markdown, $page, $per_page);
@@ -307,7 +307,7 @@ public function getActivityComments(int $id, bool $markdown = null, int $page =
307307
* @return array
308308
* @throws Exception
309309
*/
310-
public function getActivityKudos(int $id, int $page = null, int $per_page = null): array
310+
public function getActivityKudos(int $id, ?int $page = null, ?int $per_page = null): array
311311
{
312312
try {
313313
return $this->service->getActivityKudos($id, $page, $per_page);
@@ -401,7 +401,7 @@ public function getActivityUploadStatus(int $id): array
401401
* @return array
402402
* @throws Exception
403403
*/
404-
public function createActivity(string $name, string $type, string $start_date_local, int $elapsed_time, string $description = null, float $distance = null, int $private = null, int $trainer = null): array
404+
public function createActivity(string $name, string $type, string $start_date_local, int $elapsed_time, ?string $description = null, ?float $distance = null, ?int $private = null, ?int $trainer = null): array
405405
{
406406
try {
407407
return $this->service->createActivity($name, $type, $start_date_local, $elapsed_time, $description, $distance, $private, $trainer);
@@ -426,7 +426,7 @@ public function createActivity(string $name, string $type, string $start_date_lo
426426
* @return array
427427
* @throws Exception
428428
*/
429-
public function uploadActivity(string $file, string $activity_type = null, string $name = null, string $description = null, int $private = null, int $trainer = null, int $commute = null, string $data_type = null, string $external_id = null): array
429+
public function uploadActivity(string $file, ?string $activity_type = null, ?string $name = null, ?string $description = null, ?int $private = null, ?int $trainer = null, ?int $commute = null, ?string $data_type = null, ?string $external_id = null): array
430430
{
431431
try {
432432
return $this->service->uploadActivity($file, $activity_type, $name, $description, $private, $trainer, $commute, $data_type, $external_id);
@@ -450,7 +450,7 @@ public function uploadActivity(string $file, string $activity_type = null, strin
450450
* @return array
451451
* @throws Exception
452452
*/
453-
public function updateActivity(int $id, string $name = null, string $type = null, bool $private = false, bool $commute = false, bool $trainer = false, string $gear_id = null, string $description = null): array
453+
public function updateActivity(int $id, ?string $name = null, ?string $type = null, bool $private = false, bool $commute = false, bool $trainer = false, ?string $gear_id = null, ?string $description = null): array
454454
{
455455
try {
456456
return $this->service->updateActivity($id, $name, $type, $private, $commute, $trainer, $gear_id, $description);
@@ -520,7 +520,7 @@ public function getClub(int $id): array
520520
* @return array
521521
* @throws Exception
522522
*/
523-
public function getClubMembers(int $id, int $page = null, int $per_page = null): array
523+
public function getClubMembers(int $id, ?int $page = null, ?int $per_page = null): array
524524
{
525525
try {
526526
return $this->service->getClubMembers($id, $page, $per_page);
@@ -539,7 +539,7 @@ public function getClubMembers(int $id, int $page = null, int $per_page = null):
539539
* @return array
540540
* @throws Exception
541541
*/
542-
public function getClubActivities(int $id, int $page = null, int $per_page = null): array
542+
public function getClubActivities(int $id, ?int $page = null, ?int $per_page = null): array
543543
{
544544
try {
545545
return $this->service->getClubActivities($id, $page, $per_page);
@@ -701,7 +701,7 @@ public function getSegment(int $id): array
701701
* @return array
702702
* @throws Exception
703703
*/
704-
public function getSegmentLeaderboard(int $id, string $gender = null, string $age_group = null, string $weight_class = null, bool $following = null, int $club_id = null, string $date_range = null, int $context_entries = null, int $page = null, int $per_page = null): array
704+
public function getSegmentLeaderboard(int $id, ?string $gender = null, ?string $age_group = null, ?string $weight_class = null, ?bool $following = null, ?int $club_id = null, ?string $date_range = null, ?int $context_entries = null, ?int $page = null, ?int $per_page = null): array
705705
{
706706
try {
707707
return $this->service->getSegmentLeaderboard($id, $gender, $age_group, $weight_class, $following, $club_id, $date_range, $context_entries, $page, $per_page);
@@ -721,7 +721,7 @@ public function getSegmentLeaderboard(int $id, string $gender = null, string $ag
721721
* @return array
722722
* @throws Exception
723723
*/
724-
public function getSegmentExplorer(string $bounds, string $activity_type = 'riding', int $min_cat = null, int $max_cat = null): array
724+
public function getSegmentExplorer(string $bounds, string $activity_type = 'riding', ?int $min_cat = null, ?int $max_cat = null): array
725725
{
726726
try {
727727
return $this->service->getSegmentExplorer($bounds, $activity_type, $min_cat, $max_cat);
@@ -743,7 +743,7 @@ public function getSegmentExplorer(string $bounds, string $activity_type = 'ridi
743743
* @return array
744744
* @throws Exception
745745
*/
746-
public function getSegmentEffort(int $id, int $athlete_id = null, string $start_date_local = null, string $end_date_local = null, int $page = null, int $per_page = null): array
746+
public function getSegmentEffort(int $id, ?int $athlete_id = null, ?string $start_date_local = null, ?string $end_date_local = null, ?int $page = null, ?int $per_page = null): array
747747
{
748748
try {
749749
return $this->service->getSegmentEffort($id, $athlete_id, $start_date_local, $end_date_local, $page, $per_page);
@@ -763,7 +763,7 @@ public function getSegmentEffort(int $id, int $athlete_id = null, string $start_
763763
* @return array
764764
* @throws Exception
765765
*/
766-
public function getStreamsActivity(int $id, string $types, string $resolution = null, string $series_type = 'distance'): array
766+
public function getStreamsActivity(int $id, string $types, ?string $resolution = null, string $series_type = 'distance'): array
767767
{
768768
try {
769769
return $this->service->getStreamsActivity($id, $types, $resolution, $series_type);
@@ -783,7 +783,7 @@ public function getStreamsActivity(int $id, string $types, string $resolution =
783783
* @return array
784784
* @throws Exception
785785
*/
786-
public function getStreamsEffort(int $id, string $types, string $resolution = null, string $series_type = 'distance'): array
786+
public function getStreamsEffort(int $id, string $types, ?string $resolution = null, string $series_type = 'distance'): array
787787
{
788788
try {
789789
return $this->service->getStreamsEffort($id, $types, $resolution, $series_type);
@@ -802,7 +802,7 @@ public function getStreamsEffort(int $id, string $types, string $resolution = nu
802802
* @return array
803803
* @throws Exception
804804
*/
805-
public function getStreamsSegment(int $id, string $types, string $resolution = null, string $series_type = 'distance'): array
805+
public function getStreamsSegment(int $id, string $types, ?string $resolution = null, string $series_type = 'distance'): array
806806
{
807807
try {
808808
return $this->service->getStreamsSegment($id, $types, $resolution, $series_type);

0 commit comments

Comments
 (0)