From ff0bf300fa009996053c9799b5ac819a3cd51f64 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Wed, 2 Oct 2024 18:34:43 +0200 Subject: [PATCH] cs: fix native_function_invocation & trailing_comma_in_multiline --- src/FileExtractor/PHPFileExtractor.php | 2 +- src/Model/Error.php | 2 +- src/Model/SourceLocation.php | 2 +- src/Visitor/Php/SourceLocationContainerVisitor.php | 2 +- src/Visitor/Php/Symfony/ValidationAnnotation.php | 2 +- src/Visitor/Twig/Worker.php | 4 ++-- tests/Smoke/AllExtractorsTest.php | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/FileExtractor/PHPFileExtractor.php b/src/FileExtractor/PHPFileExtractor.php index ae58780..cb35178 100644 --- a/src/FileExtractor/PHPFileExtractor.php +++ b/src/FileExtractor/PHPFileExtractor.php @@ -44,7 +44,7 @@ public function getSourceLocations(SplFileInfo $file, SourceCollection $collecti $tokens = $parser->parse($file->getContents()); $traverser->traverse($tokens); } catch (Error $e) { - trigger_error(sprintf('Skipping file "%s" because of parse Error: %s. ', $path, $e->getMessage())); + trigger_error(\sprintf('Skipping file "%s" because of parse Error: %s. ', $path, $e->getMessage())); } } diff --git a/src/Model/Error.php b/src/Model/Error.php index df5c58f..5897f09 100644 --- a/src/Model/Error.php +++ b/src/Model/Error.php @@ -21,7 +21,7 @@ final class Error public function __construct( private readonly string $message, private readonly string $path, - private readonly int $line + private readonly int $line, ) { } diff --git a/src/Model/SourceLocation.php b/src/Model/SourceLocation.php index 56cbc4f..7f7e4a5 100644 --- a/src/Model/SourceLocation.php +++ b/src/Model/SourceLocation.php @@ -20,7 +20,7 @@ public function __construct( private readonly string $message, /** Translation key. */ private readonly string $path, private readonly int $line, - private readonly array $context = [] + private readonly array $context = [], ) { } diff --git a/src/Visitor/Php/SourceLocationContainerVisitor.php b/src/Visitor/Php/SourceLocationContainerVisitor.php index f26a4aa..6b4da38 100644 --- a/src/Visitor/Php/SourceLocationContainerVisitor.php +++ b/src/Visitor/Php/SourceLocationContainerVisitor.php @@ -76,7 +76,7 @@ public function enterNode(Node $node): ?Node foreach ($sourceLocations as $sourceLocation) { if (!$sourceLocation instanceof SourceLocation) { - throw new \RuntimeException(sprintf('%s::getTranslationSourceLocations() was expected to return an array of SourceLocations, but got an array which contains an item of type %s.', $this->namespace.'\\'.$node->name, \gettype($sourceLocation))); + throw new \RuntimeException(\sprintf('%s::getTranslationSourceLocations() was expected to return an array of SourceLocations, but got an array which contains an item of type %s.', $this->namespace.'\\'.$node->name, \gettype($sourceLocation))); } $this->collection->addLocation($sourceLocation); diff --git a/src/Visitor/Php/Symfony/ValidationAnnotation.php b/src/Visitor/Php/Symfony/ValidationAnnotation.php index 05c86f8..a539f58 100644 --- a/src/Visitor/Php/Symfony/ValidationAnnotation.php +++ b/src/Visitor/Php/Symfony/ValidationAnnotation.php @@ -64,7 +64,7 @@ public function enterNode(Node $node): ?Node /** @var ClassMetadata $metadata */ $metadata = $this->metadataFactory->getMetadataFor($name); } catch (AnnotationException $e) { - $this->addError($node, sprintf('Could not parse class "%s" for annotations. %s', $this->namespace, $e->getMessage())); + $this->addError($node, \sprintf('Could not parse class "%s" for annotations. %s', $this->namespace, $e->getMessage())); return null; } diff --git a/src/Visitor/Twig/Worker.php b/src/Visitor/Twig/Worker.php index 484f117..af0005a 100644 --- a/src/Visitor/Twig/Worker.php +++ b/src/Visitor/Twig/Worker.php @@ -89,11 +89,11 @@ private function extractContextFromJoinedFilters(): array } elseif ('desc' === $name) { $arguments = $this->stack[$i]->getNode('arguments'); if (!$arguments->hasNode(0)) { - throw new \LogicException(sprintf('The "%s" filter requires exactly one argument, the description text.', $name)); + throw new \LogicException(\sprintf('The "%s" filter requires exactly one argument, the description text.', $name)); } $text = $arguments->getNode(0); if (!$text instanceof ConstantExpression) { - throw new \LogicException(sprintf('The first argument of the "%s" filter must be a constant expression, such as a string.', $name)); + throw new \LogicException(\sprintf('The first argument of the "%s" filter must be a constant expression, such as a string.', $name)); } $context['desc'] = $text->getAttribute('value'); } diff --git a/tests/Smoke/AllExtractorsTest.php b/tests/Smoke/AllExtractorsTest.php index b9237eb..fe2a816 100644 --- a/tests/Smoke/AllExtractorsTest.php +++ b/tests/Smoke/AllExtractorsTest.php @@ -103,7 +103,7 @@ public function testNoException() private function translationExists(SourceCollection $sc, string $translationKey, ?string $message = null): SourceLocation { if (empty($message)) { - $message = sprintf('Tried to find "%s" but failed', $translationKey); + $message = \sprintf('Tried to find "%s" but failed', $translationKey); } $source = null; @@ -127,7 +127,7 @@ private function translationExists(SourceCollection $sc, string $translationKey, private function translationMissing(SourceCollection $sc, string $translationKey, ?string $message = null): void { if (empty($message)) { - $message = sprintf('The translation key "%s" should not exist', $translationKey); + $message = \sprintf('The translation key "%s" should not exist', $translationKey); } $found = false;