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 f71a366..f5c893f 100644 --- a/composer.json +++ b/composer.json @@ -5,11 +5,12 @@ "homepage": "https://polylang.pro", "type": "library", "require": { - "szepeviktor/phpstan-wordpress": "^1.0" + "php": "^8.0", + "szepeviktor/phpstan-wordpress": "^2.0", + "wpsyntex/polylang-stubs": "dev-master" }, "require-dev": { - "phpunit/phpunit": "^7 || ^9", - "wpsyntex/polylang-stubs": "dev-master" + "phpunit/phpunit": "^9" }, "autoload": { "psr-4": { 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 ) ); } 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;