Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 2 additions & 3 deletions src/GuessTypeFromSwitcherAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
Expand All @@ -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.
Expand Down
9 changes: 4 additions & 5 deletions src/ModelLanguagesGetListDynamicMethodReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 ) );
}
Expand All @@ -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 ) ) {
Expand All @@ -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 ) );
}
Expand Down
8 changes: 3 additions & 5 deletions src/OptionsGetDynamicMethodReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down