From c3c8e50b6a1ac8f2b311f49166ebddb96cc829f9 Mon Sep 17 00:00:00 2001 From: Daniel Kreuer Date: Mon, 9 Mar 2020 23:58:18 +0100 Subject: [PATCH 1/3] Fix returning possible null values The function may return null values but the return type annotation restricts to return strings only. This workaround prevents PHP from crashing by returning an empty string instead - which is fine because the result is sent to output. --- Command/ListClientsCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Command/ListClientsCommand.php b/Command/ListClientsCommand.php index 2cbcdc66..06f79b62 100644 --- a/Command/ListClientsCommand.php +++ b/Command/ListClientsCommand.php @@ -115,7 +115,7 @@ private function getRows(array $clients, array $columns): array ]; return array_map(static function (string $column) use ($values): string { - return $values[$column]; + return $values[$column] ?? ''; }, $columns); }, $clients); } From 011131dfce88baab49aaf3964dd50f68f0f630bc Mon Sep 17 00:00:00 2001 From: Daniel Kreuer Date: Tue, 10 Mar 2020 00:10:47 +0100 Subject: [PATCH 2/3] Add test for clients without secret --- Tests/Acceptance/ListClientsCommandTest.php | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Tests/Acceptance/ListClientsCommandTest.php b/Tests/Acceptance/ListClientsCommandTest.php index 67b5782f..30effb63 100644 --- a/Tests/Acceptance/ListClientsCommandTest.php +++ b/Tests/Acceptance/ListClientsCommandTest.php @@ -35,6 +35,28 @@ public function testListClients(): void $this->assertEquals(trim($expected), trim($output)); } + public function testListClientsWithClientHavingNoSecret(): void + { + $client = $this->fakeAClient('foobar', null); + $this->getClientManager()->save($client); + + $command = $this->command(); + $commandTester = new CommandTester($command); + $commandTester->execute([ + 'command' => $command->getName(), + ]); + $output = $commandTester->getDisplay(); + $expected = <<assertEquals(trim($expected), trim($output)); + } + public function testListClientsEmpty(): void { $command = $this->command(); From bbbf5ed8569f33d864be8e2a1c4ccd4d6c1a560a Mon Sep 17 00:00:00 2001 From: Daniel Kreuer Date: Wed, 11 Mar 2020 19:07:27 +0100 Subject: [PATCH 3/3] Fix test --- Tests/Acceptance/ListClientsCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Acceptance/ListClientsCommandTest.php b/Tests/Acceptance/ListClientsCommandTest.php index 30effb63..2c89566f 100644 --- a/Tests/Acceptance/ListClientsCommandTest.php +++ b/Tests/Acceptance/ListClientsCommandTest.php @@ -50,7 +50,7 @@ public function testListClientsWithClientHavingNoSecret(): void ------------ -------- ------- -------------- ------------ identifier secret scope redirect uri grant type ------------ -------- ------- -------------- ------------ - foobar + foobar ------------ -------- ------- -------------- ------------ TABLE;