From 6c3c90170d222500cb0e791d13f89791977c305c Mon Sep 17 00:00:00 2001 From: Farhad Safarov Date: Tue, 12 Nov 2024 15:53:14 +0300 Subject: [PATCH 1/5] Test against PHP 8.3 & 8.4 --- .github/workflows/integrate.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index b0f637a..935c94d 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -20,6 +20,8 @@ jobs: php-version: - 8.1 - 8.2 + - 8.3 + - 8.4 dependencies: - highest @@ -66,6 +68,8 @@ jobs: php-version: - 8.1 - 8.2 + - 8.3 + - 8.4 symfony-version: - 6 From d6c93a8f26a423d9e75f15991d6b75b7cc80b9db Mon Sep 17 00:00:00 2001 From: Farhad Safarov Date: Tue, 12 Nov 2024 16:37:15 +0300 Subject: [PATCH 2/5] remove 8.4 --- .github/workflows/integrate.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 935c94d..1828fac 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -21,7 +21,6 @@ jobs: - 8.1 - 8.2 - 8.3 - - 8.4 dependencies: - highest @@ -69,7 +68,6 @@ jobs: - 8.1 - 8.2 - 8.3 - - 8.4 symfony-version: - 6 From cb7aab0b201eba83508c505822a81eac543dbc10 Mon Sep 17 00:00:00 2001 From: Farhad Safarov Date: Sat, 21 Dec 2024 10:55:37 +0300 Subject: [PATCH 3/5] suppress MissingClassConstType (PHP 8.3 only feature) --- src/Handler/ContainerHandler.php | 1 + src/Test/CodeceptionModule.php | 18 +++++------------- src/Twig/CachedTemplatesMapping.php | 13 ++++--------- src/Twig/TemplateFileAnalyzer.php | 2 +- .../acceptance/console/ConsoleArgument.feature | 3 ++- 5 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/Handler/ContainerHandler.php b/src/Handler/ContainerHandler.php index e750deb..2628c1a 100644 --- a/src/Handler/ContainerHandler.php +++ b/src/Handler/ContainerHandler.php @@ -26,6 +26,7 @@ class ContainerHandler implements AfterMethodCallAnalysisInterface, AfterClassLikeVisitInterface, AfterCodebasePopulatedInterface, BeforeAddIssueInterface { + /** @psalm-suppress MissingClassConstType */ private const GET_CLASSLIKES = [ 'Psr\Container\ContainerInterface', 'Symfony\Component\DependencyInjection\ContainerInterface', diff --git a/src/Test/CodeceptionModule.php b/src/Test/CodeceptionModule.php index 0e58bc2..5c2b46d 100644 --- a/src/Test/CodeceptionModule.php +++ b/src/Test/CodeceptionModule.php @@ -21,27 +21,19 @@ */ class CodeceptionModule extends BaseModule { + /** @psalm-suppress MissingClassConstType */ private const DEFAULT_TWIG_TEMPLATES_DIR = 'templates'; - /** - * @var string - */ - private $twigTemplateDir = self::DEFAULT_TWIG_TEMPLATES_DIR; + private string $twigTemplateDir = self::DEFAULT_TWIG_TEMPLATES_DIR; - /** - * @var FilesystemCache|null - */ - private $twigCache; + private ?FilesystemCache $twigCache = null; - /** - * @var string|null - */ - private $lastCachePath; + private ?string $lastCachePath = null; /** * @var list */ - private $suppressedIssueHandlers = []; + private array $suppressedIssueHandlers = []; public function _initialize(): void { diff --git a/src/Twig/CachedTemplatesMapping.php b/src/Twig/CachedTemplatesMapping.php index c2c21b8..8c1c301 100644 --- a/src/Twig/CachedTemplatesMapping.php +++ b/src/Twig/CachedTemplatesMapping.php @@ -13,6 +13,7 @@ class CachedTemplatesMapping implements AfterCodebasePopulatedInterface { /** + * @psalm-suppress MissingClassConstType * @var string */ public const CACHED_TEMPLATE_HEADER_PATTERN = @@ -20,17 +21,11 @@ class CachedTemplatesMapping implements AfterCodebasePopulatedInterface '\/\* (?@?.+\.twig) \*\/\n'. 'class (?__TwigTemplate_[a-z0-9]{64}) extends (\\\\Twig\\\\)?Template'; - /** - * @var string|null - */ - private static $cachePath; + private static ?string $cachePath = null; - /** - * @var CachedTemplatesRegistry|null - */ - private static $cacheRegistry; + private static ?CachedTemplatesRegistry $cacheRegistry = null; - public static function afterCodebasePopulated(AfterCodebasePopulatedEvent $event) + public static function afterCodebasePopulated(AfterCodebasePopulatedEvent $event): void { $codebase = $event->getCodebase(); diff --git a/src/Twig/TemplateFileAnalyzer.php b/src/Twig/TemplateFileAnalyzer.php index 76b968c..9a2feec 100644 --- a/src/Twig/TemplateFileAnalyzer.php +++ b/src/Twig/TemplateFileAnalyzer.php @@ -35,7 +35,7 @@ public static function initExtensions(array $extensionClasses): void public function analyze( ?PsalmContext $file_context = null, - ?PsalmContext $global_context = null + ?PsalmContext $global_context = null, ): void { $codebase = $this->project_analyzer->getCodebase(); $taint = $codebase->taint_flow_graph; diff --git a/tests/acceptance/acceptance/console/ConsoleArgument.feature b/tests/acceptance/acceptance/console/ConsoleArgument.feature index b4e9631..852abc5 100644 --- a/tests/acceptance/acceptance/console/ConsoleArgument.feature +++ b/tests/acceptance/acceptance/console/ConsoleArgument.feature @@ -2,7 +2,8 @@ Feature: ConsoleArgument Background: - Given I have Symfony plugin enabled + Given I have issue handler "MissingClassConstType" suppressed + And I have Symfony plugin enabled And I have the following code preamble """ Date: Sat, 21 Dec 2024 11:07:50 +0300 Subject: [PATCH 4/5] move suppresses to the baseline --- psalm-baseline.xml | 35 ++++++++++++++++++++++++----- src/Handler/ContainerHandler.php | 1 - src/Test/CodeceptionModule.php | 1 - src/Twig/CachedTemplatesMapping.php | 1 - 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 6f8f423..deccc8e 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,14 +1,39 @@ - + + + + + + - - DeprecatedMethod + + + + + + + + + + @?.+\.twig) \*\/\n'. + 'class (?__TwigTemplate_[a-z0-9]{64}) extends (\\\\Twig\\\\)?Template']]> + + - int - string + + diff --git a/src/Handler/ContainerHandler.php b/src/Handler/ContainerHandler.php index 2628c1a..e750deb 100644 --- a/src/Handler/ContainerHandler.php +++ b/src/Handler/ContainerHandler.php @@ -26,7 +26,6 @@ class ContainerHandler implements AfterMethodCallAnalysisInterface, AfterClassLikeVisitInterface, AfterCodebasePopulatedInterface, BeforeAddIssueInterface { - /** @psalm-suppress MissingClassConstType */ private const GET_CLASSLIKES = [ 'Psr\Container\ContainerInterface', 'Symfony\Component\DependencyInjection\ContainerInterface', diff --git a/src/Test/CodeceptionModule.php b/src/Test/CodeceptionModule.php index 5c2b46d..3b39740 100644 --- a/src/Test/CodeceptionModule.php +++ b/src/Test/CodeceptionModule.php @@ -21,7 +21,6 @@ */ class CodeceptionModule extends BaseModule { - /** @psalm-suppress MissingClassConstType */ private const DEFAULT_TWIG_TEMPLATES_DIR = 'templates'; private string $twigTemplateDir = self::DEFAULT_TWIG_TEMPLATES_DIR; diff --git a/src/Twig/CachedTemplatesMapping.php b/src/Twig/CachedTemplatesMapping.php index 8c1c301..685074c 100644 --- a/src/Twig/CachedTemplatesMapping.php +++ b/src/Twig/CachedTemplatesMapping.php @@ -13,7 +13,6 @@ class CachedTemplatesMapping implements AfterCodebasePopulatedInterface { /** - * @psalm-suppress MissingClassConstType * @var string */ public const CACHED_TEMPLATE_HEADER_PATTERN = From 7dad5ee12c4da396e6a9a96496f2e7457e83ecb9 Mon Sep 17 00:00:00 2001 From: Farhad Safarov Date: Sat, 21 Dec 2024 11:10:24 +0300 Subject: [PATCH 5/5] UnusedVariable --- tests/acceptance/acceptance/console/ConsoleArgument.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/acceptance/acceptance/console/ConsoleArgument.feature b/tests/acceptance/acceptance/console/ConsoleArgument.feature index 852abc5..17df160 100644 --- a/tests/acceptance/acceptance/console/ConsoleArgument.feature +++ b/tests/acceptance/acceptance/console/ConsoleArgument.feature @@ -2,7 +2,7 @@ Feature: ConsoleArgument Background: - Given I have issue handler "MissingClassConstType" suppressed + Given I have issue handler "UnusedVariable,MissingClassConstType" suppressed And I have Symfony plugin enabled And I have the following code preamble """