diff --git a/composer.json b/composer.json index c9d9d97..05728ae 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,8 @@ "composer/installers": "^1.10" }, "require-dev": { - "composer/composer": "^2.0.8", - "phpstan/phpstan": "^0.12" + "composer/composer": "^2.3.0", + "phpstan/phpstan": "^1.9" }, "suggest": { "szepeviktor/composer-theme-fusion": "Composer plugin for ThemeFusion" @@ -34,5 +34,10 @@ "scripts": { "lint": "find src/ -type f -name '*.php' -print0|xargs -0 -L1 -P4 -- php -l -f", "analyze": "phpstan analyze" + }, + "config": { + "allow-plugins": { + "composer/installers": true + } } } diff --git a/src/EnvatoApi.php b/src/EnvatoApi.php index a23d0e7..fd40ff7 100644 --- a/src/EnvatoApi.php +++ b/src/EnvatoApi.php @@ -39,12 +39,12 @@ public function getVersion(int $itemId): string // TODO HTTP 429 response. Included in this response is a HTTP header Retry-After if ($response->getStatusCode() === 200) { - $versionData = \json_decode($response->getBody(), true); + $versionData = \json_decode($response->getBody() ?? '', true); // TODO Check JSON - if (\array_key_exists('wordpress_theme_latest_version', $versionData)) { + if (is_array($versionData) && \array_key_exists('wordpress_theme_latest_version', $versionData)) { return $versionData['wordpress_theme_latest_version']; } - if (\array_key_exists('wordpress_plugin_latest_version', $versionData)) { + if (is_array($versionData) && \array_key_exists('wordpress_plugin_latest_version', $versionData)) { return $versionData['wordpress_plugin_latest_version']; } } @@ -62,12 +62,12 @@ public function getDownloadUrl(int $itemId): string // TODO HTTP 429 response. Included in this response is a HTTP header Retry-After if ($response->getStatusCode() === 200) { - $urlData = \json_decode($response->getBody(), true); + $urlData = \json_decode($response->getBody() ?? '', true); // TODO Check JSON - if (\array_key_exists('wordpress_theme', $urlData)) { + if (is_array($urlData) && \array_key_exists('wordpress_theme', $urlData)) { return $urlData['wordpress_theme']; } - if (\array_key_exists('wordpress_plugin', $urlData)) { + if (is_array($urlData) && \array_key_exists('wordpress_plugin', $urlData)) { return $urlData['wordpress_plugin']; } } diff --git a/src/EnvatoPackage.php b/src/EnvatoPackage.php index d8a6682..4372306 100644 --- a/src/EnvatoPackage.php +++ b/src/EnvatoPackage.php @@ -50,7 +50,7 @@ public function getType(): string /** * {@inheritDoc} */ - public function getDistType() + public function getDistType(): string { return 'zip'; } @@ -58,7 +58,7 @@ public function getDistType() /** * {@inheritDoc} */ - public function getVersion() + public function getVersion(): string { if ($this->version !== '0.0.0.0') { return $this->version; @@ -75,7 +75,7 @@ public function getVersion() /** * {@inheritDoc} */ - public function getPrettyVersion() + public function getPrettyVersion(): string { if ($this->prettyVersion !== '0.0.0') { return $this->prettyVersion;