Skip to content

Commit

Permalink
refactor: apply new coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroTroller committed Aug 2, 2024
1 parent cee3788 commit 8277ca8
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 11 deletions.
8 changes: 5 additions & 3 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

use PedroTroller\CS\Fixer\Fixers;
use PedroTroller\CS\Fixer\RuleSetFactory;
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

return (new PhpCsFixer\Config())
return (new Config())
->setRiskyAllowed(true)
->setRules(
RuleSetFactory::create()
->per(2, true)
->phpCsFixer(true)
->php(8.0, true)
->php(8.1, true)
->pedrotroller(true)
->enable('align_multiline_comment')
->enable('array_indentation')
Expand All @@ -34,7 +36,7 @@
->setUsingCache(false)
->registerCustomFixers(new Fixers())
->setFinder(
PhpCsFixer\Finder::create()
Finder::create()
->in(__DIR__)
->append([__FILE__, __DIR__.'/bin/doc'])
)
Expand Down
2 changes: 1 addition & 1 deletion bin/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

final class Utils
{
public static function arrayToString(array $array = null)
public static function arrayToString(?array $array = null)
{
if (null === $array) {
return;
Expand Down
5 changes: 4 additions & 1 deletion bin/doc
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);

use PedroTroller\CS\Fixer\AbstractFixer;
use PedroTroller\CS\Fixer\Fixers;
use PhpCsFixer\Fixer\ConfigurableFixerInterface;
use PhpCsFixer\FixerConfiguration\FixerOptionInterface;
use PhpCsFixer\FixerDefinition\CodeSample;
Expand Down Expand Up @@ -80,7 +83,7 @@ $fixers = array_map(static function (AbstractFixer $fixer) {
];
}, $samples),
];
}, iterator_to_array(new PedroTroller\CS\Fixer\Fixers()));
}, ...(new Fixers()));

$loader = new FilesystemLoader([__DIR__]);
$twig = new Environment($loader);
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"description": "PHP-CS-FIXER : my custom fixers",
"license": "MIT",
"require": {
"php": "^8.0"
"php": "^8.1",
"friendsofphp/php-cs-fixer": ">=3.59.3"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.28",
"phpspec/phpspec": "^7.0",
"sebastian/diff": "^4.0",
"twig/twig": "^3.3",
Expand Down
2 changes: 1 addition & 1 deletion src/PedroTroller/CS/Fixer/AbstractFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getDefinition(): FixerDefinitionInterface
return new FixerDefinition(
$this->getDocumentation(),
array_map(
fn (array $configutation = null) => new CodeSample($this->getSampleCode(), $configutation),
fn (?array $configutation = null) => new CodeSample($this->getSampleCode(), $configutation),
$this->getSampleConfigurations()
)
);
Expand Down
4 changes: 2 additions & 2 deletions src/PedroTroller/CS/Fixer/RuleSetFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function create(array $rules = []): self
);
}

public function per(int|float $version = null, bool $risky = false): self
public function per(null|float|int $version = null, bool $risky = false): self
{
$candidates = null !== $version
? ['@PER-CS'.number_format($version, 1, '.', '')]
Expand Down Expand Up @@ -198,7 +198,7 @@ public function pedrotroller(bool $risky = false): self
));
}

public function enable(string $name, array $config = null): self
public function enable(string $name, ?array $config = null): self
{
return self::create(array_merge(
$this->rules,
Expand Down
2 changes: 1 addition & 1 deletion tests/TokensAnalyzerIntegration/MethodArguments.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function assertions(TokensAnalyzer $analyzer, Tokens $tokens): void
$arguments,
[
($theFunction + 5) => [
'type' => 'Domain\\Model\\User',
'type' => 'Domain\Model\User',
'name' => '$user',
'nullable' => false,
'asDefault' => false,
Expand Down

0 comments on commit 8277ca8

Please sign in to comment.