From 0802d2de411f9b7c1307b4171d617620b1ea72f5 Mon Sep 17 00:00:00 2001 From: karser Date: Sun, 28 Apr 2024 23:49:26 +0300 Subject: [PATCH] added phpstan typecheck --- Tests/Form/Recaptcha3TypeTest.php | 14 +++++------ Tests/TestKernel.php | 2 +- .../Constraints/Recaptcha3ValidatorTest.php | 2 +- phpstan.neon | 24 +++++++++++++++++++ 4 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 phpstan.neon diff --git a/Tests/Form/Recaptcha3TypeTest.php b/Tests/Form/Recaptcha3TypeTest.php index 8754896..51ad653 100644 --- a/Tests/Form/Recaptcha3TypeTest.php +++ b/Tests/Form/Recaptcha3TypeTest.php @@ -27,14 +27,14 @@ public function testDefaultOptions() $form = $this->factory->create(Recaptcha3Type::class); $form->setData($data); - $this->assertTrue($form->isSynchronized()); - $this->assertEquals($data, $form->getData()); + self::assertTrue($form->isSynchronized()); + self::assertEquals($data, $form->getData()); $view = $form->createView(); - $this->assertSame(self::SITEKEY, $view->vars['site_key']); - $this->assertSame(self::HOST, $view->vars['host']); - $this->assertSame('homepage', $view->vars['action_name']); - $this->assertSame('', $view->vars['script_nonce_csp']); - $this->assertTrue($view->vars['enabled']); + self::assertSame(self::SITEKEY, $view->vars['site_key']); + self::assertSame(self::HOST, $view->vars['host']); + self::assertSame('homepage', $view->vars['action_name']); + self::assertSame('', $view->vars['script_nonce_csp']); + self::assertTrue($view->vars['enabled']); } } diff --git a/Tests/TestKernel.php b/Tests/TestKernel.php index ab37c13..a1c701c 100644 --- a/Tests/TestKernel.php +++ b/Tests/TestKernel.php @@ -22,7 +22,7 @@ public function setConfigurationFilename($filename) /** * {@inheritdoc} */ - public function registerBundles(): array + public function registerBundles(): iterable { return [ new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), diff --git a/Tests/Validator/Constraints/Recaptcha3ValidatorTest.php b/Tests/Validator/Constraints/Recaptcha3ValidatorTest.php index 140a76c..7e9d337 100644 --- a/Tests/Validator/Constraints/Recaptcha3ValidatorTest.php +++ b/Tests/Validator/Constraints/Recaptcha3ValidatorTest.php @@ -105,7 +105,7 @@ public function testLastResponse() $this->recaptcha->nextSuccess = true; $validator = new Recaptcha3Validator($this->recaptcha, $enabled = true, $this->resolver); - self::assertNull($this->validator->getLastResponse()); + self::assertNull($validator->getLastResponse()); $validator->validate('test', new Recaptcha3()); self::assertNotNull($validator->getLastResponse()); diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..4374b9b --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,24 @@ +includes: + - vendor/phpstan/phpstan-deprecation-rules/rules.neon + - vendor/phpstan/phpstan-strict-rules/rules.neon + +parameters: + level: 5 + reportUnmatchedIgnoredErrors: false + checkMissingIterableValueType: false + checkGenericClassInNonGenericObjectType: false + inferPrivatePropertyTypeFromConstructor: true + paths: + - %currentWorkingDirectory% + ignoreErrors: + - '#Class Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder constructor invoked with 0 parameters, 1-3 required#' + - '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder::root\(\)#' + - '#Call to function method_exists\(\) with .*?TreeBuilder.*? and .*?getRootNode.*? will always evaluate to true#' + - '#Comparison operation "<" between 70006 and 50200 is always false#' + - '#Comparison operation ">=" between 7 and 6 is always true#' + - '#Else branch is unreachable because ternary operator condition is always true#' + + excludePaths: + - %currentWorkingDirectory%/.github/* + - %currentWorkingDirectory%/.idea/* + - %currentWorkingDirectory%/vendor/*