From 2f46fbfc7a4ad6d474ea8b4c864f3a63512a6511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Wed, 14 Jun 2023 23:14:49 +0200 Subject: [PATCH] Added stricter phpstan checks --- composer.json | 1 + composer.lock | 51 ++++++++++++++++++- phpstan.neon | 18 ++++++- .../Constraints/InstanceOfConstraint.php | 1 + 4 files changed, 69 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 7dda9d6b..81edc573 100644 --- a/composer.json +++ b/composer.json @@ -88,6 +88,7 @@ "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^1.4.7", "phpstan/phpstan-doctrine": "^1.2.11", + "phpstan/phpstan-strict-rules": "^1.5", "phpstan/phpstan-symfony": "^1.1.7", "psalm/plugin-symfony": "^v5.0.1", "rector/rector": "^0.17.0", diff --git a/composer.lock b/composer.lock index afde027e..f67c8c87 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3fced602006b9f4356f00e003f404d84", + "content-hash": "a8ee56e1ebdd203018f921be240029ca", "packages": [ { "name": "beberlei/assert", @@ -14422,6 +14422,55 @@ }, "time": "2023-05-11T11:26:04+00:00" }, + { + "name": "phpstan/phpstan-strict-rules", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-strict-rules.git", + "reference": "b21c03d4f6f3a446e4311155f4be9d65048218e6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/b21c03d4f6f3a446e4311155f4be9d65048218e6", + "reference": "b21c03d4f6f3a446e4311155f4be9d65048218e6", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.10" + }, + "require-dev": { + "nikic/php-parser": "^4.13.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-deprecation-rules": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Extra strict and opinionated rules for PHPStan", + "support": { + "issues": "https://github.com/phpstan/phpstan-strict-rules/issues", + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.5.1" + }, + "time": "2023-03-29T14:47:40+00:00" + }, { "name": "phpstan/phpstan-symfony", "version": "1.3.2", diff --git a/phpstan.neon b/phpstan.neon index 9b99d1b5..e35c6d07 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -17,4 +17,20 @@ parameters: treatPhpDocTypesAsCertain: false symfony: - container_xml_path: '%rootDir%/../../../var/cache/dev/App_KernelDevDebugContainer.xml' \ No newline at end of file + container_xml_path: '%rootDir%/../../../var/cache/dev/App_KernelDevDebugContainer.xml' + + checkUninitializedProperties: true + + strictRules: + disallowedLooseComparison: false + booleansInConditions: false + uselessCast: false + requireParentConstructorCall: true + disallowedConstructs: false + overwriteVariablesWithLoop: true + closureUsesThis: false + matchingInheritedMethodNames: true + numericOperandsInArithmeticOperators: true + strictCalls: true + switchConditionsMatchingType: false + noVariableVariables: false \ No newline at end of file diff --git a/src/DataTables/Filters/Constraints/InstanceOfConstraint.php b/src/DataTables/Filters/Constraints/InstanceOfConstraint.php index 227bdaba..410716d4 100644 --- a/src/DataTables/Filters/Constraints/InstanceOfConstraint.php +++ b/src/DataTables/Filters/Constraints/InstanceOfConstraint.php @@ -94,6 +94,7 @@ class InstanceOfConstraint extends AbstractConstraint $expressions = []; + /** @phpstan-ignore-next-line */ if ($this->operator === 'ANY' || $this->operator === 'NONE') { foreach($this->value as $value) { //We can not use a parameter here, as this is the only way to pass the FCQN to the query (via binded params, we would need to use ClassMetaData). See: https://github.com/doctrine/orm/issues/4462