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: Update PHP-CS-Fixer rules #1150

Merged
merged 1 commit into from
Nov 29, 2023
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
97 changes: 23 additions & 74 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

use PhpCsFixer\Config;
use Fidry\PhpCsFixerConfig\FidryConfig;
use PhpCsFixer\Finder;

$finder = Finder::create()
Expand All @@ -28,77 +28,26 @@
'fixtures/Parser/files/php',
'Bridge/Symfony/Application/var',
'fixtures/Bridge/Symfony/Application/cache',
])
;
]);

return (new Config())
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => true,
'cast_spaces' => true,
'combine_consecutive_unsets' => true,
'declare_equal_normalize' => true,
'declare_strict_types' => true,
'heredoc_to_nowdoc' => true,
'include' => true,
'header_comment' => [
'location' => 'after_open',
'header' => <<<'LICENSE'
This file is part of the Alice package.

(c) Nelmio <hello@nelm.io>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
LICENSE,
],
'lowercase_cast' => true,
'general_phpdoc_annotation_remove' => true,
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
'modernize_types_casting' => true,
'native_function_casing' => true,
'new_with_braces' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_short_bool_cast' => true,
'no_spaces_around_offset' => true,
'no_superfluous_phpdoc_tags' => [
'remove_inheritdoc' => true,
],
'no_unused_imports' => true,
'ordered_imports' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_order' => true,
'phpdoc_order_by_value' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'phpdoc_trim' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert' => true,
'php_unit_dedicate_assert_internal_type' => true,
'php_unit_expectation' => true,
'php_unit_fqcn_annotation' => true,
'php_unit_namespaced' => true,
'php_unit_test_case_static_method_calls' => true,
'php_unit_test_class_requires_covers' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'trim_array_spaces' => true,
'void_return' => true,
'whitespace_after_comma_in_array' => true,
])
->setFinder($finder)
;
$config = new FidryConfig(
<<<'EOF'
This file is part of the Alice package.

(c) Nelmio <hello@nelm.io>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF,
74_000,
);

$config->addRules([
'php_unit_method_casing' => ['case' => 'camel_case'],
'phpdoc_no_empty_return' => false,
]);

$config->setFinder($finder);
$config->setCacheFile(__DIR__.'/dist/.php-cs-fixer.cache');

return $config;
8 changes: 4 additions & 4 deletions fixtures/Bridge/Symfony/Application/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ class AppKernel extends Kernel
* @var string|null
*/
private $config;

public function __construct($environment, $debug)
{
parent::__construct($environment, $debug);
}

public function registerBundles(): array
{
return [
new FrameworkBundle(),
new NelmioAliceBundle(),
];
}

public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load($this->config ?? __DIR__.'/config.yml');
}

public function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new class() implements CompilerPassInterface {
Expand Down
12 changes: 6 additions & 6 deletions fixtures/Definition/FakeMethodCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@
class FakeMethodCall implements MethodCallInterface
{
use NotCallableTrait;
public function withArguments(array $arguments = null): void

public function withArguments(?array $arguments = null): void
{
$this->__call(__METHOD__, func_get_args());
}

public function getCaller(): void
{
$this->__call(__METHOD__, func_get_args());
}

public function getMethod(): string
{
$this->__call(__METHOD__, func_get_args());
}

public function getArguments(): array
{
$this->__call(__METHOD__, func_get_args());
}

public function __toString(): string
{
$this->__call(__METHOD__, func_get_args());
Expand Down
10 changes: 5 additions & 5 deletions fixtures/Definition/Fixture/DummyFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@ public function __construct(string $id)
{
$this->id = $id;
}

public function getId(): string
{
return $this->id;
}

public function getClassName(): string
{
$this->__call(__METHOD__, func_get_args());
}

public function getSpecs(): SpecificationBag
{
$this->__call(__METHOD__, func_get_args());
}

public function getValueForCurrent(): void
{
$this->__call(__METHOD__, func_get_args());
}

public function withSpecs(SpecificationBag $specs): void
{
$this->__call(__METHOD__, func_get_args());
Expand Down
10 changes: 5 additions & 5 deletions fixtures/Definition/Fixture/FakeFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@
class FakeFixture implements FixtureInterface
{
use NotCallableTrait;

public function getId(): string
{
$this->__call(__METHOD__, func_get_args());
}

public function getClassName(): string
{
$this->__call(__METHOD__, func_get_args());
}

public function getSpecs(): SpecificationBag
{
$this->__call(__METHOD__, func_get_args());
}

public function getValueForCurrent(): void
{
$this->__call(__METHOD__, func_get_args());
}

public function withSpecs(SpecificationBag $specs): void
{
$this->__call(__METHOD__, func_get_args());
Expand Down
10 changes: 5 additions & 5 deletions fixtures/Definition/Fixture/MutableFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ public function __construct(string $id, string $className, SpecificationBag $spe
$this->className = $className;
$this->specs = $specs;
}

public function getId(): string
{
return $this->id;
}

public function getClassName(): string
{
return $this->className;
}

public function getSpecs(): SpecificationBag
{
return $this->specs;
Expand All @@ -62,12 +62,12 @@ public function setSpecs(SpecificationBag $specs): void
{
$this->specs = $specs;
}

public function getValueForCurrent(): void
{
$this->__call(__METHOD__, func_get_args());
}

public function withSpecs(SpecificationBag $specs): void
{
$this->__call(__METHOD__, func_get_args());
Expand Down
2 changes: 1 addition & 1 deletion fixtures/Definition/Flag/ElementFlag.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(string $element)
{
$this->element = $element;
}

public function __toString(): string
{
return $this->element;
Expand Down
2 changes: 1 addition & 1 deletion fixtures/Definition/Flag/ElementWithToStringFlag.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(string $element, string $toString)
$this->element = $element;
$this->toString = $toString;
}

public function __toString(): string
{
return $this->toString;
Expand Down
12 changes: 6 additions & 6 deletions fixtures/Definition/MethodCall/DummyMethodCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,27 @@ public function __construct(string $toString)
$this->token = uniqid();
$this->toString = $toString;
}
public function withArguments(array $arguments = null): self

public function withArguments(?array $arguments = null): self
{
$this->__call(__METHOD__, func_get_args());
}

public function getCaller(): void
{
$this->__call(__METHOD__, func_get_args());
}

public function getMethod(): string
{
$this->__call(__METHOD__, func_get_args());
}

public function getArguments(): array
{
$this->__call(__METHOD__, func_get_args());
}

public function __toString(): string
{
return $this->toString;
Expand Down
2 changes: 1 addition & 1 deletion fixtures/Definition/MethodCall/IdentityFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function create(string $expression): FunctionCallValue
{
return new FunctionCallValue(
'identity',
[new EvaluatedValue($expression)]
[new EvaluatedValue($expression)],
);
}
}
19 changes: 9 additions & 10 deletions fixtures/Definition/MethodCall/MutableMethodCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,35 @@ class MutableMethodCall implements MethodCallInterface
*/
private $caller;


private $method;

/**
* @var array|null
*/
private $arguments;

public function __construct(ServiceReferenceInterface $caller = null, $method, array $arguments = null)
public function __construct(?ServiceReferenceInterface $caller = null, $method, ?array $arguments = null)
{
$this->caller = $caller;
$this->method = $method;
$this->arguments = $arguments;
}
public function withArguments(array $arguments = null): void

public function withArguments(?array $arguments = null): void
{
$this->__call(__METHOD__, func_get_args());
}

public function getCaller()
{
return $this->caller;
}

public function setCaller(ServiceReferenceInterface $caller = null): void
public function setCaller(?ServiceReferenceInterface $caller = null): void
{
$this->caller = $caller;
}

public function getMethod(): string
{
return $this->method;
Expand All @@ -65,17 +64,17 @@ public function setMethod($method): void
{
$this->method = $method;
}

public function getArguments()
{
return $this->arguments;
}

public function setArguments(array $arguments = null): void
public function setArguments(?array $arguments = null): void
{
$this->arguments = $arguments;
}

public function __toString(): string
{
return 'mutable_method_call';
Expand Down
Loading
Loading