diff --git a/.github/workflows/buildcheck.yml b/.github/workflows/buildcheck.yml index 6ba28d5..8ae9a02 100644 --- a/.github/workflows/buildcheck.yml +++ b/.github/workflows/buildcheck.yml @@ -16,6 +16,8 @@ jobs: - "8.0" - "8.1" - "8.2" + - "8.3" + - "8.4" composer: - "" - "--prefer-lowest" diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a9bf3d..23ea8d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ Changelog -------- +## 2.2.6 - 2024-12-18 + +### Changed + +* [Support] Added support for PHP 8.3 and 8.4. + +-------- + ## 2.2.5 - 2024-12-18 ### Changed diff --git a/composer.json b/composer.json index 032d653..adba155 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "phpstan/phpstan-mockery": "^0.12.14", "phpstan/phpstan-phpunit": "^0.12.22", "squizlabs/php_codesniffer": "^3.6", - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^9.6" }, "autoload": { "psr-4": {"duncan3dc\\Sonos\\": "src/"} diff --git a/src/Alarm.php b/src/Alarm.php index cd5bdfe..01414b5 100644 --- a/src/Alarm.php +++ b/src/Alarm.php @@ -269,11 +269,11 @@ public function setFrequency(int $frequency): AlarmInterface * Check or set whether this alarm is active on a particular day. * * @param int $day Which day to check/set - * @param bool $set Set this alarm to be active or not on the specified day + * @param ?bool $set Set this alarm to be active or not on the specified day * * @return bool|AlarmInterface Returns true/false when checking, or AlarmInterface when setting */ - protected function onHandler(int $day, bool $set = null) + protected function onHandler(int $day, ?bool $set = null) { $frequency = $this->getFrequency(); if ($set === null) { @@ -293,11 +293,11 @@ protected function onHandler(int $day, bool $set = null) /** * Check or set whether this alarm is active on mondays. * - * @param bool $set Set this alarm to be active or not on mondays + * @param ?bool $set Set this alarm to be active or not on mondays * * @return bool|AlarmInterface Returns true/false when checking, or AlarmInterface when setting */ - public function onMonday(bool $set = null) + public function onMonday(?bool $set = null) { return $this->onHandler(AlarmInterface::MONDAY, $set); } @@ -306,11 +306,11 @@ public function onMonday(bool $set = null) /** * Check or set whether this alarm is active on tuesdays. * - * @param bool $set Set this alarm to be active or not on tuesdays + * @param ?bool $set Set this alarm to be active or not on tuesdays * * @return bool|AlarmInterface Returns true/false when checking, or AlarmInterface when setting */ - public function onTuesday(bool $set = null) + public function onTuesday(?bool $set = null) { return $this->onHandler(AlarmInterface::TUESDAY, $set); } @@ -319,11 +319,11 @@ public function onTuesday(bool $set = null) /** * Check or set whether this alarm is active on wednesdays. * - * @param bool $set Set this alarm to be active or not on wednesdays + * @param ?bool $set Set this alarm to be active or not on wednesdays * * @return bool|AlarmInterface Returns true/false when checking, or AlarmInterface when setting */ - public function onWednesday(bool $set = null) + public function onWednesday(?bool $set = null) { return $this->onHandler(AlarmInterface::WEDNESDAY, $set); } @@ -332,11 +332,11 @@ public function onWednesday(bool $set = null) /** * Check or set whether this alarm is active on thursdays. * - * @param bool $set Set this alarm to be active or not on thursdays + * @param ?bool $set Set this alarm to be active or not on thursdays * * @return bool|AlarmInterface Returns true/false when checking, or AlarmInterface when setting */ - public function onThursday(bool $set = null) + public function onThursday(?bool $set = null) { return $this->onHandler(AlarmInterface::THURSDAY, $set); } @@ -345,11 +345,11 @@ public function onThursday(bool $set = null) /** * Check or set whether this alarm is active on fridays. * - * @param bool $set Set this alarm to be active or not on fridays + * @param ?bool $set Set this alarm to be active or not on fridays * * @return bool|AlarmInterface Returns true/false when checking, or AlarmInterface when setting */ - public function onFriday(bool $set = null) + public function onFriday(?bool $set = null) { return $this->onHandler(AlarmInterface::FRIDAY, $set); } @@ -358,11 +358,11 @@ public function onFriday(bool $set = null) /** * Check or set whether this alarm is active on saturdays. * - * @param bool $set Set this alarm to be active or not on saturdays + * @param ?bool $set Set this alarm to be active or not on saturdays * * @return bool|AlarmInterface Returns true/false when checking, or AlarmInterface when setting */ - public function onSaturday(bool $set = null) + public function onSaturday(?bool $set = null) { return $this->onHandler(AlarmInterface::SATURDAY, $set); } @@ -371,11 +371,11 @@ public function onSaturday(bool $set = null) /** * Check or set whether this alarm is active on sundays. * - * @param bool $set Set this alarm to be active or not on sundays + * @param ?bool $set Set this alarm to be active or not on sundays * * @return bool|AlarmInterface Returns true/false when checking, or AlarmInterface when setting */ - public function onSunday(bool $set = null) + public function onSunday(?bool $set = null) { return $this->onHandler(AlarmInterface::SUNDAY, $set); } @@ -384,11 +384,11 @@ public function onSunday(bool $set = null) /** * Check or set whether this alarm is a one time only alarm. * - * @param bool $set Set this alarm to be a one time only alarm + * @param ?bool $set Set this alarm to be a one time only alarm * * @return bool|AlarmInterface Returns true/false when checking, or AlarmInterface when setting */ - public function once(bool $set = null) + public function once(?bool $set = null) { if ($set) { return $this->setFrequency(AlarmInterface::ONCE); @@ -400,11 +400,11 @@ public function once(bool $set = null) /** * Check or set whether this alarm runs every day or not. * - * @param bool $set Set this alarm to be active every day + * @param ?bool $set Set this alarm to be active every day * * @return bool|AlarmInterface Returns true/false when checking, or AlarmInterface when setting */ - public function daily(bool $set = null) + public function daily(?bool $set = null) { if ($set) { return $this->setFrequency(AlarmInterface::DAILY); diff --git a/src/Controller.php b/src/Controller.php index 76201f1..fdf1d61 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -317,11 +317,11 @@ public function useStream(Stream $stream): ControllerInterface * * If no speaker is passed then the current controller's is used. * - * @param SpeakerInterface|null $speaker The speaker to get the line-in from + * @param ?SpeakerInterface $speaker The speaker to get the line-in from * * @return static */ - public function useLineIn(SpeakerInterface $speaker = null): ControllerInterface + public function useLineIn(?SpeakerInterface $speaker = null): ControllerInterface { if ($speaker === null) { $speaker = $this; @@ -649,11 +649,11 @@ public function restoreState(ControllerStateInterface $state): ControllerInterfa * This is useful for making announcements over the Sonos network. * * @param UriInterface $track The track to play - * @param int $volume The volume to play the track at + * @param ?int $volume The volume to play the track at * * @return $this */ - public function interrupt(UriInterface $track, int $volume = null): ControllerInterface + public function interrupt(UriInterface $track, ?int $volume = null): ControllerInterface { /** * Ensure the track has been generated. diff --git a/src/Devices/Collection.php b/src/Devices/Collection.php index c2bdaec..c38ef0f 100644 --- a/src/Devices/Collection.php +++ b/src/Devices/Collection.php @@ -31,9 +31,9 @@ final class Collection implements CollectionInterface /** * Create a new instance. * - * @param FactoryInterface $factory The factory to create new devices from + * @param ?FactoryInterface $factory The factory to create new devices from */ - public function __construct(FactoryInterface $factory = null) + public function __construct(?FactoryInterface $factory = null) { if ($factory === null) { $factory = new Factory(); diff --git a/src/Devices/Device.php b/src/Devices/Device.php index 6229e26..322717c 100644 --- a/src/Devices/Device.php +++ b/src/Devices/Device.php @@ -41,10 +41,10 @@ final class Device implements DeviceInterface * Create an instance of the Device class. * * @param string $ip The ip address that the device is listening on - * @param CacheInterface $cache The cache object to use for finding Sonos devices on the network - * @param LoggerInterface $logger A logging object + * @param ?CacheInterface $cache The cache object to use for finding Sonos devices on the network + * @param ?LoggerInterface $logger A logging object */ - public function __construct(string $ip, CacheInterface $cache = null, LoggerInterface $logger = null) + public function __construct(string $ip, ?CacheInterface $cache = null, ?LoggerInterface $logger = null) { $this->ip = $ip; diff --git a/src/Devices/Discovery.php b/src/Devices/Discovery.php index e36119d..490a08f 100644 --- a/src/Devices/Discovery.php +++ b/src/Devices/Discovery.php @@ -37,9 +37,9 @@ final class Discovery implements CollectionInterface /** * Create a new instance. * - * @param CollectionInterface $collection The device collection to actually use + * @param ?CollectionInterface $collection The device collection to actually use */ - public function __construct(CollectionInterface $collection = null) + public function __construct(?CollectionInterface $collection = null) { if ($collection === null) { $collection = new Collection(); diff --git a/src/Devices/Factory.php b/src/Devices/Factory.php index ed1b80a..c592c3a 100644 --- a/src/Devices/Factory.php +++ b/src/Devices/Factory.php @@ -22,10 +22,10 @@ final class Factory implements FactoryInterface /** * Create a new instance. * - * @param CacheInterface $cache The cache object to use for finding Sonos devices on the network - * @param LoggerInterface $logger A logging object + * @param ?CacheInterface $cache The cache object to use for finding Sonos devices on the network + * @param ?LoggerInterface $logger A logging object */ - public function __construct(CacheInterface $cache = null, LoggerInterface $logger = null) + public function __construct(?CacheInterface $cache = null, ?LoggerInterface $logger = null) { if ($cache === null) { $cache = new ArrayPool(); diff --git a/src/Helper.php b/src/Helper.php index 00d1f5b..735aad8 100644 --- a/src/Helper.php +++ b/src/Helper.php @@ -68,7 +68,7 @@ public static function setMode(array $options): string * @param string $id The ID of the track * @param string $parent The ID of the parent * @param array $extra An xml array of extra attributes for this item - * @param string $service The Sonos service ID to use + * @param ?string $service The Sonos service ID to use * * @return string */ @@ -76,7 +76,7 @@ public static function createMetaDataXml( string $id, string $parent = "-1", array $extra = [], - string $service = null + ?string $service = null ): string { if ($service !== null) { $extra["desc"] = [ diff --git a/src/Interfaces/AlarmInterface.php b/src/Interfaces/AlarmInterface.php index 9ea39b9..3ddb9db 100644 --- a/src/Interfaces/AlarmInterface.php +++ b/src/Interfaces/AlarmInterface.php @@ -126,91 +126,91 @@ public function setFrequency(int $frequency): AlarmInterface; /** * Check or set whether this alarm is active on mondays. * - * @param bool $set Set this alarm to be active or not on mondays + * @param ?bool $set Set this alarm to be active or not on mondays * * @return bool|static Returns true/false when checking, or static when setting */ - public function onMonday(bool $set = null); + public function onMonday(?bool $set = null); /** * Check or set whether this alarm is active on tuesdays. * - * @param bool $set Set this alarm to be active or not on tuesdays + * @param ?bool $set Set this alarm to be active or not on tuesdays * * @return bool|static Returns true/false when checking, or static when setting */ - public function onTuesday(bool $set = null); + public function onTuesday(?bool $set = null); /** * Check or set whether this alarm is active on wednesdays. * - * @param bool $set Set this alarm to be active or not on wednesdays + * @param ?bool $set Set this alarm to be active or not on wednesdays * * @return bool|static Returns true/false when checking, or static when setting */ - public function onWednesday(bool $set = null); + public function onWednesday(?bool $set = null); /** * Check or set whether this alarm is active on thursdays. * - * @param bool $set Set this alarm to be active or not on thursdays + * @param ?bool $set Set this alarm to be active or not on thursdays * * @return bool|static Returns true/false when checking, or static when setting */ - public function onThursday(bool $set = null); + public function onThursday(?bool $set = null); /** * Check or set whether this alarm is active on fridays. * - * @param bool $set Set this alarm to be active or not on fridays + * @param ?bool $set Set this alarm to be active or not on fridays * * @return bool|static Returns true/false when checking, or static when setting */ - public function onFriday(bool $set = null); + public function onFriday(?bool $set = null); /** * Check or set whether this alarm is active on saturdays. * - * @param bool $set Set this alarm to be active or not on saturdays + * @param ?bool $set Set this alarm to be active or not on saturdays * * @return bool|static Returns true/false when checking, or static when setting */ - public function onSaturday(bool $set = null); + public function onSaturday(?bool $set = null); /** * Check or set whether this alarm is active on sundays. * - * @param bool $set Set this alarm to be active or not on sundays + * @param ?bool $set Set this alarm to be active or not on sundays * * @return bool|static Returns true/false when checking, or static when setting */ - public function onSunday(bool $set = null); + public function onSunday(?bool $set = null); /** * Check or set whether this alarm is a one time only alarm. * - * @param bool $set Set this alarm to be a one time only alarm + * @param ?bool $set Set this alarm to be a one time only alarm * * @return bool|static Returns true/false when checking, or static when setting */ - public function once(bool $set = null); + public function once(?bool $set = null); /** * Check or set whether this alarm runs every day or not. * - * @param bool $set Set this alarm to be active every day + * @param ?bool $set Set this alarm to be active every day * * @return bool|static Returns true/false when checking, or static when setting */ - public function daily(bool $set = null); + public function daily(?bool $set = null); /** diff --git a/src/Interfaces/ControllerInterface.php b/src/Interfaces/ControllerInterface.php index 107aff9..2d201bd 100644 --- a/src/Interfaces/ControllerInterface.php +++ b/src/Interfaces/ControllerInterface.php @@ -162,11 +162,11 @@ public function useStream(Stream $stream): ControllerInterface; * * If no speaker is passed then the current controller's is used. * - * @param SpeakerInterface|null $speaker The speaker to get the line-in from + * @param ?SpeakerInterface $speaker The speaker to get the line-in from * * @return self */ - public function useLineIn(SpeakerInterface $speaker = null): ControllerInterface; + public function useLineIn(?SpeakerInterface $speaker = null): ControllerInterface; /** @@ -322,9 +322,9 @@ public function restoreState(ControllerStateInterface $state): ControllerInterfa * This is useful for making announcements over the Sonos network. * * @param UriInterface $track The track to play - * @param int $volume The volume to play the track at + * @param ?int $volume The volume to play the track at * * @return self */ - public function interrupt(UriInterface $track, int $volume = null): ControllerInterface; + public function interrupt(UriInterface $track, ?int $volume = null): ControllerInterface; } diff --git a/src/Interfaces/QueueInterface.php b/src/Interfaces/QueueInterface.php index a81c95e..2d68128 100644 --- a/src/Interfaces/QueueInterface.php +++ b/src/Interfaces/QueueInterface.php @@ -25,12 +25,12 @@ public function getTracks(int $start = 0, int $total = 0): array; * Add a track to the queue. * * @param string|UriInterface $track The URI of the track to add, or an object that implements the UriInterface - * @param int $position The position to insert the track in the queue (zero-based), + * @param ?int $position The position to insert the track in the queue (zero-based), * by default the track will be added to the end of the queue * * @return QueueInterface */ - public function addTrack($track, int $position = null): QueueInterface; + public function addTrack($track, ?int $position = null): QueueInterface; /** @@ -38,12 +38,12 @@ public function addTrack($track, int $position = null): QueueInterface; * * @param string[]|UriInterface[] $tracks An array where each element is either the URI of the tracks to add, * or an object that implements the UriInterface - * @param int $position The position to insert the tracks in the queue (zero-based), + * @param ?int $position The position to insert the tracks in the queue (zero-based), * by default the tracks will be added to the end of the queue * * @return QueueInterface */ - public function addTracks(array $tracks, int $position = null): QueueInterface; + public function addTracks(array $tracks, ?int $position = null): QueueInterface; /** diff --git a/src/Network.php b/src/Network.php index fd07b27..014833f 100644 --- a/src/Network.php +++ b/src/Network.php @@ -49,9 +49,9 @@ final class Network implements NetworkInterface, LoggerAwareInterface /** * Create a new instance. * - * @param CollectionInterface $collection The collection of devices on this network + * @param ?CollectionInterface $collection The collection of devices on this network */ - public function __construct(CollectionInterface $collection = null) + public function __construct(?CollectionInterface $collection = null) { if ($collection === null) { $collection = new Discovery(); diff --git a/src/Playlist.php b/src/Playlist.php index e1fc25f..aea6d06 100644 --- a/src/Playlist.php +++ b/src/Playlist.php @@ -90,7 +90,7 @@ protected function getNextPosition(): int * * @return void */ - protected function addUris(array $tracks, int $position = null) + protected function addUris(array $tracks, ?int $position = null) { if ($position === null) { $position = $this->getNextPosition(); diff --git a/src/Queue.php b/src/Queue.php index 086687b..d1396fb 100644 --- a/src/Queue.php +++ b/src/Queue.php @@ -43,9 +43,9 @@ class Queue implements QueueInterface * Create an instance of the Queue class. * * @param ControllerInterface $controller The Controller instance that this queue is for - * @param FactoryInterface $factory A factory to create tracks from + * @param ?FactoryInterface $factory A factory to create tracks from */ - public function __construct(ControllerInterface $controller, FactoryInterface $factory = null) + public function __construct(ControllerInterface $controller, ?FactoryInterface $factory = null) { $this->id = "Q:0"; $this->updateId = 0; @@ -182,12 +182,12 @@ protected function getNextPosition(): int * Add multiple uris to the queue. * * @param UriInterface[] $tracks The track to add - * @param int $position The position to insert the track in the queue (zero-based), + * @param ?int $position The position to insert the track in the queue (zero-based), * by default the track will be added to the end of the queue * * @return void */ - protected function addUris(array $tracks, int $position = null) + protected function addUris(array $tracks, ?int $position = null) { if ($position === null) { $position = $this->getNextPosition(); @@ -237,12 +237,12 @@ protected function addUris(array $tracks, int $position = null) * Add a track to the queue. * * @param string|UriInterface $track The URI of the track to add, or an object that implements the UriInterface - * @param int $position The position to insert the track in the queue (zero-based), + * @param ?int $position The position to insert the track in the queue (zero-based), * by default the track will be added to the end of the queue * * @return $this */ - public function addTrack($track, int $position = null): QueueInterface + public function addTrack($track, ?int $position = null): QueueInterface { # If a simple uri has been passed then convert it to a Track instance if (is_string($track)) { @@ -275,12 +275,12 @@ public function addTrack($track, int $position = null): QueueInterface * * @param string[]|UriInterface[] $tracks An array where each element is either the URI of the tracks to add, * or an object that implements the UriInterface - * @param int $position The position to insert the tracks in the queue (zero-based), + * @param ?int $position The position to insert the tracks in the queue (zero-based), * by default the tracks will be added to the end of the queue * * @return $this */ - public function addTracks(array $tracks, int $position = null): QueueInterface + public function addTracks(array $tracks, ?int $position = null): QueueInterface { $uris = []; foreach ($tracks as $track) {