Skip to content

Commit

Permalink
Fix: Run 'make coding-standards'
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Apr 30, 2023
1 parent 6392fa9 commit 73d7ef8
Show file tree
Hide file tree
Showing 30 changed files with 62 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.fixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* Copyright (c) 2018-2020 Andreas M枚ller
* Copyright (c) 2018-2023 Andreas M枚ller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
Expand Down
22 changes: 8 additions & 14 deletions src/Classes/FinalRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class FinalRule implements Rule
/**
* @var array<int, string>
*/
private static $whitelistedAnnotations = [
private static array $whitelistedAnnotations = [
'Entity',
'ORM\Entity',
'ORM\Mapping\Entity',
Expand All @@ -33,31 +33,25 @@ final class FinalRule implements Rule
/**
* @var array<int, class-string>
*/
private static $whitelistedAttributes = [
private static array $whitelistedAttributes = [
'Doctrine\ORM\Mapping\Entity',
];

/**
* @var bool
*/
private $allowAbstractClasses;
private bool $allowAbstractClasses;

/**
* @var array<int, string>
*/
private $classesNotRequiredToBeAbstractOrFinal;
private array $classesNotRequiredToBeAbstractOrFinal;

/**
* @var string
*/
private $errorMessageTemplate = 'Class %s is not final.';
private string $errorMessageTemplate = 'Class %s is not final.';

/**
* @param array<int, class-string> $classesNotRequiredToBeAbstractOrFinal
*/
public function __construct(
bool $allowAbstractClasses,
array $classesNotRequiredToBeAbstractOrFinal
array $classesNotRequiredToBeAbstractOrFinal,
) {
$this->allowAbstractClasses = $allowAbstractClasses;
$this->classesNotRequiredToBeAbstractOrFinal = \array_map(static function (string $classNotRequiredToBeAbstractOrFinal): string {
Expand All @@ -76,13 +70,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
if (!$node instanceof Node\Stmt\Class_) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
Node\Stmt\Class_::class,
\get_class($node),
$node::class,
));
}

Expand Down
8 changes: 4 additions & 4 deletions src/Classes/NoExtendsRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ final class NoExtendsRule implements Rule
/**
* @var array<int, class-string>
*/
private static $defaultClassesAllowedToBeExtended = [
private static array $defaultClassesAllowedToBeExtended = [
'PHPUnit\\Framework\\TestCase',
];

/**
* @var array<int, class-string>
*/
private $classesAllowedToBeExtended;
private array $classesAllowedToBeExtended;

/**
* @param array<int, class-string> $classesAllowedToBeExtended
Expand All @@ -53,13 +53,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
if (!$node instanceof Node\Stmt\Class_) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
Node\Stmt\Class_::class,
\get_class($node),
$node::class,
));
}

Expand Down
11 changes: 4 additions & 7 deletions src/Classes/PHPUnit/Framework/TestCaseWithSuffixRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@ final class TestCaseWithSuffixRule implements Rules\Rule
/**
* @var array<int, class-string>
*/
private static $phpunitTestCaseClassNames = [
private static array $phpunitTestCaseClassNames = [
'PHPUnit\Framework\TestCase',
];

/**
* @var Reflection\ReflectionProvider
*/
private $reflectionProvider;
private Reflection\ReflectionProvider $reflectionProvider;

public function __construct(Reflection\ReflectionProvider $reflectionProvider)
{
Expand All @@ -45,13 +42,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Analyser\Scope $scope
Analyser\Scope $scope,
): array {
if (!$node instanceof Node\Stmt\Class_) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
Node\Stmt\Class_::class,
\get_class($node),
$node::class,
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Closures/NoNullableReturnTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
if (!$node instanceof Node\Expr\Closure) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
Node\Expr\Closure::class,
\get_class($node),
$node::class,
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Closures/NoParameterWithNullDefaultValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
if (!$node instanceof Node\Expr\Closure) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
Node\Expr\Closure::class,
\get_class($node),
$node::class,
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Closures/NoParameterWithNullableTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
if (!$node instanceof Node\Expr\Closure) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
Node\Expr\Closure::class,
\get_class($node),
$node::class,
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Expressions/NoCompactRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
if (!$node instanceof Node\Expr\FuncCall) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
Node\Expr\FuncCall::class,
\get_class($node),
$node::class,
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Expressions/NoEmptyRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
return [
'Language construct empty() should not be used.',
Expand Down
2 changes: 1 addition & 1 deletion src/Expressions/NoErrorSuppressionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
return [
'Error suppression via "@" should not be used.',
Expand Down
2 changes: 1 addition & 1 deletion src/Expressions/NoEvalRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
return [
'Language construct eval() should not be used.',
Expand Down
2 changes: 1 addition & 1 deletion src/Expressions/NoIssetRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
return [
'Language construct isset() should not be used.',
Expand Down
4 changes: 2 additions & 2 deletions src/Files/DeclareStrictTypesRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
if (!$node instanceof FileNode) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
FileNode::class,
\get_class($node),
$node::class,
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Functions/NoNullableReturnTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
if (!$node instanceof Node\Stmt\Function_) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
Node\Stmt\Function_::class,
\get_class($node),
$node::class,
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Functions/NoParameterWithNullDefaultValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
if (!$node instanceof Node\Stmt\Function_) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
Node\Stmt\Function_::class,
\get_class($node),
$node::class,
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Functions/NoParameterWithNullableTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
if (!$node instanceof Node\Stmt\Function_) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
Node\Stmt\Function_::class,
\get_class($node),
$node::class,
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Methods/FinalInAbstractClassRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
if (!$node instanceof Node\Stmt\ClassMethod) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
Node\Stmt\ClassMethod::class,
\get_class($node),
$node::class,
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Methods/NoConstructorParameterWithDefaultValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
if (!$node instanceof Node\Stmt\ClassMethod) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
Node\Stmt\ClassMethod::class,
\get_class($node),
$node::class,
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Methods/NoNullableReturnTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
if (!$node instanceof Node\Stmt\ClassMethod) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
Node\Stmt\ClassMethod::class,
\get_class($node),
$node::class,
));
}

Expand Down
15 changes: 6 additions & 9 deletions src/Methods/NoParameterWithContainerTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,19 @@

final class NoParameterWithContainerTypeDeclarationRule implements Rule
{
/**
* @var Reflection\ReflectionProvider
*/
private $reflectionProvider;
private Reflection\ReflectionProvider $reflectionProvider;

/**
* @var array<int, string>
*/
private $interfacesImplementedByContainers;
private array $interfacesImplementedByContainers;

/**
* @param array<int, string> $interfacesImplementedByContainers
*/
public function __construct(
Reflection\ReflectionProvider $reflectionProvider,
array $interfacesImplementedByContainers
array $interfacesImplementedByContainers,
) {
$this->reflectionProvider = $reflectionProvider;
$this->interfacesImplementedByContainers = \array_filter(
Expand All @@ -56,13 +53,13 @@ public function getNodeType(): string

public function processNode(
Node $node,
Scope $scope
Scope $scope,
): array {
if (!$node instanceof Node\Stmt\ClassMethod) {
throw new ShouldNotHappenException(\sprintf(
'Expected node to be instance of "%s", but got instance of "%s" instead.',
Node\Stmt\ClassMethod::class,
\get_class($node),
$node::class,
));
}

Expand Down Expand Up @@ -134,7 +131,7 @@ private static function createError(
Reflection\ClassReflection $classReflection,
string $methodName,
string $parameterName,
Reflection\ClassReflection $classUsedInTypeDeclaration
Reflection\ClassReflection $classUsedInTypeDeclaration,
): string {
if ($classReflection->isAnonymous()) {
return \sprintf(
Expand Down

0 comments on commit 73d7ef8

Please sign in to comment.