[PR #259] [MERGED] Add return self on setters #283

Closed
opened 2026-02-27 19:26:55 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jwilsson/spotify-web-api-php/pull/259
Author: @stephdotnet
Created: 2/11/2023
Status: Merged
Merged: 2/11/2023
Merged by: @jwilsson

Base: mainHead: add-return-self-on-setters


📝 Commits (1)

  • 3f90f86 Add return self on setters

📊 Changes

6 files changed (+60 additions, -15 deletions)

View changed files

📝 src/Request.php (+3 -1)
📝 src/Session.php (+15 -5)
📝 src/SpotifyWebAPI.php (+9 -3)
📝 tests/RequestTest.php (+2 -1)
📝 tests/SessionTest.php (+10 -5)
📝 tests/SpotifyWebAPITest.php (+21 -0)

📄 Description

Hi,

First of all, thanks for your work, this package is perfect.
The reason of this PR is to add a little improvement, especially usefull when using the api like following

$api = new SpotifyWebAPI\SpotifyWebAPI();
$api->setAccessToken(session()->get('access_token'));
$user = $api->me();

It will now be possible to chain the setters such as

$me = (new SpotifyWebAPI\SpotifyWebAPI())
    ->setAccessToken(session()->get('access_token'))
    ->me();

Since I'm using this package in my project, i faced this and wanted to contribute on my own to this project.
I also added the tests to cover this expectation. I hope everything will be fine to you.

PS: I also i noticed a deprecation on assertObjectHasAttribute that will be remove in PhpUnit 10. I didn't want to mix up the PR so feel free to say if you want i can mass search and replace the usages 👍 (it will become assertObjectHasProperty)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jwilsson/spotify-web-api-php/pull/259 **Author:** [@stephdotnet](https://github.com/stephdotnet) **Created:** 2/11/2023 **Status:** ✅ Merged **Merged:** 2/11/2023 **Merged by:** [@jwilsson](https://github.com/jwilsson) **Base:** `main` ← **Head:** `add-return-self-on-setters` --- ### 📝 Commits (1) - [`3f90f86`](https://github.com/jwilsson/spotify-web-api-php/commit/3f90f86efea2b98b369ee330fd818b23e7f6920f) Add return self on setters ### 📊 Changes **6 files changed** (+60 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `src/Request.php` (+3 -1) 📝 `src/Session.php` (+15 -5) 📝 `src/SpotifyWebAPI.php` (+9 -3) 📝 `tests/RequestTest.php` (+2 -1) 📝 `tests/SessionTest.php` (+10 -5) 📝 `tests/SpotifyWebAPITest.php` (+21 -0) </details> ### 📄 Description Hi, First of all, thanks for your work, this package is perfect. The reason of this PR is to add a little improvement, especially usefull when using the api like following ``` $api = new SpotifyWebAPI\SpotifyWebAPI(); $api->setAccessToken(session()->get('access_token')); $user = $api->me(); ``` It will now be possible to chain the setters such as ``` $me = (new SpotifyWebAPI\SpotifyWebAPI()) ->setAccessToken(session()->get('access_token')) ->me(); ``` Since I'm using this package in my project, i faced this and wanted to contribute on my own to this project. I also added the tests to cover this expectation. I hope everything will be fine to you. PS: I also i noticed a deprecation on `assertObjectHasAttribute` that will be remove in PhpUnit 10. I didn't want to mix up the PR so feel free to say if you want i can mass search and replace the usages 👍 (it will become `assertObjectHasProperty`) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 19:26:55 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-web-api-php#283
No description provided.