Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cs: fix native_function_invocation & trailing_comma_in_multiline #178

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/FileExtractor/PHPFileExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public function getSourceLocations(SplFileInfo $file, SourceCollection $collection): void
{
$path = $file->getRelativePath();
$parser = (new ParserFactory())->createForVersion(PhpVersion::fromString('8.1'));

Check failure on line 36 in src/FileExtractor/PHPFileExtractor.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to an undefined method PhpParser\ParserFactory::createForVersion().
$traverser = new NodeTraverser();
foreach ($this->visitors as $v) {
$v->init($collection, $file);
Expand All @@ -44,7 +44,7 @@
$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()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Model/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Model/SourceLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [],
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Visitor/Php/SourceLocationContainerVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Visitor/Php/Symfony/ValidationAnnotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Visitor/Twig/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Smoke/AllExtractorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading