From 2a3a5d7938c097e08113e1ae815908168e87437d Mon Sep 17 00:00:00 2001 From: Tim Korn Date: Sat, 4 May 2024 07:35:00 +0200 Subject: [PATCH 1/6] Improve parameter-constructors and transform mixed from phpdoc to type --- src/BigBlueButton.php | 12 ++--- src/Core/Track.php | 5 +- src/Parameters/BaseParameters.php | 5 +- src/Parameters/CreateMeetingParameters.php | 39 ++++------------ src/Parameters/DeleteRecordingsParameters.php | 8 ++-- src/Parameters/EndMeetingParameters.php | 12 +++-- src/Parameters/GetMeetingInfoParameters.php | 10 ++-- .../GetRecordingTextTracksParameters.php | 6 +-- src/Parameters/InsertDocumentParameters.php | 6 +-- src/Parameters/IsMeetingRunningParameters.php | 6 +-- src/Parameters/JoinMeetingParameters.php | 46 ++++++++----------- src/Parameters/MetaParameters.php | 17 ++----- .../PublishRecordingsParameters.php | 10 ++-- .../PutRecordingTextTrackParameters.php | 18 ++++---- src/Parameters/UpdateRecordingsParameters.php | 6 +-- src/Parameters/UserDataParameters.php | 17 ++----- src/Responses/BaseJsonResponse.php | 6 +-- tests/TestCase.php | 39 ++++------------ tests/TestServices/Fixtures.php | 9 +--- 19 files changed, 95 insertions(+), 182 deletions(-) diff --git a/src/BigBlueButton.php b/src/BigBlueButton.php index d0576293..ae08b5e5 100644 --- a/src/BigBlueButton.php +++ b/src/BigBlueButton.php @@ -302,11 +302,9 @@ public function getRecordingsUrl(GetRecordingsParameters $recordingsParams): str } /** - * @param mixed $recordingParams - * * @throws BadResponseException|\RuntimeException */ - public function getRecordings($recordingParams): GetRecordingsResponse + public function getRecordings(mixed $recordingParams): GetRecordingsResponse { $xml = $this->processXmlResponse($this->getUrlBuilder()->getRecordingsUrl($recordingParams)); @@ -414,11 +412,9 @@ public function getHooksCreateUrl(HooksCreateParameters $hookCreateParams): stri } /** - * @param mixed $hookCreateParams - * * @throws BadResponseException */ - public function hooksCreate($hookCreateParams): HooksCreateResponse + public function hooksCreate(mixed $hookCreateParams): HooksCreateResponse { $xml = $this->processXmlResponse($this->getUrlBuilder()->getHooksCreateUrl($hookCreateParams)); @@ -452,11 +448,9 @@ public function getHooksDestroyUrl(HooksDestroyParameters $hooksDestroyParams): } /** - * @param mixed $hooksDestroyParams - * * @throws BadResponseException */ - public function hooksDestroy($hooksDestroyParams): HooksDestroyResponse + public function hooksDestroy(mixed $hooksDestroyParams): HooksDestroyResponse { $xml = $this->processXmlResponse($this->getUrlBuilder()->getHooksDestroyUrl($hooksDestroyParams)); diff --git a/src/Core/Track.php b/src/Core/Track.php index d9f3ae1e..c004fc1e 100644 --- a/src/Core/Track.php +++ b/src/Core/Track.php @@ -35,10 +35,7 @@ class Track private string $source; - /** - * @param mixed $track - */ - public function __construct($track) + public function __construct(mixed $track) { $this->href = $track->href; $this->kind = $track->kind; diff --git a/src/Parameters/BaseParameters.php b/src/Parameters/BaseParameters.php index 12b7da5c..f0fd07f4 100644 --- a/src/Parameters/BaseParameters.php +++ b/src/Parameters/BaseParameters.php @@ -27,10 +27,7 @@ abstract class BaseParameters { abstract public function getHTTPQuery(): string; - /** - * @param mixed $array - */ - protected function buildHTTPQuery($array): string + protected function buildHTTPQuery(mixed $array): string { return str_replace(['%20', '!', "'", '(', ')', '*'], ['+', '%21', '%27', '%28', '%29', '%2A'], http_build_query(array_filter($array), '', '&', \PHP_QUERY_RFC3986)); } diff --git a/src/Parameters/CreateMeetingParameters.php b/src/Parameters/CreateMeetingParameters.php index 97f382e5..17b18907 100644 --- a/src/Parameters/CreateMeetingParameters.php +++ b/src/Parameters/CreateMeetingParameters.php @@ -27,9 +27,9 @@ class CreateMeetingParameters extends MetaParameters { use DocumentableTrait; - private ?string $meetingId = null; + private string $meetingId; - private ?string $meetingName = null; + private string $meetingName; /** * @deprecated Password-string replaced by an Enum\Role-constant in JoinMeetingParameters::__construct() @@ -177,11 +177,8 @@ class CreateMeetingParameters extends MetaParameters /** * CreateMeetingParameters constructor. - * - * @param mixed $meetingId - * @param mixed $meetingName */ - public function __construct($meetingId = null, $meetingName = null) + public function __construct(string $meetingId, string $meetingName) { $this->meetingId = $meetingId; $this->meetingName = $meetingName; @@ -582,12 +579,9 @@ public function isVirtualBackgroundsDisabled(): ?bool * Default: false * * @since 2.4.3 - * - * @param mixed $virtualBackgroundsDisabled - * * @deprecated Removed in 2.5, temporarily still handled, please transition to disabledFeatures. */ - public function setVirtualBackgroundsDisabled($virtualBackgroundsDisabled): self + public function setVirtualBackgroundsDisabled(mixed $virtualBackgroundsDisabled): self { $this->virtualBackgroundsDisabled = $virtualBackgroundsDisabled; @@ -943,20 +937,14 @@ public function setAllowModsToEjectCameras(bool $allowModsToEjectCameras): self return $this; } - /** - * @param mixed $endCallbackUrl - */ - public function setEndCallbackUrl($endCallbackUrl): self + public function setEndCallbackUrl(mixed $endCallbackUrl): self { $this->addMeta('endCallbackUrl', $endCallbackUrl); return $this; } - /** - * @param mixed $recordingReadyCallbackUrl - */ - public function setRecordingReadyCallbackUrl($recordingReadyCallbackUrl): self + public function setRecordingReadyCallbackUrl(mixed $recordingReadyCallbackUrl): self { $this->addMeta('bbb-recording-ready-url', $recordingReadyCallbackUrl); @@ -1055,11 +1043,9 @@ public function isBreakoutRoomsEnabled(): ?bool * * Default: true * - * @param mixed $breakoutRoomsEnabled - * * @deprecated Removed in 2.5, temporarily still handled, please transition to disabledFeatures. */ - public function setBreakoutRoomsEnabled($breakoutRoomsEnabled): self + public function setBreakoutRoomsEnabled(mixed $breakoutRoomsEnabled): self { $this->breakoutRoomsEnabled = $breakoutRoomsEnabled; @@ -1143,10 +1129,8 @@ public function isAllowRequestsWithoutSession(): ?bool * Default: false * * @since 2.4.3 - * - * @param mixed $allowRequestsWithoutSession */ - public function setAllowRequestsWithoutSession($allowRequestsWithoutSession): self + public function setAllowRequestsWithoutSession(mixed $allowRequestsWithoutSession): self { $this->allowRequestsWithoutSession = $allowRequestsWithoutSession; @@ -1349,12 +1333,7 @@ public function getBreakoutRoomsGroups(): array return $this->breakoutRoomsGroups; } - /** - * @param mixed $id - * @param mixed $name - * @param mixed $roster - */ - public function addBreakoutRoomsGroup($id, $name, $roster): self + public function addBreakoutRoomsGroup(mixed $id, mixed $name, mixed $roster): self { $this->breakoutRoomsGroups[] = ['id' => $id, 'name' => $name, 'roster' => $roster]; diff --git a/src/Parameters/DeleteRecordingsParameters.php b/src/Parameters/DeleteRecordingsParameters.php index deac0c7d..cdc4b02a 100644 --- a/src/Parameters/DeleteRecordingsParameters.php +++ b/src/Parameters/DeleteRecordingsParameters.php @@ -25,19 +25,19 @@ */ class DeleteRecordingsParameters extends BaseParameters { - private ?string $recordingId = null; + private string $recordingId; - public function __construct(?string $recordingId = null) + public function __construct(string $recordingId) { $this->recordingId = $recordingId; } - public function getRecordingId(): ?string + public function getRecordingId(): string { return $this->recordingId; } - public function setRecordingId(string $recordingId): DeleteRecordingsParameters + public function setRecordingId(string $recordingId): self { $this->recordingId = $recordingId; diff --git a/src/Parameters/EndMeetingParameters.php b/src/Parameters/EndMeetingParameters.php index c23c458b..fdb3dfc0 100644 --- a/src/Parameters/EndMeetingParameters.php +++ b/src/Parameters/EndMeetingParameters.php @@ -25,20 +25,22 @@ */ class EndMeetingParameters extends BaseParameters { - private ?string $meetingId = null; + private string $meetingId; /** + * The password of the moderator. + * * @deprecated */ - private ?string $password = null; + private ?string $password; - public function __construct(?string $meetingId = null, ?string $password = null) + public function __construct(string $meetingId, ?string $password = null) { $this->password = $password; $this->meetingId = $meetingId; } - public function getMeetingId(): ?string + public function getMeetingId(): string { return $this->meetingId; } @@ -61,7 +63,7 @@ public function getPassword(): ?string /** * @deprecated */ - public function setPassword(string $password): self + public function setPassword(?string $password): self { $this->password = $password; diff --git a/src/Parameters/GetMeetingInfoParameters.php b/src/Parameters/GetMeetingInfoParameters.php index 0d1a0ca0..c61c7e2f 100644 --- a/src/Parameters/GetMeetingInfoParameters.php +++ b/src/Parameters/GetMeetingInfoParameters.php @@ -25,18 +25,18 @@ */ class GetMeetingInfoParameters extends BaseParameters { - private ?string $meetingId = null; + private string $meetingId; private ?int $offset = null; private ?int $limit = null; - public function __construct(?string $meetingId = null) + public function __construct(string $meetingId) { $this->meetingId = $meetingId; } - public function getMeetingId(): ?string + public function getMeetingId(): string { return $this->meetingId; } @@ -53,7 +53,7 @@ public function getOffset(): ?int return $this->offset; } - public function setOffset(int $offset): self + public function setOffset(?int $offset): self { $this->offset = $offset; @@ -65,7 +65,7 @@ public function getLimit(): ?int return $this->limit; } - public function setLimit(int $limit): self + public function setLimit(?int $limit): self { $this->limit = $limit; diff --git a/src/Parameters/GetRecordingTextTracksParameters.php b/src/Parameters/GetRecordingTextTracksParameters.php index 804af3b6..1a4b84dd 100644 --- a/src/Parameters/GetRecordingTextTracksParameters.php +++ b/src/Parameters/GetRecordingTextTracksParameters.php @@ -25,17 +25,17 @@ */ class GetRecordingTextTracksParameters extends MetaParameters { - private ?string $recordId = null; + private string $recordId; /** * GetRecordingTextTracksParameters constructor. */ - public function __construct(?string $recordId = null) + public function __construct(string $recordId) { $this->recordId = $recordId; } - public function getRecordId(): ?string + public function getRecordId(): string { return $this->recordId; } diff --git a/src/Parameters/InsertDocumentParameters.php b/src/Parameters/InsertDocumentParameters.php index 671e849d..c2ab42ce 100644 --- a/src/Parameters/InsertDocumentParameters.php +++ b/src/Parameters/InsertDocumentParameters.php @@ -27,14 +27,14 @@ class InsertDocumentParameters extends BaseParameters { use DocumentableTrait; - private ?string $meetingId = null; + private string $meetingId; - public function __construct(?string $meetingId = null) + public function __construct(string $meetingId) { $this->meetingId = $meetingId; } - public function getMeetingId(): ?string + public function getMeetingId(): string { return $this->meetingId; } diff --git a/src/Parameters/IsMeetingRunningParameters.php b/src/Parameters/IsMeetingRunningParameters.php index f7cfa7ae..017f3603 100644 --- a/src/Parameters/IsMeetingRunningParameters.php +++ b/src/Parameters/IsMeetingRunningParameters.php @@ -25,14 +25,14 @@ */ class IsMeetingRunningParameters extends BaseParameters { - private ?string $meetingId = null; + private string $meetingId; - public function __construct(?string $meetingId = null) + public function __construct(string $meetingId) { $this->meetingId = $meetingId; } - public function getMeetingId(): ?string + public function getMeetingId(): string { return $this->meetingId; } diff --git a/src/Parameters/JoinMeetingParameters.php b/src/Parameters/JoinMeetingParameters.php index 9f79b8a5..f5b5e6db 100644 --- a/src/Parameters/JoinMeetingParameters.php +++ b/src/Parameters/JoinMeetingParameters.php @@ -27,9 +27,9 @@ */ class JoinMeetingParameters extends UserDataParameters { - private ?string $meetingId; + private string $meetingId; - private ?string $username; + private string $username; /** * @deprecated Password-string replaced by an Enum\Role-constant in JoinMeetingParameters::__construct() @@ -49,7 +49,7 @@ class JoinMeetingParameters extends UserDataParameters /** * @var array */ - private array $customParameters; + private array $customParameters = []; private ?string $role = null; @@ -59,12 +59,7 @@ class JoinMeetingParameters extends UserDataParameters private ?string $defaultLayout = null; - /** - * @param mixed $passwordOrRole - * @param mixed $meetingId - * @param mixed $username - */ - public function __construct($meetingId = null, $username = null, $passwordOrRole = null) + public function __construct(string $meetingId, string $username, string $passwordOrRole) { $this->meetingId = $meetingId; $this->username = $username; @@ -74,22 +69,21 @@ public function __construct($meetingId = null, $username = null, $passwordOrRole } else { $this->password = $passwordOrRole; } - $this->customParameters = []; } - public function getMeetingId(): ?string + public function getMeetingId(): string { return $this->meetingId; } - public function setMeetingId(string $meetingId): JoinMeetingParameters + public function setMeetingId(string $meetingId): self { $this->meetingId = $meetingId; return $this; } - public function getUsername(): ?string + public function getUsername(): string { return $this->username; } @@ -101,6 +95,18 @@ public function setUsername(string $username): self return $this; } + public function getRole(): ?string + { + return $this->role; + } + + public function setRole(?string $role): self + { + $this->role = $role; + + return $this; + } + /** * @deprecated Password-string replaced by an Enum\Role-constant in JoinMeetingParameters::__construct() */ @@ -112,7 +118,7 @@ public function getPassword(): ?string /** *@deprecated Password-string replaced by an Enum\Role-constant in JoinMeetingParameters::__construct() */ - public function setPassword(string $password): self + public function setPassword(?string $password): self { $this->password = $password; @@ -179,18 +185,6 @@ public function setRedirect(bool $redirect): self return $this; } - public function getRole(): ?string - { - return $this->role; - } - - public function setRole(string $role): self - { - $this->role = $role; - - return $this; - } - public function isExcludeFromDashboard(): ?bool { return $this->excludeFromDashboard; diff --git a/src/Parameters/MetaParameters.php b/src/Parameters/MetaParameters.php index a97b158f..c2fc5175 100644 --- a/src/Parameters/MetaParameters.php +++ b/src/Parameters/MetaParameters.php @@ -30,30 +30,19 @@ abstract class MetaParameters extends BaseParameters */ private array $meta = []; - /** - * @return mixed - */ - public function getMeta(string $key) + public function getMeta(string $key): mixed { return $this->meta[$key]; } - /** - * @param mixed $value - * - * @return $this - */ - public function addMeta(string $key, $value) + public function addMeta(string $key, mixed $value): self { $this->meta[$key] = $value; return $this; } - /** - * @param mixed $queries - */ - protected function buildMeta(&$queries): void + protected function buildMeta(mixed &$queries): void { if (0 !== count($this->meta)) { foreach ($this->meta as $key => $value) { diff --git a/src/Parameters/PublishRecordingsParameters.php b/src/Parameters/PublishRecordingsParameters.php index ecb9b5a7..6ed74d64 100644 --- a/src/Parameters/PublishRecordingsParameters.php +++ b/src/Parameters/PublishRecordingsParameters.php @@ -25,17 +25,17 @@ */ class PublishRecordingsParameters extends BaseParameters { - private ?string $recordingId = null; + private string $recordingId; - private ?bool $publish = null; + private bool $publish; - public function __construct(string $recordingId, ?bool $publish = null) + public function __construct(string $recordingId, bool $publish) { $this->recordingId = $recordingId; $this->publish = $publish; } - public function getRecordingId(): ?string + public function getRecordingId(): string { return $this->recordingId; } @@ -47,7 +47,7 @@ public function setRecordingId(string $recordingId): self return $this; } - public function isPublish(): ?bool + public function isPublish(): bool { return $this->publish; } diff --git a/src/Parameters/PutRecordingTextTrackParameters.php b/src/Parameters/PutRecordingTextTrackParameters.php index ab8e0409..7471b3c6 100644 --- a/src/Parameters/PutRecordingTextTrackParameters.php +++ b/src/Parameters/PutRecordingTextTrackParameters.php @@ -25,18 +25,18 @@ */ class PutRecordingTextTrackParameters extends BaseParameters { - private ?string $recordId = null; + private string $recordId; - private ?string $kind = null; + private string $kind; - private ?string $lang = null; + private string $lang; - private ?string $label = null; + private string $label; /** * PutRecordingTextTrackParameters constructor. */ - public function __construct(?string $recordId = null, ?string $kind = null, ?string $lang = null, ?string $label = null) + public function __construct(string $recordId, string $kind, string $lang, string $label) { $this->recordId = $recordId; $this->kind = $kind; @@ -44,7 +44,7 @@ public function __construct(?string $recordId = null, ?string $kind = null, ?str $this->label = $label; } - public function getRecordId(): ?string + public function getRecordId(): string { return $this->recordId; } @@ -56,7 +56,7 @@ public function setRecordId(string $recordId): self return $this; } - public function getKind(): ?string + public function getKind(): string { return $this->kind; } @@ -68,7 +68,7 @@ public function setKind(string $kind): self return $this; } - public function getLang(): ?string + public function getLang(): string { return $this->lang; } @@ -80,7 +80,7 @@ public function setLang(string $lang): self return $this; } - public function getLabel(): ?string + public function getLabel(): string { return $this->label; } diff --git a/src/Parameters/UpdateRecordingsParameters.php b/src/Parameters/UpdateRecordingsParameters.php index b0fe770e..f176d3bd 100644 --- a/src/Parameters/UpdateRecordingsParameters.php +++ b/src/Parameters/UpdateRecordingsParameters.php @@ -25,14 +25,14 @@ */ class UpdateRecordingsParameters extends MetaParameters { - private ?string $recordingId = null; + private string $recordingId; - public function __construct(?string $recordingId = null) + public function __construct(string $recordingId) { $this->recordingId = $recordingId; } - public function getRecordingId(): ?string + public function getRecordingId(): string { return $this->recordingId; } diff --git a/src/Parameters/UserDataParameters.php b/src/Parameters/UserDataParameters.php index e768365a..1ddd766d 100644 --- a/src/Parameters/UserDataParameters.php +++ b/src/Parameters/UserDataParameters.php @@ -27,30 +27,19 @@ abstract class UserDataParameters extends BaseParameters */ private array $userData = []; - /** - * @return mixed - */ - public function getUserData(string $key) + public function getUserData(string $key): mixed { return $this->userData[$key]; } - /** - * @param mixed $value - * - * @return $this - */ - public function addUserData(string $key, $value): self + public function addUserData(string $key, mixed $value): self { $this->userData[$key] = $value; return $this; } - /** - * @param mixed $queries - */ - protected function buildUserData(&$queries): void + protected function buildUserData(mixed &$queries): void { if (0 !== count($this->userData)) { foreach ($this->userData as $key => $value) { diff --git a/src/Responses/BaseJsonResponse.php b/src/Responses/BaseJsonResponse.php index efbc098b..fee53276 100644 --- a/src/Responses/BaseJsonResponse.php +++ b/src/Responses/BaseJsonResponse.php @@ -27,11 +27,7 @@ abstract class BaseJsonResponse { public const SUCCESS = 'SUCCESS'; public const FAILED = 'FAILED'; - - /** - * @var mixed - */ - protected $data; + protected mixed $data; public function __construct(string $json) { diff --git a/tests/TestCase.php b/tests/TestCase.php index 3ba82c67..a124d53b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -51,10 +51,7 @@ public function setUp(): void // Additional assertions - /** - * @param mixed $actual - */ - public function assertIsInteger($actual, string $message = ''): void + public function assertIsInteger(mixed $actual, string $message = ''): void { if (empty($message)) { $message = 'Got a ' . gettype($actual) . ' instead of an integer.'; @@ -62,10 +59,7 @@ public function assertIsInteger($actual, string $message = ''): void $this->assertTrue(is_integer($actual), $message); } - /** - * @param mixed $actual - */ - public function assertIsDouble($actual, string $message = ''): void + public function assertIsDouble(mixed $actual, string $message = ''): void { if (empty($message)) { $message = 'Got a ' . gettype($actual) . ' instead of a double.'; @@ -73,10 +67,7 @@ public function assertIsDouble($actual, string $message = ''): void $this->assertTrue(is_double($actual), $message); } - /** - * @param mixed $actual - */ - public function assertIsBoolean($actual, string $message = ''): void + public function assertIsBoolean(mixed $actual, string $message = ''): void { if (empty($message)) { $message = 'Got a ' . gettype($actual) . ' instead of a boolean.'; @@ -85,10 +76,9 @@ public function assertIsBoolean($actual, string $message = ''): void } /** - * @param mixed $obj * @param array $getters */ - public function assertEachGetterValueIsString($obj, array $getters): void + public function assertEachGetterValueIsString(mixed $obj, array $getters): void { foreach ($getters as $getterName) { $this->assertIsString($obj->{$getterName}(), 'Got a ' . gettype($obj->{$getterName}()) . ' instead of a string for property -> ' . $getterName); @@ -96,10 +86,9 @@ public function assertEachGetterValueIsString($obj, array $getters): void } /** - * @param mixed $obj * @param array $getters */ - public function assertEachGetterValueIsInteger($obj, array $getters): void + public function assertEachGetterValueIsInteger(mixed $obj, array $getters): void { foreach ($getters as $getterName) { $this->assertIsInteger($obj->{$getterName}(), 'Got a ' . gettype($obj->{$getterName}()) . ' instead of an integer for property -> ' . $getterName); @@ -107,10 +96,9 @@ public function assertEachGetterValueIsInteger($obj, array $getters): void } /** - * @param mixed $obj * @param array $getters */ - public function assertEachGetterValueIsNull($obj, array $getters): void + public function assertEachGetterValueIsNull(mixed $obj, array $getters): void { foreach ($getters as $getterName) { $this->assertNull($obj->{$getterName}(), 'Got a ' . gettype($obj->{$getterName}()) . ' instead of NULL for property -> ' . $getterName); @@ -118,10 +106,9 @@ public function assertEachGetterValueIsNull($obj, array $getters): void } /** - * @param mixed $obj * @param array $getters */ - public function assertEachGetterValueIsDouble($obj, array $getters): void + public function assertEachGetterValueIsDouble(mixed $obj, array $getters): void { foreach ($getters as $getterName) { $this->assertIsDouble($obj->{$getterName}(), 'Got a ' . gettype($obj->{$getterName}()) . ' instead of a double for property -> ' . $getterName); @@ -129,10 +116,9 @@ public function assertEachGetterValueIsDouble($obj, array $getters): void } /** - * @param mixed $obj * @param array $getters */ - public function assertEachGetterValueIsBoolean($obj, array $getters): void + public function assertEachGetterValueIsBoolean(mixed $obj, array $getters): void { foreach ($getters as $getterName) { $this->assertIsBoolean($obj->{$getterName}(), 'Got a ' . gettype($obj->{$getterName}()) . ' instead of a boolean for property -> ' . $getterName); @@ -235,11 +221,9 @@ protected function generateBreakoutRoomsGroups(): array } /** - * @param mixed $createParams - * * @return array */ - protected function generateBreakoutCreateParams($createParams): array + protected function generateBreakoutCreateParams(mixed $createParams): array { return array_merge($createParams, [ 'isBreakout' => true, @@ -324,10 +308,7 @@ protected function getCreateMock(array $params): CreateMeetingParameters ; } - /** - * @param mixed $params - */ - protected function getBreakoutCreateMock($params): CreateMeetingParameters + protected function getBreakoutCreateMock(mixed $params): CreateMeetingParameters { $createMeetingParams = $this->getCreateMock($params); diff --git a/tests/TestServices/Fixtures.php b/tests/TestServices/Fixtures.php index 5a5f3134..42a3c8d6 100644 --- a/tests/TestServices/Fixtures.php +++ b/tests/TestServices/Fixtures.php @@ -169,11 +169,9 @@ public static function generateBreakoutRoomsGroups(): array } /** - * @param mixed $createParams - * * @return array */ - public static function generateBreakoutCreateParams($createParams): array + public static function generateBreakoutCreateParams(mixed $createParams): array { $faker = Faker::create(); @@ -309,10 +307,7 @@ public static function getCreateMeetingParametersMock(array $params): CreateMeet ; } - /** - * @param mixed $params - */ - public static function getBreakoutCreateMock($params): CreateMeetingParameters + public static function getBreakoutCreateMock(mixed $params): CreateMeetingParameters { $createMeetingParams = Fixtures::getCreateMeetingParametersMock($params); From ea8d09241ec4bf89745694d97029652feb64371b Mon Sep 17 00:00:00 2001 From: Tim Korn Date: Sat, 4 May 2024 07:48:46 +0200 Subject: [PATCH 2/6] Make PhpStan happy again --- src/Parameters/MetaParameters.php | 2 +- src/Parameters/PublishRecordingsParameters.php | 2 +- src/Parameters/UserDataParameters.php | 2 +- tests/BigBlueButtonTest.php | 8 ++++++-- tests/Parameters/CreateMeetingParametersTest.php | 5 ++++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Parameters/MetaParameters.php b/src/Parameters/MetaParameters.php index c2fc5175..d47a8711 100644 --- a/src/Parameters/MetaParameters.php +++ b/src/Parameters/MetaParameters.php @@ -35,7 +35,7 @@ public function getMeta(string $key): mixed return $this->meta[$key]; } - public function addMeta(string $key, mixed $value): self + public function addMeta(string $key, mixed $value): static { $this->meta[$key] = $value; diff --git a/src/Parameters/PublishRecordingsParameters.php b/src/Parameters/PublishRecordingsParameters.php index 6ed74d64..f5217758 100644 --- a/src/Parameters/PublishRecordingsParameters.php +++ b/src/Parameters/PublishRecordingsParameters.php @@ -64,7 +64,7 @@ public function getHTTPQuery(): string return $this->buildHTTPQuery( [ 'recordID' => $this->recordingId, - 'publish' => !is_null($this->publish) ? ($this->publish ? 'true' : 'false') : $this->publish, + 'publish' => $this->publish ? 'true' : 'false', ] ); } diff --git a/src/Parameters/UserDataParameters.php b/src/Parameters/UserDataParameters.php index 1ddd766d..60e81f6a 100644 --- a/src/Parameters/UserDataParameters.php +++ b/src/Parameters/UserDataParameters.php @@ -32,7 +32,7 @@ public function getUserData(string $key): mixed return $this->userData[$key]; } - public function addUserData(string $key, mixed $value): self + public function addUserData(string $key, mixed $value): static { $this->userData[$key] = $value; diff --git a/tests/BigBlueButtonTest.php b/tests/BigBlueButtonTest.php index 57799876..d24551b3 100644 --- a/tests/BigBlueButtonTest.php +++ b/tests/BigBlueButtonTest.php @@ -150,8 +150,10 @@ public function testCreateMeetingWithDocumentUrlAndFileName(): void public function testCreateMeetingWithDocumentEmbedded(): void { $params = Fixtures::getCreateMeetingParametersMock(Fixtures::generateCreateParams()); + $file = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'bbb_logo.png'); + $this->assertIsString($file); - $params->addPresentation('bbb_logo.png', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'bbb_logo.png')); + $params->addPresentation('bbb_logo.png', $file); $result = $this->bbb->createMeeting($params); @@ -165,9 +167,11 @@ public function testCreateMeetingWithDocumentEmbedded(): void */ public function testCreateMeetingWithMultiDocument(): void { + $file = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'bbb_logo.png'); + $this->assertIsString($file); $params = Fixtures::getCreateMeetingParametersMock(Fixtures::generateCreateParams()); $params->addPresentation('https://picsum.photos/3840/2160/?random', null, 'presentation.png'); - $params->addPresentation('logo.png', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'bbb_logo.png')); + $params->addPresentation('logo.png', $file); $result = $this->bbb->createMeeting($params); diff --git a/tests/Parameters/CreateMeetingParametersTest.php b/tests/Parameters/CreateMeetingParametersTest.php index 55b0f77c..91c32e87 100644 --- a/tests/Parameters/CreateMeetingParametersTest.php +++ b/tests/Parameters/CreateMeetingParametersTest.php @@ -146,8 +146,11 @@ public function testGetPresentationsAsXMLWithUrlAndFilename(): void public function testGetPresentationsAsXMLWithFile(): void { + $file = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'bbb_logo.png'); + $this->assertIsString($file); + $createMeetingParams = Fixtures::getCreateMeetingParametersMock(Fixtures::generateCreateParams()); - $createMeetingParams->addPresentation('bbb_logo.png', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'bbb_logo.png')); + $createMeetingParams->addPresentation('bbb_logo.png', $file); $this->assertXmlStringEqualsXmlFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'presentation_with_embedded_file.xml', $createMeetingParams->getPresentationsAsXML()); } } From 0a6b15bb650c54ab721a9c7e8d276c2d321570f1 Mon Sep 17 00:00:00 2001 From: Ghazi Triki Date: Tue, 7 May 2024 14:31:15 +0100 Subject: [PATCH 3/6] Revert urlBuilder property to protected scope in BigBlueButton. --- src/BigBlueButton.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BigBlueButton.php b/src/BigBlueButton.php index 039098dc..1eb5d5f5 100644 --- a/src/BigBlueButton.php +++ b/src/BigBlueButton.php @@ -84,7 +84,7 @@ class BigBlueButton protected int $timeOut = 10; protected string $jSessionId; - private UrlBuilder $urlBuilder; + protected UrlBuilder $urlBuilder; /** * @param null|array $opts From 78a30ed0b8813a61f9dce60e14ac8393faf8b5f8 Mon Sep 17 00:00:00 2001 From: Ghazi Triki Date: Tue, 7 May 2024 15:56:36 +0100 Subject: [PATCH 4/6] Update some missed strongly-typed properties in singatures. --- src/BigBlueButton.php | 6 +++--- src/Parameters/BaseParameters.php | 2 +- src/Parameters/CreateMeetingParameters.php | 6 +++--- src/Parameters/DocumentableTrait.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/BigBlueButton.php b/src/BigBlueButton.php index ae08b5e5..5b7bbb2e 100644 --- a/src/BigBlueButton.php +++ b/src/BigBlueButton.php @@ -304,7 +304,7 @@ public function getRecordingsUrl(GetRecordingsParameters $recordingsParams): str /** * @throws BadResponseException|\RuntimeException */ - public function getRecordings(mixed $recordingParams): GetRecordingsResponse + public function getRecordings(GetRecordingsParameters $recordingParams): GetRecordingsResponse { $xml = $this->processXmlResponse($this->getUrlBuilder()->getRecordingsUrl($recordingParams)); @@ -414,7 +414,7 @@ public function getHooksCreateUrl(HooksCreateParameters $hookCreateParams): stri /** * @throws BadResponseException */ - public function hooksCreate(mixed $hookCreateParams): HooksCreateResponse + public function hooksCreate(HooksCreateParameters $hookCreateParams): HooksCreateResponse { $xml = $this->processXmlResponse($this->getUrlBuilder()->getHooksCreateUrl($hookCreateParams)); @@ -450,7 +450,7 @@ public function getHooksDestroyUrl(HooksDestroyParameters $hooksDestroyParams): /** * @throws BadResponseException */ - public function hooksDestroy(mixed $hooksDestroyParams): HooksDestroyResponse + public function hooksDestroy(HooksDestroyParameters $hooksDestroyParams): HooksDestroyResponse { $xml = $this->processXmlResponse($this->getUrlBuilder()->getHooksDestroyUrl($hooksDestroyParams)); diff --git a/src/Parameters/BaseParameters.php b/src/Parameters/BaseParameters.php index f0fd07f4..25c909af 100644 --- a/src/Parameters/BaseParameters.php +++ b/src/Parameters/BaseParameters.php @@ -27,7 +27,7 @@ abstract class BaseParameters { abstract public function getHTTPQuery(): string; - protected function buildHTTPQuery(mixed $array): string + protected function buildHTTPQuery(array $array): string { return str_replace(['%20', '!', "'", '(', ')', '*'], ['+', '%21', '%27', '%28', '%29', '%2A'], http_build_query(array_filter($array), '', '&', \PHP_QUERY_RFC3986)); } diff --git a/src/Parameters/CreateMeetingParameters.php b/src/Parameters/CreateMeetingParameters.php index 17b18907..d155466d 100644 --- a/src/Parameters/CreateMeetingParameters.php +++ b/src/Parameters/CreateMeetingParameters.php @@ -581,7 +581,7 @@ public function isVirtualBackgroundsDisabled(): ?bool * @since 2.4.3 * @deprecated Removed in 2.5, temporarily still handled, please transition to disabledFeatures. */ - public function setVirtualBackgroundsDisabled(mixed $virtualBackgroundsDisabled): self + public function setVirtualBackgroundsDisabled(bool $virtualBackgroundsDisabled): self { $this->virtualBackgroundsDisabled = $virtualBackgroundsDisabled; @@ -937,14 +937,14 @@ public function setAllowModsToEjectCameras(bool $allowModsToEjectCameras): self return $this; } - public function setEndCallbackUrl(mixed $endCallbackUrl): self + public function setEndCallbackUrl(string $endCallbackUrl): self { $this->addMeta('endCallbackUrl', $endCallbackUrl); return $this; } - public function setRecordingReadyCallbackUrl(mixed $recordingReadyCallbackUrl): self + public function setRecordingReadyCallbackUrl(string $recordingReadyCallbackUrl): self { $this->addMeta('bbb-recording-ready-url', $recordingReadyCallbackUrl); diff --git a/src/Parameters/DocumentableTrait.php b/src/Parameters/DocumentableTrait.php index 44b70258..0cf0044d 100644 --- a/src/Parameters/DocumentableTrait.php +++ b/src/Parameters/DocumentableTrait.php @@ -37,7 +37,7 @@ public function getPresentations(): array return $this->presentations; } - public function addPresentation(string $nameOrUrl, ?string $content = null, ?string $filename = null, DocumentOptions $documentOptions = null): self + public function addPresentation(string $nameOrUrl, ?string $content = null, ?string $filename = null, ?DocumentOptions $documentOptions = null): self { $this->presentations[$nameOrUrl] = [ 'content' => $content ? base64_encode($content) : null, From 854c79709885024c962cddef06aa179dd5653ad0 Mon Sep 17 00:00:00 2001 From: Ghazi Triki Date: Tue, 7 May 2024 16:06:24 +0100 Subject: [PATCH 5/6] Minor signatures updates. --- src/Parameters/CreateMeetingParameters.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Parameters/CreateMeetingParameters.php b/src/Parameters/CreateMeetingParameters.php index d155466d..477d0c14 100644 --- a/src/Parameters/CreateMeetingParameters.php +++ b/src/Parameters/CreateMeetingParameters.php @@ -1045,7 +1045,7 @@ public function isBreakoutRoomsEnabled(): ?bool * * @deprecated Removed in 2.5, temporarily still handled, please transition to disabledFeatures. */ - public function setBreakoutRoomsEnabled(mixed $breakoutRoomsEnabled): self + public function setBreakoutRoomsEnabled(bool $breakoutRoomsEnabled): self { $this->breakoutRoomsEnabled = $breakoutRoomsEnabled; @@ -1130,7 +1130,7 @@ public function isAllowRequestsWithoutSession(): ?bool * * @since 2.4.3 */ - public function setAllowRequestsWithoutSession(mixed $allowRequestsWithoutSession): self + public function setAllowRequestsWithoutSession(bool $allowRequestsWithoutSession): self { $this->allowRequestsWithoutSession = $allowRequestsWithoutSession; @@ -1333,7 +1333,7 @@ public function getBreakoutRoomsGroups(): array return $this->breakoutRoomsGroups; } - public function addBreakoutRoomsGroup(mixed $id, mixed $name, mixed $roster): self + public function addBreakoutRoomsGroup(mixed $id, string $name, array $roster): self { $this->breakoutRoomsGroups[] = ['id' => $id, 'name' => $name, 'roster' => $roster]; From f67b3153d7cd6634b0f92ef8a66b0ef76905d526 Mon Sep 17 00:00:00 2001 From: Tim Korn Date: Tue, 7 May 2024 22:51:10 +0200 Subject: [PATCH 6/6] make phpstan happy --- src/Parameters/BaseParameters.php | 3 +++ src/Parameters/CreateMeetingParameters.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/Parameters/BaseParameters.php b/src/Parameters/BaseParameters.php index 25c909af..2ff81800 100644 --- a/src/Parameters/BaseParameters.php +++ b/src/Parameters/BaseParameters.php @@ -27,6 +27,9 @@ abstract class BaseParameters { abstract public function getHTTPQuery(): string; + /** + * @param array $array + */ protected function buildHTTPQuery(array $array): string { return str_replace(['%20', '!', "'", '(', ')', '*'], ['+', '%21', '%27', '%28', '%29', '%2A'], http_build_query(array_filter($array), '', '&', \PHP_QUERY_RFC3986)); diff --git a/src/Parameters/CreateMeetingParameters.php b/src/Parameters/CreateMeetingParameters.php index 477d0c14..09682a0e 100644 --- a/src/Parameters/CreateMeetingParameters.php +++ b/src/Parameters/CreateMeetingParameters.php @@ -1333,6 +1333,9 @@ public function getBreakoutRoomsGroups(): array return $this->breakoutRoomsGroups; } + /** + * @param array $roster + */ public function addBreakoutRoomsGroup(mixed $id, string $name, array $roster): self { $this->breakoutRoomsGroups[] = ['id' => $id, 'name' => $name, 'roster' => $roster];