From 902779dfa3c85d47eaa9e5bb983483533c3fb829 Mon Sep 17 00:00:00 2001 From: Hug0-Drelon Date: Thu, 30 Oct 2025 13:40:42 +0100 Subject: [PATCH 1/5] Bump szepeviktor/phpstan-wordpress and align php and phpunit requirements. --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index f71a366..01a3e60 100644 --- a/composer.json +++ b/composer.json @@ -5,10 +5,11 @@ "homepage": "https://polylang.pro", "type": "library", "require": { - "szepeviktor/phpstan-wordpress": "^1.0" + "php": "^7.4 || ^8.0", + "szepeviktor/phpstan-wordpress": "^2.0" }, "require-dev": { - "phpunit/phpunit": "^7 || ^9", + "phpunit/phpunit": "^9", "wpsyntex/polylang-stubs": "dev-master" }, "autoload": { From 82059f733ae602465eba49d888af5aacfbca09fe Mon Sep 17 00:00:00 2001 From: Hug0-Drelon Date: Thu, 30 Oct 2025 14:10:17 +0100 Subject: [PATCH 2/5] Move wpsyntex/polylang-stubs from require-dev to require. --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 01a3e60..86d0fbe 100644 --- a/composer.json +++ b/composer.json @@ -6,11 +6,11 @@ "type": "library", "require": { "php": "^7.4 || ^8.0", - "szepeviktor/phpstan-wordpress": "^2.0" + "szepeviktor/phpstan-wordpress": "^2.0", + "wpsyntex/polylang-stubs": "dev-master" }, "require-dev": { - "phpunit/phpunit": "^9", - "wpsyntex/polylang-stubs": "dev-master" + "phpunit/phpunit": "^9" }, "autoload": { "psr-4": { From e20eb92e28955a909e9b8d75208e972724d5d321 Mon Sep 17 00:00:00 2001 From: Hug0-Drelon Date: Mon, 3 Nov 2025 16:52:38 +0100 Subject: [PATCH 3/5] Fix "Call to undefined method PHPStan\Type\Accessory\AccessoryArrayListType::intersectWith()" error. --- src/OptionsGetDynamicMethodReturnTypeExtension.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/OptionsGetDynamicMethodReturnTypeExtension.php b/src/OptionsGetDynamicMethodReturnTypeExtension.php index b79df52..1b5995c 100644 --- a/src/OptionsGetDynamicMethodReturnTypeExtension.php +++ b/src/OptionsGetDynamicMethodReturnTypeExtension.php @@ -75,11 +75,9 @@ public function getTypeFromMethodCall( MethodReflection $methodReflection, Metho case 'post_types': case 'sync': case 'taxonomies': - $returnType[] = AccessoryArrayListType::intersectWith( - new ArrayType( - new IntegerType(), - $this->getNonFalsyStringType() - ) + $returnType[] = new ArrayType( + new IntegerType(), + $this->getNonFalsyStringType() ); break; From fc8c335172e7a377a086d5a9aa3959d69732cb89 Mon Sep 17 00:00:00 2001 From: Hug0-Drelon Date: Wed, 5 Nov 2025 11:50:31 +0100 Subject: [PATCH 4/5] Use trinary logic instead of instance checks. --- src/GuessTypeFromSwitcherAttributes.php | 5 ++--- ...lLanguagesGetListDynamicMethodReturnTypeExtension.php | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/GuessTypeFromSwitcherAttributes.php b/src/GuessTypeFromSwitcherAttributes.php index 5394bf9..1375d9e 100644 --- a/src/GuessTypeFromSwitcherAttributes.php +++ b/src/GuessTypeFromSwitcherAttributes.php @@ -8,7 +8,6 @@ use PHPStan\Analyser\Scope; use PHPStan\TrinaryLogic; use PHPStan\Type\Type; -use PHPStan\Type\Constant\ConstantArrayType; use PHPStan\Type\Constant\ConstantStringType; use PHPStan\Type\IntersectionType; use PHPStan\Type\StringType; @@ -28,7 +27,7 @@ private function guessType(Arg $args, Scope $scope) : Type $argsKeys = []; $argsValues = []; - if ($argsType instanceof ArrayType) { + if ($argsType->isArray()->yes()) { $argsKeys = $argsType->getKeysArray(); $argsValues = $argsType->getValuesArray(); } @@ -42,7 +41,7 @@ private function guessType(Arg $args, Scope $scope) : Type } } - if ($argsKeys instanceof ConstantArrayType) { + if ($argsKeys->isConstantArray()->yes()) { foreach ($argsKeys->getValueTypes() as $index => $key) { if ($key->getValue() !== 'raw') { // Current argument is not 'raw' parameter. diff --git a/src/ModelLanguagesGetListDynamicMethodReturnTypeExtension.php b/src/ModelLanguagesGetListDynamicMethodReturnTypeExtension.php index 6fd7768..f4431f9 100644 --- a/src/ModelLanguagesGetListDynamicMethodReturnTypeExtension.php +++ b/src/ModelLanguagesGetListDynamicMethodReturnTypeExtension.php @@ -11,7 +11,6 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; use PHPStan\Reflection\MethodReflection; -use PHPStan\Type\Constant\ConstantArrayType; use PHPStan\Type\Constant\ConstantStringType; use PHPStan\Type\ArrayType; use PHPStan\Type\IntersectionType; @@ -60,7 +59,7 @@ public function getTypeFromMethodCall( MethodReflection $methodReflection, Metho $fieldsType = $type->getOffsetValueType( $fieldsInst ); - if ( ! $fieldsType instanceof ConstantStringType ) { + if ( $fieldsType->isString()->no() ) { // The 'field' argument is not a string. return new ArrayType( new IntegerType(), new ObjectType( PLL_Language::class ) ); } @@ -70,10 +69,10 @@ public function getTypeFromMethodCall( MethodReflection $methodReflection, Metho } } - if ( ! isset( $fieldsValue ) && $argumentType instanceof ArrayType ) { + if ( ! isset( $fieldsValue ) && $argumentType->isArray()->yes() ) { $argumentKeys = $argumentType->getKeysArray(); - if ( $argumentKeys instanceof ConstantArrayType ) { + if ( $argumentKeys->isConstantArray()->yes() ) { $argumentKeysTypes = $argumentKeys->getValueTypes(); if( empty( $argumentKeysTypes ) ) { @@ -88,7 +87,7 @@ public function getTypeFromMethodCall( MethodReflection $methodReflection, Metho $fieldsType = $argumentType->getValuesArray()->getValueTypes()[ $index ]; - if ( ! $fieldsType instanceof ConstantStringType ) { + if ( $fieldsType->isString()->no() ) { // The 'field' argument is not a string. return new ArrayType( new IntegerType(), new ObjectType( PLL_Language::class ) ); } From ee2c21105fd8267d6d615be59e37c8317085bc15 Mon Sep 17 00:00:00 2001 From: Hug0-Drelon Date: Wed, 5 Nov 2025 12:51:15 +0100 Subject: [PATCH 5/5] Change PHP requirements. --- .github/workflows/phpunit-tests.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index ae4e79a..b52bdba 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: [7.4, 8.4] + php-version: [8.0, 8.4] steps: - name: Check out the source code diff --git a/composer.json b/composer.json index 86d0fbe..f5c893f 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "homepage": "https://polylang.pro", "type": "library", "require": { - "php": "^7.4 || ^8.0", + "php": "^8.0", "szepeviktor/phpstan-wordpress": "^2.0", "wpsyntex/polylang-stubs": "dev-master" },