jwilsson / spotify-web-api-php

A PHP wrapper for Spotify's Web API.
MIT License
862 stars 156 forks source link

Add return self on setters #259

Closed stephdotnet closed 1 year ago

stephdotnet commented 1 year ago

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)

jwilsson commented 1 year ago

Looks great, thanks for contributing! 🎉

If you wish to fix the PHPUnit deprecations, please do! Any help is greatly appreciated 👍