From dedc1dffd471149753f668d44083017a34f247ae Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Mon, 8 Jan 2024 21:58:43 +0530 Subject: [PATCH 1/6] Added usort at root level to provide common sort output at all displays --- src/Api/Management/Entity/App.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Api/Management/Entity/App.php b/src/Api/Management/Entity/App.php index 0b030015..962c1ce5 100644 --- a/src/Api/Management/Entity/App.php +++ b/src/Api/Management/Entity/App.php @@ -187,6 +187,9 @@ public function setCallbackUrl(string $callbackUrl): void */ public function getCredentials(): array { + usort($this->credentials, function (AppCredentialInterface $a, AppCredentialInterface $b) { + return $b->getIssuedAt()->getTimestamp() <=> $a->getIssuedAt()->getTimestamp(); + }); return $this->credentials; } From a198ecf59ba0c26b263a023abc57873c6b8c11d9 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Mon, 8 Jan 2024 22:41:53 +0530 Subject: [PATCH 2/6] Fixing indentation style --- src/Api/Management/Entity/App.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/Management/Entity/App.php b/src/Api/Management/Entity/App.php index 962c1ce5..152288a5 100644 --- a/src/Api/Management/Entity/App.php +++ b/src/Api/Management/Entity/App.php @@ -188,7 +188,7 @@ public function setCallbackUrl(string $callbackUrl): void public function getCredentials(): array { usort($this->credentials, function (AppCredentialInterface $a, AppCredentialInterface $b) { - return $b->getIssuedAt()->getTimestamp() <=> $a->getIssuedAt()->getTimestamp(); + return $b->getIssuedAt()->getTimestamp() <=> $a->getIssuedAt()->getTimestamp(); }); return $this->credentials; } From cb15b65f00f08b2dc88ea92239210c22074400ea Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Tue, 9 Jan 2024 18:54:30 +0530 Subject: [PATCH 3/6] PHP CS fixes --- src/Api/Management/Entity/App.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Api/Management/Entity/App.php b/src/Api/Management/Entity/App.php index 152288a5..06e0d015 100644 --- a/src/Api/Management/Entity/App.php +++ b/src/Api/Management/Entity/App.php @@ -25,6 +25,7 @@ use Apigee\Edge\Entity\Property\ScopesPropertyAwareTrait; use Apigee\Edge\Entity\Property\StatusPropertyAwareTrait; use Apigee\Edge\Structure\AttributesProperty; +use LogicException; /** * Class App. @@ -55,7 +56,7 @@ abstract class App extends Entity implements AppInterface /** @var string Url, used for "three-legged" OAuth grant type flows. */ protected $callbackUrl; - /** @var \Apigee\Edge\Api\Management\Entity\AppCredential[] */ + /** @var AppCredential[] */ protected $credentials = []; /** @var string[] */ @@ -190,6 +191,7 @@ public function getCredentials(): array usort($this->credentials, function (AppCredentialInterface $a, AppCredentialInterface $b) { return $b->getIssuedAt()->getTimestamp() <=> $a->getIssuedAt()->getTimestamp(); }); + return $this->credentials; } @@ -198,7 +200,7 @@ public function getCredentials(): array * * Credentials, included in app, can not be changed by modifying them on the entity level. * - * @param \Apigee\Edge\Api\Management\Entity\AppCredentialInterface ...$credentials + * @param AppCredentialInterface ...$credentials * * @internal */ @@ -241,14 +243,14 @@ final public function getApiProducts(): array * * @param array $initialApiProducts * - * @throws \LogicException If used to update existing App. + * @throws LogicException If used to update existing App. */ final public function setInitialApiProducts(array $initialApiProducts): void { if (!$this->appId) { $this->initialApiProducts = $initialApiProducts; } else { - throw new \LogicException('This method is only supported for creating a new app.'); + throw new LogicException('This method is only supported for creating a new app.'); } } } From 1eec02c306bf065b524b303f402897a942ef7c77 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Tue, 9 Jan 2024 18:58:00 +0530 Subject: [PATCH 4/6] Arrow function used --- src/Api/Management/Entity/App.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Api/Management/Entity/App.php b/src/Api/Management/Entity/App.php index 06e0d015..a7b1be7d 100644 --- a/src/Api/Management/Entity/App.php +++ b/src/Api/Management/Entity/App.php @@ -188,10 +188,7 @@ public function setCallbackUrl(string $callbackUrl): void */ public function getCredentials(): array { - usort($this->credentials, function (AppCredentialInterface $a, AppCredentialInterface $b) { - return $b->getIssuedAt()->getTimestamp() <=> $a->getIssuedAt()->getTimestamp(); - }); - + usort($this->credentials, static fn(AppCredentialInterface $a, AppCredentialInterface $b) => $b->getIssuedAt()->getTimestamp() <=> $a->getIssuedAt()->getTimestamp()); return $this->credentials; } From 0a2191625f04e59c3a4d17283edae2e362043595 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Tue, 9 Jan 2024 19:04:55 +0530 Subject: [PATCH 5/6] PHP CS FIX --- src/Api/Management/Entity/App.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Api/Management/Entity/App.php b/src/Api/Management/Entity/App.php index a7b1be7d..0e5017f9 100644 --- a/src/Api/Management/Entity/App.php +++ b/src/Api/Management/Entity/App.php @@ -188,7 +188,8 @@ public function setCallbackUrl(string $callbackUrl): void */ public function getCredentials(): array { - usort($this->credentials, static fn(AppCredentialInterface $a, AppCredentialInterface $b) => $b->getIssuedAt()->getTimestamp() <=> $a->getIssuedAt()->getTimestamp()); + usort($this->credentials, static fn (AppCredentialInterface $a, AppCredentialInterface $b) => $b->getIssuedAt()->getTimestamp() <=> $a->getIssuedAt()->getTimestamp()); + return $this->credentials; } From 6a0db830982fcfa5d2f20d64d7df7e6f52d641f4 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Tue, 9 Jan 2024 19:29:54 +0530 Subject: [PATCH 6/6] Chnages to fix PossiblyNullReference error --- src/Api/Management/Entity/App.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/Management/Entity/App.php b/src/Api/Management/Entity/App.php index 0e5017f9..b089189d 100644 --- a/src/Api/Management/Entity/App.php +++ b/src/Api/Management/Entity/App.php @@ -188,7 +188,7 @@ public function setCallbackUrl(string $callbackUrl): void */ public function getCredentials(): array { - usort($this->credentials, static fn (AppCredentialInterface $a, AppCredentialInterface $b) => $b->getIssuedAt()->getTimestamp() <=> $a->getIssuedAt()->getTimestamp()); + usort($this->credentials, static fn (AppCredentialInterface $a, AppCredentialInterface $b) => $b->getIssuedAt() <=> $a->getIssuedAt()); return $this->credentials; }