diff --git a/src/Twig/TwigTemplateConstantExtractor.php b/src/Twig/TwigTemplateConstantExtractor.php index b4ebfc3eb..a5f4db6c9 100644 --- a/src/Twig/TwigTemplateConstantExtractor.php +++ b/src/Twig/TwigTemplateConstantExtractor.php @@ -42,7 +42,7 @@ private function findClassConstantFetchesInFile(string $filePath): array { $fileContents = FileSystem::read($filePath); - $constantMatches = Strings::matchAll($fileContents, '#{{\s*constant\(\s*([\'"])(?.*?)\1#'); + $constantMatches = Strings::matchAll($fileContents, '#{{.*?\s*constant\(\s*([\'"])(?.*?)\1#'); $externalClassAccessConstantFetches = []; foreach ($constantMatches as $constantMatch) { diff --git a/tests/Twig/TwigTemplateConstantExtractor/Fixture/twig/some_file.twig b/tests/Twig/TwigTemplateConstantExtractor/Fixture/twig/some_file.twig index fd7e2ffbd..1c634e63a 100644 --- a/tests/Twig/TwigTemplateConstantExtractor/Fixture/twig/some_file.twig +++ b/tests/Twig/TwigTemplateConstantExtractor/Fixture/twig/some_file.twig @@ -3,4 +3,4 @@ Here we use constant, it should stay public: {{ constant('Rector\\SwissKnife\\Tests\\Twig\\TwigTemplateConstantExtractor\\Fixture\\SomeTemplateUsedConstant::STAY_PUBLIC') }} -We can use it again here: {{ constant('Rector\\SwissKnife\\Tests\\Twig\\TwigTemplateConstantExtractor\\Fixture\\SomeTemplateUsedConstant::STAY_PUBLIC') }} +We can use it again here: {{ value is constant('Rector\\SwissKnife\\Tests\\Twig\\TwigTemplateConstantExtractor\\Fixture\\SomeTemplateUsedConstant::STAY_PUBLIC') }}