Skip to content

Commit 17b1c43

Browse files
authored
Merge pull request #392 from phparkitect/fix-cs-fixer-bug-on-ci
Fix cs fixer bug on ci
2 parents ff656da + adeec20 commit 17b1c43

8 files changed

+22
-21
lines changed

.php-cs-fixer.dist.php

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
'modernize_types_casting' => true, // Replaces intval, floatval, doubleval, strval and boolval function calls with according type casting operator.
2525
'multiline_whitespace_before_semicolons' => true, // Forbid multi-line whitespace before the closing semicolon or move the semicolon to the new line for chained calls.
2626
'no_unreachable_default_argument_value' => true, // In function arguments there must not be arguments with default values before non-default ones.
27+
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],// To avoid problems of compatibility with the old php-cs-fixer version used on PHP 7.3
2728
'no_useless_else' => true,
2829
'no_useless_return' => true,
2930
'ordered_class_elements' => true, // Orders the elements of classes/interfaces/traits.

src/Analyzer/ClassDescriptionBuilder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ class ClassDescriptionBuilder
1111
private $classDependencies = [];
1212

1313
/** @var ?FullyQualifiedClassName */
14-
private $FQCN = null;
14+
private $FQCN;
1515

1616
/** @var list<FullyQualifiedClassName> */
1717
private $interfaces = [];
1818

1919
/** @var ?FullyQualifiedClassName */
20-
private $extend = null;
20+
private $extend;
2121

2222
/** @var bool */
2323
private $final = false;

src/Analyzer/FileVisitor.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public function enterNode(Node $node): void
7272
*
7373
* @see FileVisitorTest::test_it_should_return_errors_for_const_outside_namespace
7474
*/
75-
if ($node instanceof Node\Expr\ClassConstFetch &&
76-
method_exists($node->class, 'toString')
75+
if ($node instanceof Node\Expr\ClassConstFetch
76+
&& method_exists($node->class, 'toString')
7777
) {
7878
if ($this->isSelfOrStaticOrParent($node->class->toString())) {
7979
return;
@@ -89,8 +89,8 @@ public function enterNode(Node $node): void
8989
*
9090
* @see FileVisitorTest::test_should_returns_all_dependencies
9191
*/
92-
if ($node instanceof Node\Expr\StaticCall &&
93-
method_exists($node->class, 'toString')
92+
if ($node instanceof Node\Expr\StaticCall
93+
&& method_exists($node->class, 'toString')
9494
) {
9595
if ($this->isSelfOrStaticOrParent($node->class->toString())) {
9696
return;
@@ -100,8 +100,8 @@ public function enterNode(Node $node): void
100100
->addDependency(new ClassDependency($node->class->toString(), $node->getLine()));
101101
}
102102

103-
if ($node instanceof Node\Expr\Instanceof_ &&
104-
method_exists($node->class, 'toString')
103+
if ($node instanceof Node\Expr\Instanceof_
104+
&& method_exists($node->class, 'toString')
105105
) {
106106
if ($this->isSelfOrStaticOrParent($node->class->toString())) {
107107
return;
@@ -110,11 +110,11 @@ public function enterNode(Node $node): void
110110
->addDependency(new ClassDependency($node->class->toString(), $node->getLine()));
111111
}
112112

113-
if ($node instanceof Node\Expr\New_ &&
114-
!($node->class instanceof Node\Expr\Variable)
113+
if ($node instanceof Node\Expr\New_
114+
&& !($node->class instanceof Node\Expr\Variable)
115115
) {
116-
if ((method_exists($node->class, 'isAnonymous') && $node->class->isAnonymous()) ||
117-
!method_exists($node->class, 'toString')) {
116+
if ((method_exists($node->class, 'isAnonymous') && $node->class->isAnonymous())
117+
|| !method_exists($node->class, 'toString')) {
118118
return;
119119
}
120120

src/Analyzer/NameResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function enterNode(Node $node)
175175

176176
if ($this->parseCustomAnnotations && !($node->type instanceof FullyQualified)) {
177177
foreach ($phpDocNode->getTags() as $tagValue) {
178-
if ('@' === $tagValue->name[0] && false === strpos($tagValue->name, '@var')) {
178+
if ('@' === $tagValue->name[0] && !str_contains($tagValue->name, '@var')) {
179179
$customTag = str_replace('@', '', $tagValue->name);
180180
$type = $this->resolveName(new Node\Name($customTag), Use_::TYPE_NORMAL);
181181
$node->type = $type;

src/Analyzer/PatternString.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public function toString(): string
3838
private function containsWildcard(string $pattern): bool
3939
{
4040
return
41-
str_contains($pattern, '*') ||
42-
str_contains($pattern, '?') ||
43-
str_contains($pattern, '.') ||
44-
str_contains($pattern, '[');
41+
str_contains($pattern, '*')
42+
|| str_contains($pattern, '?')
43+
|| str_contains($pattern, '.')
44+
|| str_contains($pattern, '[');
4545
}
4646

4747
private function startsWithPattern(string $pattern): bool

src/Expression/ForClasses/DependsOnlyOnTheseNamespaces.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public function evaluate(ClassDescription $theClass, Violations $violations, str
3636
/** @var ClassDependency $dependency */
3737
foreach ($dependencies as $dependency) {
3838
if (
39-
'' === $dependency->getFQCN()->namespace() ||
40-
$theClass->namespaceMatches($dependency->getFQCN()->namespace())
39+
'' === $dependency->getFQCN()->namespace()
40+
|| $theClass->namespaceMatches($dependency->getFQCN()->namespace())
4141
) {
4242
continue;
4343
}

src/Rules/Violation.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Violation implements \JsonSerializable
1515
/** @var string */
1616
private $error;
1717

18-
public function __construct(string $fqcn, string $error, ?int $line = null)
18+
public function __construct(string $fqcn, string $error, int $line = null)
1919
{
2020
$this->fqcn = $fqcn;
2121
$this->error = $error;

tests/E2E/Cli/CheckCommandTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function test_you_can_ignore_the_default_baseline(): void
149149
protected function runCheck(
150150
$configFilePath = null,
151151
bool $stopOnFailure = null,
152-
?string $useBaseline = null,
152+
string $useBaseline = null,
153153
$generateBaseline = false,
154154
bool $skipBaseline = false
155155
): ApplicationTester {

0 commit comments

Comments
 (0)