Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
seba-aln committed Feb 4, 2025
1 parent a0178cb commit 6725275
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 168 deletions.
45 changes: 0 additions & 45 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1371,16 +1371,6 @@ parameters:
count: 1
path: src/PubNub/Endpoints/Objects/Member/GetMembers.php

-
message: "#^Method PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\GetMembers\\:\\:validateParams\\(\\) has no return type specified\\.$#"
count: 1
path: src/PubNub/Endpoints/Objects/Member/GetMembers.php

-
message: "#^PHPDoc tag @throws with type PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\PubNubBuildRequestException is not subtype of Throwable$#"
count: 1
path: src/PubNub/Endpoints/Objects/Member/GetMembers.php

-
message: "#^Property PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\GetMembers\\:\\:\\$include type has no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -1406,16 +1396,6 @@ parameters:
count: 1
path: src/PubNub/Endpoints/Objects/Member/RemoveMembers.php

-
message: "#^Method PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\RemoveMembers\\:\\:validateParams\\(\\) has no return type specified\\.$#"
count: 1
path: src/PubNub/Endpoints/Objects/Member/RemoveMembers.php

-
message: "#^PHPDoc tag @throws with type PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\PubNubBuildRequestException is not subtype of Throwable$#"
count: 1
path: src/PubNub/Endpoints/Objects/Member/RemoveMembers.php

-
message: "#^Property PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\RemoveMembers\\:\\:\\$include type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -1451,16 +1431,6 @@ parameters:
count: 1
path: src/PubNub/Endpoints/Objects/Member/SetMembers.php

-
message: "#^Method PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\SetMembers\\:\\:validateParams\\(\\) has no return type specified\\.$#"
count: 1
path: src/PubNub/Endpoints/Objects/Member/SetMembers.php

-
message: "#^PHPDoc tag @throws with type PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\PubNubBuildRequestException is not subtype of Throwable$#"
count: 1
path: src/PubNub/Endpoints/Objects/Member/SetMembers.php

-
message: "#^Property PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\SetMembers\\:\\:\\$custom type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -1501,11 +1471,6 @@ parameters:
count: 1
path: src/PubNub/Endpoints/Objects/Membership/GetMemberships.php

-
message: "#^PHPDoc tag @throws with type PubNub\\\\Endpoints\\\\Objects\\\\Membership\\\\PubNubBuildRequestException is not subtype of Throwable$#"
count: 1
path: src/PubNub/Endpoints/Objects/Membership/GetMemberships.php

-
message: "#^Property PubNub\\\\Endpoints\\\\Objects\\\\Membership\\\\GetMemberships\\:\\:\\$include type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -1536,11 +1501,6 @@ parameters:
count: 1
path: src/PubNub/Endpoints/Objects/Membership/RemoveMemberships.php

-
message: "#^PHPDoc tag @throws with type PubNub\\\\Endpoints\\\\Objects\\\\Membership\\\\PubNubBuildRequestException is not subtype of Throwable$#"
count: 1
path: src/PubNub/Endpoints/Objects/Membership/RemoveMemberships.php

-
message: "#^Property PubNub\\\\Endpoints\\\\Objects\\\\Membership\\\\RemoveMemberships\\:\\:\\$channels type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -1581,11 +1541,6 @@ parameters:
count: 1
path: src/PubNub/Endpoints/Objects/Membership/SetMemberships.php

-
message: "#^PHPDoc tag @throws with type PubNub\\\\Endpoints\\\\Objects\\\\Membership\\\\PubNubBuildRequestException is not subtype of Throwable$#"
count: 1
path: src/PubNub/Endpoints/Objects/Membership/SetMemberships.php

-
message: "#^Property PubNub\\\\Endpoints\\\\Objects\\\\Membership\\\\SetMemberships\\:\\:\\$channels type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down
24 changes: 12 additions & 12 deletions src/PubNub/Endpoints/Objects/Member/GetMembers.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ class GetMembers extends ObjectsCollectionEndpoint
protected string $endpointName = "GetMembers";

/** @var string */
protected $channel;
protected ?string $channel;

/** @var array */
protected $include = [];
protected array $include = [];

/** @var PNMemberIncludes */
protected ?PNMemberIncludes $includes;

/**
Expand All @@ -38,12 +39,12 @@ public function __construct(PubNub $pubnubInstance)
}

/**
* @param string $ch
* @param string $channel
* @return $this
*/
public function channel($ch)
public function channel(string $channel): self
{
$this->channel = $ch;
$this->channel = $channel;

return $this;
}
Expand All @@ -58,7 +59,7 @@ public function include(PNMemberIncludes $includes): self
* @param array $include
* @return $this
*/
public function includeFields($include)
public function includeFields(array $include): self
{
$this->include = $include;

Expand All @@ -67,19 +68,20 @@ public function includeFields($include)

/**
* @throws PubNubValidationException
* @return void
*/
protected function validateParams()
{
$this->validateSubscribeKey();

if (!is_string($this->channel)) {
if (empty($this->channel)) {
throw new PubNubValidationException("channel missing");
}
}

/**
* @return string
* @throws PubNubBuildRequestException
* @throws \PubNub\Exceptions\PubNubBuildRequestException
*/
protected function buildData()
{
Expand Down Expand Up @@ -136,10 +138,8 @@ protected function customParams()
array_push($includes, 'uuid');
}

$includesString = implode(",", $includes);

if (strlen($includesString) > 0) {
$params['include'] = $includesString;
if (!empty($includes)) {
$params['include'] = implode(",", $includes);
}
}

Expand Down
25 changes: 11 additions & 14 deletions src/PubNub/Endpoints/Objects/Member/ManageMembers.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ class ManageMembers extends ObjectsCollectionEndpoint
protected string $endpointName = "ManageMembers";

/** @var string */
protected $channel;
protected ?string $channel;

/** @var string[] */
protected $setUuids;
protected array $setUuids;

/** @var string[] */
protected $removeUuids;
protected array $removeUuids;

/** @var string[] */
protected $include = [];
protected array $include = [];

/** @var PNMemberIncludes */
protected PNMemberIncludes $includes;
Expand All @@ -56,10 +56,9 @@ public function __construct(PubNub $pubnubInstance)
* @param string $ch
* @return $this
*/
public function channel($ch)
public function channel(string $ch): self
{
$this->channel = $ch;

return $this;
}

Expand Down Expand Up @@ -93,7 +92,7 @@ public function removeUuids($uuids): self
* @param PNChannelMember[] $setMembers
* @return $this
*/
public function setMembers(array $setMembers)
public function setMembers(array $setMembers): self
{
$this->setMembers = $setMembers;
return $this;
Expand Down Expand Up @@ -145,7 +144,7 @@ protected function validateParams()
{
$this->validateSubscribeKey();

if (!is_string($this->channel)) {
if (empty($this->channel)) {
throw new PubNubValidationException("channel missing");
}
$members = !empty($this->setMembers) or !empty($this->removeMembers);
Expand All @@ -162,11 +161,11 @@ protected function validateParams()

/**
* @return string
* @throws \PubNub\Exceptions\PubNubBuildRequestException
*/
protected function buildData()
{
$set = [];
$remove = [];
if (!empty($this->setMembers)) {
foreach ($this->setMembers as $member) {
array_push($set, $member->toArray());
Expand All @@ -181,7 +180,7 @@ protected function buildData()
array_push($set, $entry);
}
}

$remove = [];
if (!empty($this->removeMembers)) {
foreach ($this->removeMembers as $member) {
array_push($remove, $member->toArray());
Expand Down Expand Up @@ -253,10 +252,8 @@ protected function customParams()
array_push($includes, 'uuid');
}

$includesString = implode(",", $includes);

if (strlen($includesString) > 0) {
$params['include'] = $includesString;
if (!empty($includes)) {
$params['include'] = implode(",", $includes);
}
}
}
Expand Down
27 changes: 12 additions & 15 deletions src/PubNub/Endpoints/Objects/Member/RemoveMembers.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class RemoveMembers extends ObjectsCollectionEndpoint
protected string $endpointName = "ManageMembers";

/** @var string */
protected $channel;
protected ?string $channel;

/** @var array */
protected $uuids;
protected array $uuids;

/** @var array */
protected $include = [];
protected array $include = [];

/** @var PNMemberIncludes */
protected PNMemberIncludes $includes;
Expand All @@ -50,7 +50,7 @@ public function __construct(PubNub $pubnubInstance)
* @param string $ch
* @return $this
*/
public function channel($ch)
public function channel(string $ch): self
{
$this->channel = $ch;

Expand All @@ -63,7 +63,7 @@ public function channel($ch)
*
* @return $this
*/
public function uuids($uuids)
public function uuids(array $uuids): self
{
$this->uuids = $uuids;

Expand All @@ -74,10 +74,9 @@ public function uuids($uuids)
* @param PNChannelMember[] $members
* @return $this
*/
public function members(array $members)
public function members(array $members): self
{
$this->members = $members;

return $this;
}

Expand All @@ -103,21 +102,21 @@ public function include(PNMemberIncludes $includes): self
* @deprecated Use include() method
* @return $this
*/
public function includeFields($include)
public function includeFields(array $include): self
{
$this->include = $include;

return $this;
}

/**
* @throws PubNubValidationException
* @return void
*/
protected function validateParams()
{
$this->validateSubscribeKey();

if (!is_string($this->channel)) {
if (empty($this->channel)) {
throw new PubNubValidationException("channel missing");
}

Expand All @@ -132,7 +131,7 @@ protected function validateParams()

/**
* @return string
* @throws PubNubBuildRequestException
* @throws \PubNub\Exceptions\PubNubBuildRequestException
*/
protected function buildData()
{
Expand Down Expand Up @@ -206,10 +205,8 @@ protected function customParams()
array_push($includes, 'uuid');
}

$includesString = implode(",", $includes);

if (strlen($includesString) > 0) {
$params['include'] = $includesString;
if (!empty($includes)) {
$params['include'] = implode(",", $includes);
}
}

Expand Down
Loading

0 comments on commit 6725275

Please sign in to comment.