diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4a4efc2e3..a7d6eb0fc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.1", "8.2", "8.3"] + php: ["8.1", "8.2", "8.3", "8.4"] uses: ./.github/workflows/main-php-matrix.yml with: diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 12c739f2f..07ca545c4 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,6 +4,8 @@ includes: - tests/phpstan/configs/impossible-generics.neon - tests/phpstan/configs/php-bugs.neon - tests/phpstan/configs/phpstan-bugs.neon + - tests/phpstan/configs/property-hook-sadness.neon + - tests/phpstan/configs/reflection-class-sadness.neon - tests/phpstan/configs/spl-fixed-array-sucks.neon - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/rules.neon diff --git a/src/world/generator/executor/AsyncGeneratorExecutor.php b/src/world/generator/executor/AsyncGeneratorExecutor.php index d19b6e661..007ffa5b2 100644 --- a/src/world/generator/executor/AsyncGeneratorExecutor.php +++ b/src/world/generator/executor/AsyncGeneratorExecutor.php @@ -48,7 +48,7 @@ final class AsyncGeneratorExecutor implements GeneratorExecutor{ \Logger $logger, private readonly AsyncPool $workerPool, private readonly GeneratorExecutorSetupParameters $setupParameters, - int $asyncContextId = null + ?int $asyncContextId = null ){ $this->logger = new \PrefixedLogger($logger, "AsyncGeneratorExecutor"); diff --git a/tests/phpstan/configs/property-hook-sadness.neon b/tests/phpstan/configs/property-hook-sadness.neon new file mode 100644 index 000000000..b3901993a --- /dev/null +++ b/tests/phpstan/configs/property-hook-sadness.neon @@ -0,0 +1,61 @@ +parameters: + ignoreErrors: + - + message: '#^Cannot unset property pocketmine\\entity\\Human\:\:\$enderInventory because it might have hooks in a subclass\.$#' + identifier: unset.possiblyHookedProperty + count: 1 + path: ../../../src/entity/Human.php + + - + message: '#^Cannot unset property pocketmine\\entity\\Human\:\:\$hungerManager because it might have hooks in a subclass\.$#' + identifier: unset.possiblyHookedProperty + count: 1 + path: ../../../src/entity/Human.php + + - + message: '#^Cannot unset property pocketmine\\entity\\Human\:\:\$inventory because it might have hooks in a subclass\.$#' + identifier: unset.possiblyHookedProperty + count: 1 + path: ../../../src/entity/Human.php + + - + message: '#^Cannot unset property pocketmine\\entity\\Human\:\:\$offHandInventory because it might have hooks in a subclass\.$#' + identifier: unset.possiblyHookedProperty + count: 1 + path: ../../../src/entity/Human.php + + - + message: '#^Cannot unset property pocketmine\\entity\\Human\:\:\$xpManager because it might have hooks in a subclass\.$#' + identifier: unset.possiblyHookedProperty + count: 1 + path: ../../../src/entity/Human.php + + - + message: '#^Cannot unset property pocketmine\\entity\\Living\:\:\$armorInventory because it might have hooks in a subclass\.$#' + identifier: unset.possiblyHookedProperty + count: 1 + path: ../../../src/entity/Living.php + + - + message: '#^Cannot unset property pocketmine\\entity\\Living\:\:\$effectManager because it might have hooks in a subclass\.$#' + identifier: unset.possiblyHookedProperty + count: 1 + path: ../../../src/entity/Living.php + + - + message: '#^Cannot unset property pocketmine\\player\\Player\:\:\$craftingGrid because it might have hooks in a subclass\.$#' + identifier: unset.possiblyHookedProperty + count: 1 + path: ../../../src/player/Player.php + + - + message: '#^Cannot unset property pocketmine\\player\\Player\:\:\$cursorInventory because it might have hooks in a subclass\.$#' + identifier: unset.possiblyHookedProperty + count: 1 + path: ../../../src/player/Player.php + + - + message: '#^Cannot unset property pocketmine\\world\\format\\io\\leveldb\\LevelDB\:\:\$db because it might have hooks in a subclass\.$#' + identifier: unset.possiblyHookedProperty + count: 1 + path: ../../../src/world/format/io/leveldb/LevelDB.php diff --git a/tests/phpstan/configs/reflection-class-sadness.neon b/tests/phpstan/configs/reflection-class-sadness.neon new file mode 100644 index 000000000..477a97d41 --- /dev/null +++ b/tests/phpstan/configs/reflection-class-sadness.neon @@ -0,0 +1,31 @@ +parameters: + ignoreErrors: + - + message: '#^Call\-site variance of covariant pocketmine\\event\\Event in generic type ReflectionClass\ in PHPDoc tag @param for parameter \$class is redundant, template type T of object of class ReflectionClass has the same variance\.$#' + identifier: generics.callSiteVarianceRedundant + count: 2 + path: ../../phpunit/event/HandlerListManagerTest.php + + - + message: '#^Call\-site variance of covariant pocketmine\\event\\Event in generic type ReflectionClass\ in PHPDoc tag @param for parameter \$expect is redundant, template type T of object of class ReflectionClass has the same variance\.$#' + identifier: generics.callSiteVarianceRedundant + count: 1 + path: ../../phpunit/event/HandlerListManagerTest.php + + - + message: '#^Call\-site variance of covariant pocketmine\\event\\Event in generic type ReflectionClass\ in PHPDoc tag @return is redundant, template type T of object of class ReflectionClass has the same variance\.$#' + identifier: generics.callSiteVarianceRedundant + count: 3 + path: ../../phpunit/event/HandlerListManagerTest.php + + - + message: '#^Call\-site variance of covariant pocketmine\\event\\Event in generic type ReflectionClass\ in PHPDoc tag @var for property pocketmine\\event\\HandlerListManagerTest\:\:\$isValidFunc is redundant, template type T of object of class ReflectionClass has the same variance\.$#' + identifier: generics.callSiteVarianceRedundant + count: 1 + path: ../../phpunit/event/HandlerListManagerTest.php + + - + message: '#^Call\-site variance of covariant pocketmine\\event\\Event in generic type ReflectionClass\ in PHPDoc tag @var for property pocketmine\\event\\HandlerListManagerTest\:\:\$resolveParentFunc is redundant, template type T of object of class ReflectionClass has the same variance\.$#' + identifier: generics.callSiteVarianceRedundant + count: 2 + path: ../../phpunit/event/HandlerListManagerTest.php diff --git a/tests/phpunit/event/HandlerListManagerTest.php b/tests/phpunit/event/HandlerListManagerTest.php index c61043dab..5b4f6babc 100644 --- a/tests/phpunit/event/HandlerListManagerTest.php +++ b/tests/phpunit/event/HandlerListManagerTest.php @@ -35,12 +35,12 @@ class HandlerListManagerTest extends TestCase{ /** * @var \Closure - * @phpstan-var \Closure(\ReflectionClass) : bool + * @phpstan-var \Closure(\ReflectionClass) : bool */ private $isValidFunc; /** * @var \Closure - * @phpstan-var \Closure(\ReflectionClass) : ?\ReflectionClass + * @phpstan-var \Closure(\ReflectionClass) : ?\ReflectionClass */ private $resolveParentFunc; @@ -53,7 +53,7 @@ class HandlerListManagerTest extends TestCase{ /** * @return \Generator|mixed[][] - * @phpstan-return \Generator, bool, string}, void, void> + * @phpstan-return \Generator, bool, string}, void, void> */ public static function isValidClassProvider() : \Generator{ yield [new \ReflectionClass(Event::class), false, "event base should not be handleable"]; @@ -65,7 +65,7 @@ class HandlerListManagerTest extends TestCase{ /** * @dataProvider isValidClassProvider * - * @phpstan-param \ReflectionClass $class + * @phpstan-param \ReflectionClass $class */ public function testIsValidClass(\ReflectionClass $class, bool $isValid, string $reason) : void{ self::assertSame($isValid, ($this->isValidFunc)($class), $reason); @@ -73,7 +73,7 @@ class HandlerListManagerTest extends TestCase{ /** * @return \Generator|\ReflectionClass[][] - * @phpstan-return \Generator, \ReflectionClass|null}, void, void> + * @phpstan-return \Generator, \ReflectionClass|null}, void, void> */ public static function resolveParentClassProvider() : \Generator{ yield [new \ReflectionClass(TestConcreteExtendsAllowHandleEvent::class), new \ReflectionClass(TestAbstractAllowHandleEvent::class)]; @@ -85,8 +85,8 @@ class HandlerListManagerTest extends TestCase{ /** * @dataProvider resolveParentClassProvider * - * @phpstan-param \ReflectionClass $class - * @phpstan-param \ReflectionClass|null $expect + * @phpstan-param \ReflectionClass $class + * @phpstan-param \ReflectionClass|null $expect */ public function testResolveParentClass(\ReflectionClass $class, ?\ReflectionClass $expect) : void{ if($expect === null){