Skip to content

Commit ee172cc

Browse files
Bump csfixer to version 3.75.0 and tweak configuration (#479)
* bump csfixer to latest version and tweak config * adds test for long version
1 parent 58d222a commit ee172cc

File tree

64 files changed

+336
-306
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+336
-306
lines changed

.php-cs-fixer.dist.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
->setFinder($finder)
1010
->setRiskyAllowed(true)
1111
->setRules([
12+
'@PER-CS' => true,
1213
'@Symfony' => true,
1314
'@Symfony:risky' => true,
1415
'@PHP71Migration:risky' => true,
@@ -39,5 +40,8 @@
3940
'list_syntax' => ['syntax' => 'short'],
4041
'phpdoc_to_comment' => false,
4142
'php_unit_method_casing' => ['case' => 'snake_case'],
42-
'function_to_constant' => false
43+
'function_to_constant' => false,
44+
'php_unit_data_provider_static' => true ,
45+
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
46+
'phpdoc_array_type' => true
4347
]);

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
"ondram/ci-detector": "^4.1"
3535
},
3636
"require-dev": {
37-
"roave/security-advisories": "dev-master",
38-
"symfony/var-dumper": "^3.0|^4.0|^5.0|^6.0|^7.0",
39-
"phpunit/phpunit": "^7.5|^9.0|^10.0",
37+
"friendsofphp/php-cs-fixer": "^3.75",
4038
"mikey179/vfsstream": "^1.6",
4139
"phpspec/prophecy": "^1.10",
42-
"friendsofphp/php-cs-fixer": "3.4.0",
43-
"phpspec/prophecy-phpunit": "^2.3"
40+
"phpspec/prophecy-phpunit": "^2.3",
41+
"phpunit/phpunit": "^7.5|^9.0|^10.0",
42+
"roave/security-advisories": "dev-master",
43+
"symfony/var-dumper": "^3.0|^4.0|^5.0|^6.0|^7.0"
4444
},
4545
"autoload": {
4646
"psr-4": {

src/Analyzer/FileParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class FileParser implements Parser
1919

2020
private FileVisitor $fileVisitor;
2121

22-
/** @var ParsingError[] */
22+
/** @var array<ParsingError> */
2323
private array $parsingErrors;
2424

2525
public function __construct(
@@ -38,7 +38,7 @@ public function __construct(
3838
}
3939

4040
/**
41-
* @return ClassDescription[]
41+
* @return array<ClassDescription>
4242
*/
4343
public function getClassDescriptions(): array
4444
{

src/Analyzer/FileVisitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class FileVisitor extends NodeVisitorAbstract
1313
{
1414
private ClassDescriptionBuilder $classDescriptionBuilder;
1515

16-
/** @var ClassDescription[] */
16+
/** @var array<ClassDescription> */
1717
private array $classDescriptions = [];
1818

1919
public function __construct(ClassDescriptionBuilder $classDescriptionBuilder)

src/Analyzer/NameResolver.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ protected function resolveAttrGroups(Node $node): void
329329

330330
/**
331331
* @param Stmt\Use_::TYPE_* $type
332-
* @param ?Name $prefix
333332
*
334333
* @psalm-suppress PossiblyNullArgument
335334
*/

src/CLI/Command/Check.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
142142

143143
$rulesFilename = $this->getConfigFilename($input);
144144
if (!$onlyErrors) {
145-
$output->writeln(sprintf("Config file: %s\n", $rulesFilename));
145+
$output->writeln(\sprintf("Config file: %s\n", $rulesFilename));
146146
}
147147

148148
$config = new Config();
@@ -267,9 +267,9 @@ private function printViolations(Violations $violations, OutputInterface $output
267267
$output->writeln('<error>ERRORS!</error>');
268268
}
269269

270-
$output->writeln(sprintf('%s', $violations->toString($format)));
270+
$output->writeln(\sprintf('%s', $violations->toString($format)));
271271
if (!$onlyErrors) {
272-
$output->writeln(sprintf('<error>%s VIOLATIONS DETECTED!</error>', \count($violations)));
272+
$output->writeln(\sprintf('<error>%s VIOLATIONS DETECTED!</error>', \count($violations)));
273273
}
274274
}
275275

@@ -278,7 +278,7 @@ private function printParsedErrors(ParsingErrors $parsingErrors, OutputInterface
278278
if (!$onlyErrors) {
279279
$output->writeln('<error>ERROR ON PARSING THESE FILES:</error>');
280280
}
281-
$output->writeln(sprintf('%s', $parsingErrors->toString()));
281+
$output->writeln(\sprintf('%s', $parsingErrors->toString()));
282282
}
283283

284284
private function printNoViolationsDetectedMessage(OutputInterface $output, bool $onlyErrors = false, string $format = Printer::FORMAT_TEXT): void

src/CLI/PhpArkitectApplication.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010

1111
class PhpArkitectApplication extends \Symfony\Component\Console\Application
1212
{
13-
/** @var string */
14-
private static $logo = <<< 'EOD'
15-
____ _ _ ____ _ _ _ _ _
16-
| _ \| | | | _ \ / \ _ __| | _(_) |_ ___ ___| |_
17-
| |_) | |_| | |_) / _ \ | '__| |/ / | __/ _ \/ __| __|
18-
| __/| _ | __/ ___ \| | | <| | || __/ (__| |_
19-
|_| |_| |_|_| /_/ \_\_| |_|\_\_|\__\___|\___|\__|
20-
EOD;
13+
private static string $logo = <<< 'EOD'
14+
____ _ _ ____ _ _ _ _ _
15+
| _ \| | | | _ \ / \ _ __| | _(_) |_ ___ ___| |_
16+
| |_) | |_| | |_) / _ \ | '__| |/ / | __/ _ \/ __| __|
17+
| __/| _ | __/ ___ \| | | <| | || __/ (__| |_
18+
|_| |_| |_|_| /_/ \_\_| |_|\_\_|\__\___|\___|\__|
19+
EOD;
2120

2221
public function __construct()
2322
{
@@ -29,6 +28,6 @@ public function __construct()
2928

3029
public function getLongVersion(): string
3130
{
32-
return sprintf("%s\n\n<info>%s</info> version <comment>%s</comment>", self::$logo, $this->getName(), $this->getVersion());
31+
return \sprintf("%s\n\n<info>%s</info> version <comment>%s</comment>", self::$logo, $this->getName(), $this->getVersion());
3332
}
3433
}

src/CLI/Printer/GitlabPrinter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public function print(array $violationsCollection): string
1212
$allErrors = [];
1313

1414
/**
15-
* @var string $key
16-
* @var Violation[] $violationsByFqcn
15+
* @var string $key
16+
* @var array<Violation> $violationsByFqcn
1717
*/
1818
foreach ($violationsCollection as $class => $violationsByFqcn) {
1919
foreach ($violationsByFqcn as $violation) {

src/CLI/Printer/JsonPrinter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public function print(array $violationsCollection): string
1313
$details = [];
1414

1515
/**
16-
* @var string $key
17-
* @var Violation[] $violationsByFqcn
16+
* @var string $key
17+
* @var array<Violation> $violationsByFqcn
1818
*/
1919
foreach ($violationsCollection as $class => $violationsByFqcn) {
2020
$violationForThisFqcn = \count($violationsByFqcn);

src/CLI/Printer/TextPrinter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public function print(array $violationsCollection): string
1212
$errors = '';
1313

1414
/**
15-
* @var string $key
16-
* @var Violation[] $violationsByFqcn
15+
* @var string $key
16+
* @var array<Violation> $violationsByFqcn
1717
*/
1818
foreach ($violationsCollection as $key => $violationsByFqcn) {
1919
$violationForThisFqcn = \count($violationsByFqcn);

src/ClassSet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
class ClassSet implements \IteratorAggregate
1313
{
14-
/** @var string[] */
14+
/** @var array<string> */
1515
private array $directoryList;
1616

1717
private array $exclude;

src/ClassSetRules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ClassSetRules
1010
{
1111
private ClassSet $classSet;
1212

13-
/** @var ArchRule[] */
13+
/** @var array<ArchRule> */
1414
private array $rules;
1515

1616
private function __construct(ClassSet $classSet, ArchRule ...$rules)

src/Exceptions/IndexNotFoundException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ class IndexNotFoundException extends \Exception
77
{
88
public function __construct(int $index)
99
{
10-
parent::__construct(sprintf('Index not found %d', $index));
10+
parent::__construct(\sprintf('Index not found %d', $index));
1111
}
1212
}

src/Exceptions/PhpVersionNotValidException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ class PhpVersionNotValidException extends \Exception
77
{
88
public function __construct(string $phpVersion)
99
{
10-
parent::__construct(sprintf('PHP version not valid for PHPArkitect parser %s', $phpVersion));
10+
parent::__construct(\sprintf('PHP version not valid for PHPArkitect parser %s', $phpVersion));
1111
}
1212
}

src/Expression/Expression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function describe(ClassDescription $theClass, string $because): Descripti
2929
*
3030
* Not included directly in the interface to allow incremental implementation of it in the rules.
3131
*/
32-
//public function appliesTo(ClassDescription $theClass): bool;
32+
// public function appliesTo(ClassDescription $theClass): bool;
3333

3434
/**
3535
* Evaluates the expression for the class passed as parameter.

src/Expression/ForClasses/DependsOnlyOnTheseNamespaces.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class DependsOnlyOnTheseNamespaces implements Expression
1616
{
17-
/** @var string[] */
17+
/** @var array<string> */
1818
private array $namespaces;
1919

2020
public function __construct(string ...$namespace)

src/Expression/ForClasses/Extend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class Extend implements Expression
1515
{
16-
/** @var string[] */
16+
/** @var array<string> */
1717
private array $classNames;
1818

1919
public function __construct(string ...$classNames)

src/Expression/ForClasses/NotDependsOnTheseNamespaces.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class NotDependsOnTheseNamespaces implements Expression
1616
{
17-
/** @var string[] */
17+
/** @var array<string> */
1818
private array $namespaces;
1919

2020
public function __construct(string ...$namespace)

src/Expression/ForClasses/NotExtend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class NotExtend implements Expression
1515
{
16-
/** @var string[] */
16+
/** @var array<string> */
1717
private array $classNames;
1818

1919
public function __construct(string ...$classNames)

src/Expression/ForClasses/NotHaveDependencyOutsideNamespace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class NotHaveDependencyOutsideNamespace implements Expression
1616
{
1717
private string $namespace;
1818

19-
/** @var string[] */
19+
/** @var array<string> */
2020
private array $externalDependenciesToExclude;
2121

2222
private bool $excludeCoreNamespace;

src/Expression/ForClasses/NotResideInTheseNamespaces.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class NotResideInTheseNamespaces implements Expression
1515
{
16-
/** @var string[] */
16+
/** @var array<string> */
1717
private $namespaces;
1818

1919
public function __construct(string ...$namespaces)

src/Expression/ForClasses/ResideInOneOfTheseNamespaces.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class ResideInOneOfTheseNamespaces implements Expression
1515
{
16-
/** @var string[] */
16+
/** @var array<string> */
1717
private $namespaces;
1818

1919
public function __construct(string ...$namespaces)

src/RuleBuilders/Architecture/Architecture.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ class Architecture implements Component, DefinedBy, Where, MayDependOnComponents
1414
private $componentName;
1515
/** @var array<string, string> */
1616
private $componentSelectors;
17-
/** @var array<string, string[]> */
17+
/** @var array<string, array<string>> */
1818
private $allowedDependencies;
19-
/** @var array<string, string[]> */
19+
/** @var array<string, array<string>> */
2020
private $componentDependsOnlyOnTheseNamespaces;
2121

2222
private function __construct()

src/RuleBuilders/Architecture/MayDependOnComponents.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface MayDependOnComponents
88
/**
99
* May depend on the specified components, plus itself.
1010
*
11-
* @param string[] $componentNames
11+
* @param array<string> $componentNames
1212
*
1313
* @return Where&Rules
1414
*/

src/RuleBuilders/Architecture/ShouldOnlyDependOnComponents.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface ShouldOnlyDependOnComponents
88
/**
99
* May depend ONLY on the specified components, thus it can only depend on itself if itself is specified.
1010
*
11-
* @param string[] $componentNames
11+
* @param array<string> $componentNames
1212
*
1313
* @return Where&Rules
1414
*/

src/Rules/ParsingErrors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class ParsingErrors implements \IteratorAggregate, \Countable
1313
{
1414
/**
15-
* @var ParsingError[]
15+
* @var array<ParsingError>
1616
*/
1717
private $parsingErrors;
1818

src/Rules/Violations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class Violations implements \IteratorAggregate, \Countable, \JsonSerializable
1414
{
1515
/**
16-
* @var Violation[]
16+
* @var array<Violation>
1717
*/
1818
private array $violations;
1919

tests/E2E/Cli/CheckCommandTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function test_json_format_output(): void
176176

177177
$display = $cmdTester->getDisplay();
178178

179-
$this->assertJson($display);
179+
self::assertJson($display);
180180
}
181181

182182
public function test_json_format_output_no_errors(): void
@@ -189,10 +189,10 @@ public function test_json_format_output_no_errors(): void
189189

190190
$display = $cmdTester->getDisplay();
191191

192-
$this->assertJson($display);
192+
self::assertJson($display);
193193

194194
$json = json_decode($display, true);
195-
$this->assertCount(0, $json);
195+
self::assertCount(0, $json);
196196
}
197197

198198
public function test_gitlab_format_output(): void
@@ -205,7 +205,7 @@ public function test_gitlab_format_output(): void
205205

206206
$display = $cmdTester->getDisplay();
207207

208-
$this->assertJson($display);
208+
self::assertJson($display);
209209

210210
self::assertSame(<<<JSON
211211
[{"description":"should have a name that matches *Controller because all controllers should be end name with Controller","check_name":"App\\\\Controller\\\\Foo.should-have-a-name-that-matches-controller-because-all-controllers-should-be-end-name-with-controller","fingerprint":"1e960c3f49b5ec63ece40321072ef2bd0bc33ad11b7be326f304255d277dc860","severity":"major","location":{"path":"Controller\/Foo.php","lines":{"begin":1}}}]
@@ -223,10 +223,10 @@ public function test_gitlab_format_output_no_errors(): void
223223

224224
$display = $cmdTester->getDisplay();
225225

226-
$this->assertJson($display);
226+
self::assertJson($display);
227227

228228
$json = json_decode($display, true);
229-
$this->assertCount(0, $json);
229+
self::assertCount(0, $json);
230230
}
231231

232232
protected function runCheck(
@@ -274,27 +274,27 @@ protected function runCheck(
274274

275275
protected function assertCheckHasErrors(ApplicationTester $applicationTester, ?string $expectedOutput = null): void
276276
{
277-
$this->assertEquals(self::ERROR_CODE, $applicationTester->getStatusCode());
277+
self::assertEquals(self::ERROR_CODE, $applicationTester->getStatusCode());
278278
if (null != $expectedOutput) {
279279
$actualOutput = str_replace(["\r", "\n"], '', $applicationTester->getDisplay());
280280
$expectedOutput = str_replace(["\r", "\n"], '', $expectedOutput);
281-
$this->assertStringContainsString($expectedOutput, $actualOutput);
281+
self::assertStringContainsString($expectedOutput, $actualOutput);
282282
}
283283
}
284284

285285
protected function assertCheckHasNoErrorsLike(ApplicationTester $applicationTester, ?string $expectedOutput = null): void
286286
{
287-
$this->assertEquals(self::ERROR_CODE, $applicationTester->getStatusCode());
287+
self::assertEquals(self::ERROR_CODE, $applicationTester->getStatusCode());
288288
if (null != $expectedOutput) {
289289
$actualOutput = str_replace(["\r", "\n"], '', $applicationTester->getDisplay());
290290
$expectedOutput = str_replace(["\r", "\n"], '', $expectedOutput);
291-
$this->assertStringNotContainsString($expectedOutput, $actualOutput);
291+
self::assertStringNotContainsString($expectedOutput, $actualOutput);
292292
}
293293
}
294294

295295
protected function assertCheckHasSuccess(ApplicationTester $applicationTester): void
296296
{
297-
$this->assertEquals(self::SUCCESS_CODE, $applicationTester->getStatusCode(), 'Command failed: '.$applicationTester->getDisplay());
298-
$this->assertStringNotContainsString('ERRORS!', $applicationTester->getDisplay(), 'Error message not expected in successful execution');
297+
self::assertEquals(self::SUCCESS_CODE, $applicationTester->getStatusCode(), 'Command failed: '.$applicationTester->getDisplay());
298+
self::assertStringNotContainsString('ERRORS!', $applicationTester->getDisplay(), 'Error message not expected in successful execution');
299299
}
300300
}

0 commit comments

Comments
 (0)