From 386b27cdf13ef56be942bccae7eaaa01adfae6df Mon Sep 17 00:00:00 2001 From: Omar Date: Wed, 1 Mar 2023 16:58:31 +0100 Subject: [PATCH] Correct json decoding --- src/SecuritiesFixedCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SecuritiesFixedCommand.php b/src/SecuritiesFixedCommand.php index 680311a..ad784df 100644 --- a/src/SecuritiesFixedCommand.php +++ b/src/SecuritiesFixedCommand.php @@ -231,9 +231,9 @@ protected function saveComposerCommitStatus(string $commit_id, string $folder) { */ protected function getFolderSecurityAdvisoriesByDate(string $folder, string $date) { $date = new \DateTime($date); - $security_advisories = json_decode($this->runCommandWithKnownException(sprintf('composer audit --locked --working-dir=%s --format=json', $folder))->getOutput()); - if (!empty($security_advisories) && isset($security_advisories->advisories)) { - $security_advisories_list_by_package = (array) $security_advisories->advisories; + $security_advisories = json_decode($this->runCommandWithKnownException(sprintf('composer audit --locked --working-dir=%s --format=json', $folder))->getOutput(), TRUE); + if (!empty($security_advisories) && isset($security_advisories['advisories'])) { + $security_advisories_list_by_package = $security_advisories['advisories']; $security_advisories_list = call_user_func_array('array_merge', array_values($security_advisories_list_by_package)); $security_advisories_list = array_filter($security_advisories_list, function ($advisory) use ($date) { if (isset($advisory->reportedAt->date)) {