diff --git a/.github/workflows/phpstan.yaml b/.github/workflows/phpstan.yaml new file mode 100644 index 0000000..978d955 --- /dev/null +++ b/.github/workflows/phpstan.yaml @@ -0,0 +1,21 @@ +--- +name: PHPStan + +on: [push, pull_request] + +permissions: {} + +jobs: + phpstan: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v6 + - uses: shivammathur/setup-php@v2 + with: + php-version: "7.4" + tools: composer:v2 + - name: Install Dependencies + run: COMPOSER=composer.phpstan.json composer install --no-ansi --no-interaction --no-progress + - name: Run PHPStan + run: vendor-phpstan/bin/phpstan analyse diff --git a/.gitignore b/.gitignore index d769eb5..3194274 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ vendor +vendor-phpstan .phpunit.result.cache composer.lock +composer.phpstan.lock diff --git a/composer.phpstan.json b/composer.phpstan.json new file mode 100644 index 0000000..223a3cf --- /dev/null +++ b/composer.phpstan.json @@ -0,0 +1,9 @@ +{ + "description": "composer for PHPStan to still support php5.4 and higher in the main composer file", + "config": { + "vendor-dir": "vendor-phpstan" + }, + "require": { + "phpstan/phpstan": "^2.1" + } +} diff --git a/lib/Tinify.php b/lib/Tinify.php index 80f533f..33c404f 100644 --- a/lib/Tinify.php +++ b/lib/Tinify.php @@ -53,15 +53,15 @@ public static function setClient($client) { } function setKey($key) { - return Tinify::setKey($key); + Tinify::setKey($key); } function setAppIdentifier($appIdentifier) { - return Tinify::setAppIdentifier($appIdentifier); + Tinify::setAppIdentifier($appIdentifier); } function setProxy($proxy) { - return Tinify::setProxy($proxy); + Tinify::setProxy($proxy); } function getCompressionCount() { diff --git a/lib/Tinify/Client.php b/lib/Tinify/Client.php index 0d8ed0c..1bc0690 100644 --- a/lib/Tinify/Client.php +++ b/lib/Tinify/Client.php @@ -87,7 +87,7 @@ function request($method, $url, $body = NULL) { } $request = curl_init(); - if ($request === false || $request === null) { + if ($request === false) { throw new ConnectionException( "Error while connecting: curl extension is not functional or disabled." ); @@ -153,6 +153,7 @@ function request($method, $url, $body = NULL) { throw new ConnectionException("Error while connecting: " . $message); } } + throw new ConnectionException("Error while connecting: max retries exceeded"); } protected static function parseHeaders($headers) { diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..d6b47fe --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + phpVersion: 70100 + level: 5 + paths: + - lib