diff --git a/composer.json b/composer.json index fb8ebe8..8cd42f5 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "nikic/php-parser": "^4.13", "php-stubs/generator": "^0.8.3", "phpdocumentor/reflection-docblock": "^5.4.1", - "phpstan/phpstan": "^1.11", + "phpstan/phpstan": "^2.1", "phpunit/phpunit": "^9.5", "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.1.1", "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 92981a8..c9c6402 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -7,7 +7,12 @@ parameters: - tests/ excludePaths: - tests/data/ + phpVersion: + min: 80000 + max: 80300 level: 9 - featureToggles: - alwaysTrueAlwaysReported: true - listType: true + ignoreErrors: + - + path: tests/Faker.php + identifier: class.notFound + count: 8 diff --git a/tests/Faker.php b/tests/Faker.php index cecbb79..d47e632 100644 --- a/tests/Faker.php +++ b/tests/Faker.php @@ -88,8 +88,10 @@ public static function list($type = null): array * @template T * @param T ...$types * @return T + * + * @phpcs:disable NeutronStandard.Functions.TypeHint */ - public static function union(...$types): mixed + public static function union(...$types) { return $types[0]; } diff --git a/tests/data/Faker.php b/tests/data/Faker.php index 7f5182e..042b993 100644 --- a/tests/data/Faker.php +++ b/tests/data/Faker.php @@ -26,7 +26,7 @@ assertType('non-empty-string', Faker::nonEmptyString()); // Arrays with default values -assertType('array', Faker::array()); +assertType('array', Faker::array()); assertType('array', Faker::intArray()); assertType('array', Faker::strArray()); assertType('list', Faker::list()); @@ -44,8 +44,8 @@ assertType('array|bool|int|string', Faker::union(Faker::bool(), Faker::int(), Faker::string(), Faker::intArray(Faker::int()))); assertType('array', Faker::union(Faker::intArray(Faker::int()), Faker::strArray(Faker::string()))); assertType('array', Faker::union(Faker::array(Faker::int()), Faker::strArray(Faker::string()))); -assertType('array', Faker::union(Faker::array(), Faker::strArray())); -assertType('array', Faker::union(Faker::array(), Faker::intArray())); +assertType('array', Faker::union(Faker::array(), Faker::strArray())); +assertType('array', Faker::union(Faker::array(), Faker::intArray())); assertType('string|null', Faker::union(Faker::string(), null)); // Other diff --git a/tests/data/_wp_json_sanity_check.php b/tests/data/_wp_json_sanity_check.php index ceab47f..28fdc1b 100644 --- a/tests/data/_wp_json_sanity_check.php +++ b/tests/data/_wp_json_sanity_check.php @@ -11,6 +11,6 @@ assertType('bool', _wp_json_sanity_check(Faker::bool(), 1)); assertType('int', _wp_json_sanity_check(Faker::int(), 1)); assertType('string', _wp_json_sanity_check(Faker::string(), 1)); -assertType('array', _wp_json_sanity_check(Faker::array(), 1)); +assertType('array', _wp_json_sanity_check(Faker::array(), 1)); assertType('stdClass', _wp_json_sanity_check(Faker::stdClass(), 1)); assertType('mixed', _wp_json_sanity_check(Faker::mixed(), 1)); diff --git a/tests/data/stripslashes.php b/tests/data/stripslashes.php index 3d3e8a7..1d93737 100644 --- a/tests/data/stripslashes.php +++ b/tests/data/stripslashes.php @@ -13,7 +13,7 @@ assertType('int', stripslashes_deep(Faker::int())); assertType('float', stripslashes_deep(Faker::float())); assertType('string', stripslashes_deep(Faker::string())); -assertType('array', stripslashes_deep(Faker::array())); +assertType('array', stripslashes_deep(Faker::array())); assertType('resource', stripslashes_deep(Faker::resource())); assertType('object', stripslashes_deep(Faker::object())); @@ -22,6 +22,6 @@ assertType('int', stripslashes_from_strings_only(Faker::int())); assertType('float', stripslashes_from_strings_only(Faker::float())); assertType('string', stripslashes_from_strings_only(Faker::string())); -assertType('array', stripslashes_from_strings_only(Faker::array())); +assertType('array', stripslashes_from_strings_only(Faker::array())); assertType('resource', stripslashes_from_strings_only(Faker::resource())); assertType('object', stripslashes_from_strings_only(Faker::object())); diff --git a/tests/data/wpdb.php b/tests/data/wpdb.php index 551a029..6244536 100644 --- a/tests/data/wpdb.php +++ b/tests/data/wpdb.php @@ -10,11 +10,11 @@ // wpdb::get_row() assertType('stdClass|null', wpdb::get_row()); assertType('stdClass|null', wpdb::get_row(null, 'OBJECT')); -assertType('array|null', wpdb::get_row(null, 'ARRAY_A')); +assertType('array|null', wpdb::get_row(null, 'ARRAY_A')); assertType('list|null', wpdb::get_row(null, 'ARRAY_N')); // wpdb::get_results() -assertType('list|null', wpdb::get_results(null, 'ARRAY_A')); +assertType('list>|null', wpdb::get_results(null, 'ARRAY_A')); assertType('list>|null', wpdb::get_results(null, 'ARRAY_N')); assertType('list|null', wpdb::get_results()); assertType('list|null', wpdb::get_results(null, 'OBJECT')); diff --git a/tests/phpstan.neon b/tests/phpstan.neon index 098f5a1..1673aee 100644 --- a/tests/phpstan.neon +++ b/tests/phpstan.neon @@ -1,5 +1,3 @@ parameters: bootstrapFiles: - ../wordpress-stubs.php - featureToggles: - listType: true