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

Fix code style #443

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
run: composer install --prefer-dist

- name: Coding Standard Checks
if: ${{ matrix.php-versions >= '8.0' }}
run: PHP_CS_FIXER_IGNORE_ENV=1 ./bin/php-cs-fixer fix --dry-run -v

- name: Static Analysis
Expand Down
7 changes: 5 additions & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'modernize_types_casting' => true, // Replaces intval, floatval, doubleval, strval and boolval function calls with according type casting operator.
'multiline_whitespace_before_semicolons' => true, // Forbid multi-line whitespace before the closing semicolon or move the semicolon to the new line for chained calls.
'no_unreachable_default_argument_value' => true, // In function arguments there must not be arguments with default values before non-default ones.
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],// To avoid problems of compatibility with the old php-cs-fixer version used on PHP 7.3
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true], // To avoid problems of compatibility with the old php-cs-fixer version used on PHP 7.3
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true, // Orders the elements of classes/interfaces/traits.
Expand All @@ -40,5 +40,8 @@
'list_syntax' => ['syntax' => 'short'],
'phpdoc_to_comment' => false,
'php_unit_method_casing' => ['case' => 'snake_case'],
'function_to_constant' => false
'function_to_constant' => false,
'trailing_comma_in_multiline' => [
'elements' => ['array_destructuring', 'arrays'],
],
]);
1 change: 0 additions & 1 deletion src/Analyzer/ClassDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class ClassDescription
/**
* @param list<ClassDependency> $dependencies
* @param list<FullyQualifiedClassName> $interfaces
* @param ?FullyQualifiedClassName $extends
* @param list<FullyQualifiedClassName> $attributes
*/
public function __construct(
Expand Down
8 changes: 4 additions & 4 deletions src/CLI/Command/Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->printHeadingLine($output);

$rulesFilename = $this->getConfigFilename($input);
$output->writeln(sprintf("Config file: %s\n", $rulesFilename));
$output->writeln(\sprintf("Config file: %s\n", $rulesFilename));

$config = new Config();

Expand Down Expand Up @@ -239,14 +239,14 @@ private function getConfigFilename(InputInterface $input): string
private function printViolations(Violations $violations, OutputInterface $output): void
{
$output->writeln('<error>ERRORS!</error>');
$output->writeln(sprintf('%s', $violations->toString()));
$output->writeln(sprintf('<error>%s VIOLATIONS DETECTED!</error>', \count($violations)));
$output->writeln(\sprintf('%s', $violations->toString()));
$output->writeln(\sprintf('<error>%s VIOLATIONS DETECTED!</error>', \count($violations)));
}

private function printParsedErrors(ParsingErrors $parsingErrors, OutputInterface $output): void
{
$output->writeln('<error>ERROR ON PARSING THESE FILES:</error>');
$output->writeln(sprintf('%s', $parsingErrors->toString()));
$output->writeln(\sprintf('%s', $parsingErrors->toString()));
}

private function printNoViolationsDetectedMessage(OutputInterface $output): void
Expand Down
2 changes: 1 addition & 1 deletion src/CLI/PhpArkitectApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public function __construct()

public function getLongVersion(): string
{
return sprintf("%s\n\n<info>%s</info> version <comment>%s</comment>", self::$logo, $this->getName(), $this->getVersion());
return \sprintf("%s\n\n<info>%s</info> version <comment>%s</comment>", self::$logo, $this->getName(), $this->getVersion());
}
}
2 changes: 1 addition & 1 deletion src/Exceptions/IndexNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class IndexNotFoundException extends \Exception
{
public function __construct(int $index)
{
parent::__construct(sprintf('Index not found %d', $index));
parent::__construct(\sprintf('Index not found %d', $index));
}
}
2 changes: 1 addition & 1 deletion src/Exceptions/PhpVersionNotValidException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class PhpVersionNotValidException extends \Exception
{
public function __construct(string $phpVersion)
{
parent::__construct(sprintf('PHP version not valid for PHPArkitect parser %s', $phpVersion));
parent::__construct(\sprintf('PHP version not valid for PHPArkitect parser %s', $phpVersion));
}
}
4 changes: 2 additions & 2 deletions tests/Unit/Rules/ConstraintsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ConstraintsTest extends TestCase
{
public function test_it_should_not_add_to_violation_if_constraint_is_not_violated(): void
{
$trueExpression = new class() implements Expression {
$trueExpression = new class implements Expression {
public function describe(ClassDescription $theClass, string $because): Description
{
return new Description('', '');
Expand Down Expand Up @@ -48,7 +48,7 @@ public function evaluate(ClassDescription $theClass, Violations $violations, str

public function test_it_should_add_to_violation_store_if_constraint_is_violated(): void
{
$falseExpression = new class() implements Expression {
$falseExpression = new class implements Expression {
public function describe(ClassDescription $theClass, string $because): Description
{
return new Description('bar', 'we want to add this rule');
Expand Down