From ccad07d665fa9718e0d0b26dcf94e546a09b62e9 Mon Sep 17 00:00:00 2001 From: tijmen Date: Wed, 18 Mar 2026 17:09:53 +0100 Subject: [PATCH 1/6] add phpstan --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b9b32cc..1d36f12 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,8 @@ }, "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.4 || ^9.3" + "phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.4 || ^9.3", + "phpstan/phpstan": "^2.1" }, "autoload": { From 8460635e8d69c18e409ac6379bee750b0de4e1d7 Mon Sep 17 00:00:00 2001 From: tijmen Date: Wed, 18 Mar 2026 17:10:06 +0100 Subject: [PATCH 2/6] add config for level 4 and php 7 --- phpstan.neon | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 phpstan.neon diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..e837521 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + phpVersion: 70100 + level: 4 + paths: + - lib From 4b3608c20e6da7fb97a061234a5d353e6299a1da Mon Sep 17 00:00:00 2001 From: tijmen Date: Wed, 18 Mar 2026 17:10:14 +0100 Subject: [PATCH 3/6] add workflow --- .github/workflows/phpstan.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/phpstan.yaml diff --git a/.github/workflows/phpstan.yaml b/.github/workflows/phpstan.yaml new file mode 100644 index 0000000..517f090 --- /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 install --no-ansi --no-interaction --no-progress + - name: Run PHPStan + run: vendor/bin/phpstan analyse From 9c4c2a833c648c286e3a2e211f37bcf76cff8d6e Mon Sep 17 00:00:00 2001 From: tijmen Date: Wed, 18 Mar 2026 17:10:27 +0100 Subject: [PATCH 4/6] curl_init will never return null --- lib/Tinify/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Tinify/Client.php b/lib/Tinify/Client.php index 0d8ed0c..0584fcc 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." ); From 9fce86338aa77195261b9b2817fd54ef5a6c92dc Mon Sep 17 00:00:00 2001 From: tijmen Date: Wed, 18 Mar 2026 17:25:06 +0100 Subject: [PATCH 5/6] set level 5, does not throw more errors --- phpstan.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index e837521..d6b47fe 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: phpVersion: 70100 - level: 4 + level: 5 paths: - lib From cc9225a386fda313d7eee5581a707544d57a8f75 Mon Sep 17 00:00:00 2001 From: tijmen Date: Wed, 25 Mar 2026 17:05:41 +0100 Subject: [PATCH 6/6] Add seperate workflow for phpstan --- .github/workflows/phpstan.yaml | 4 ++-- .gitignore | 2 ++ composer.json | 3 +-- composer.phpstan.json | 9 +++++++++ 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 composer.phpstan.json diff --git a/.github/workflows/phpstan.yaml b/.github/workflows/phpstan.yaml index 517f090..978d955 100644 --- a/.github/workflows/phpstan.yaml +++ b/.github/workflows/phpstan.yaml @@ -16,6 +16,6 @@ jobs: php-version: "7.4" tools: composer:v2 - name: Install Dependencies - run: composer install --no-ansi --no-interaction --no-progress + run: COMPOSER=composer.phpstan.json composer install --no-ansi --no-interaction --no-progress - name: Run PHPStan - run: vendor/bin/phpstan analyse + 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.json b/composer.json index 1d36f12..b9b32cc 100644 --- a/composer.json +++ b/composer.json @@ -30,8 +30,7 @@ }, "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.4 || ^9.3", - "phpstan/phpstan": "^2.1" + "phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.4 || ^9.3" }, "autoload": { 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" + } +}