-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[REFACTORING] Minor changes and code-quality improvements (#12)
- Loading branch information
Felix Semmler
authored
Jun 17, 2022
1 parent
46b3414
commit 400cf45
Showing
40 changed files
with
516 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
chmod +x .Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs | ||
.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs --config-set installed_paths "$(pwd)/.Build/vendor/phpcompatibility/php-compatibility/PHPCompatibility" | ||
.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs --config-set ignore_warnings_on_exit 1 > /dev/null 2>&1 | ||
.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs --config-set ignore_errors_on_exit 1 > /dev/null 2>&1 | ||
.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs --config-set report_width 200 > /dev/null 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer; | ||
use PhpCsFixer\Fixer\Import\OrderedImportsFixer; | ||
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer; | ||
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer; | ||
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer; | ||
use PhpCsFixer\Fixer\Strict\StrictComparisonFixer; | ||
use PhpCsFixer\Fixer\Strict\StrictParamFixer; | ||
use PhpCsFixer\Fixer\StringNotation\ExplicitStringVariableFixer; | ||
use PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer; | ||
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer; | ||
use Symplify\CodingStandard\Fixer\LineLength\DocBlockLineLengthFixer; | ||
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer; | ||
use Symplify\EasyCodingStandard\ValueObject\Option; | ||
use Symplify\EasyCodingStandard\ValueObject\Set\SetList; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$parameters = $containerConfigurator->parameters(); | ||
$parameters->set( | ||
Option::PATHS, | ||
[ | ||
__DIR__ . '/../Classes', | ||
__DIR__ . '/ecs.php', | ||
] | ||
); | ||
|
||
$containerConfigurator->import(SetList::COMMON); | ||
$containerConfigurator->import(SetList::CLEAN_CODE); | ||
$containerConfigurator->import(SetList::PSR_12); | ||
$containerConfigurator->import(SetList::SYMPLIFY); | ||
|
||
$containerConfigurator->services() | ||
->set(LineLengthFixer::class) | ||
->call('configure', [[ | ||
LineLengthFixer::LINE_LENGTH => 140, | ||
LineLengthFixer::INLINE_SHORT_LINES => false, | ||
]]); | ||
|
||
// Skip Rules and Sniffer | ||
$parameters->set( | ||
Option::SKIP, | ||
[ | ||
// Default Skips | ||
Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer::class => [ | ||
__DIR__ . '/ecs.php', | ||
], | ||
ArrayListItemNewlineFixer::class => null, | ||
ArrayOpenerAndCloserNewlineFixer::class => null, | ||
ClassAttributesSeparationFixer::class => null, | ||
OrderedImportsFixer::class => null, | ||
NotOperatorWithSuccessorSpaceFixer::class => null, | ||
ExplicitStringVariableFixer::class => null, | ||
ArrayIndentationFixer::class => null, | ||
DocBlockLineLengthFixer::class => null, | ||
'\SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff.DuplicateSpaces' => null, | ||
'\SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff.PartialUse' => null, | ||
|
||
// @todo for next upgrade | ||
NoSuperfluousPhpdocTagsFixer::class => null, | ||
// @todo strict php | ||
DeclareStrictTypesFixer::class => null, | ||
StrictComparisonFixer::class => null, | ||
StrictParamFixer::class => null, | ||
] | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
parameters: | ||
ignoreErrors: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
includes: | ||
- phpstan-baseline.neon | ||
- ../.Build/vendor/symplify/phpstan-rules/packages/cognitive-complexity/config/cognitive-complexity-rules.neon | ||
|
||
rules: | ||
- Symplify\PHPStanRules\Rules\NoDefaultExceptionRule | ||
|
||
parameters: | ||
level: max | ||
paths: | ||
- "../Classes/" | ||
|
||
inferPrivatePropertyTypeFromConstructor: true | ||
checkMissingIterableValueType: false | ||
checkGenericClassInNonGenericObjectType: false | ||
|
||
services: | ||
- class: Symplify\Astral\Naming\SimpleNameResolver | ||
- class: Symplify\PHPStanRules\CognitiveComplexity\AstCognitiveComplexityAnalyzer | ||
- class: Symplify\PHPStanRules\CognitiveComplexity\NodeTraverser\ComplexityNodeTraverserFactory | ||
- class: Symplify\PHPStanRules\CognitiveComplexity\DataCollector\CognitiveComplexityDataCollector | ||
- class: Symplify\PHPStanRules\CognitiveComplexity\NodeVisitor\NestingNodeVisitor | ||
- class: Symplify\PHPStanRules\CognitiveComplexity\NodeVisitor\ComplexityNodeVisitor | ||
- class: Symplify\PHPStanRules\CognitiveComplexity\NodeAnalyzer\ComplexityAffectingNodeFinder | ||
- class: Symplify\PackageBuilder\Php\TypeChecker | ||
- class: Symplify\PackageBuilder\Matcher\ArrayStringAndFnMatcher | ||
- class: Symplify\PHPStanRules\TypeAnalyzer\ObjectTypeAnalyzer | ||
- class: Symplify\PHPStanRules\TypeAnalyzer\TypeUnwrapper | ||
- | ||
class: Symplify\PHPStanRules\Rules\ForbiddenFuncCallRule | ||
tags: [phpstan.rules.rule] | ||
arguments: | ||
forbiddenFunctions: | ||
- d | ||
- dd | ||
- die | ||
- dump | ||
- compact | ||
- var_dump |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Core\Configuration\Option; | ||
use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector; | ||
use Rector\Set\ValueObject\SetList; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$parameters = $containerConfigurator->parameters(); | ||
$parameters->set( | ||
Option::PATHS, | ||
[ | ||
__DIR__ . '/../Classes', | ||
__DIR__ . '/../Tests', | ||
__DIR__ . '/rector.php', | ||
__DIR__ . '/rector-8_0.php', | ||
] | ||
); | ||
|
||
$containerConfigurator->import(SetList::PHP_81); | ||
|
||
$parameters->set(Option::AUTO_IMPORT_NAMES, false); | ||
$parameters->set(Option::AUTOLOAD_PATHS, [__DIR__ . '/../Classes']); | ||
$parameters->set(Option::SKIP, []); | ||
|
||
$services = $containerConfigurator->services(); | ||
$services->set(RemoveUnusedPrivatePropertyRector::class); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector; | ||
use Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector; | ||
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector; | ||
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector; | ||
use Rector\CodeQualityStrict\Rector\If_\MoveOutMethodCallInsideIfConditionRector; | ||
use Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector; | ||
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; | ||
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector; | ||
use Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector; | ||
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector; | ||
use Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector; | ||
use Rector\Core\Configuration\Option; | ||
use Rector\DeadCode\Rector\Cast\RecastingRemovalRector; | ||
use Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector; | ||
use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector; | ||
use Rector\Defluent\Rector\Return_\ReturnFluentChainMethodCallToNormalMethodCallRector; | ||
use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector; | ||
use Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector; | ||
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector; | ||
use Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector; | ||
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector; | ||
use Rector\Naming\Rector\Property\MakeBoolPropertyRespectIsHasWasMethodNamingRector; | ||
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; | ||
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector; | ||
use Rector\PHPUnit\Set\PHPUnitSetList; | ||
use Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector; | ||
use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector; | ||
use Rector\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector; | ||
use Rector\Privatization\Rector\Property\PrivatizeLocalPropertyToPrivatePropertyRector; | ||
use Rector\Set\ValueObject\SetList; | ||
use Rector\TypeDeclaration\Rector\ClassMethod\AddArrayParamDocTypeRector; | ||
use Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector; | ||
use Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector; | ||
use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
|
||
$containerConfigurator->import(SetList::CODE_QUALITY); | ||
$containerConfigurator->import(SetList::CODE_QUALITY_STRICT); | ||
$containerConfigurator->import(SetList::CODING_STYLE); | ||
$containerConfigurator->import(SetList::DEAD_CODE); | ||
$containerConfigurator->import(SetList::EARLY_RETURN); | ||
$containerConfigurator->import(SetList::PRIVATIZATION); | ||
$containerConfigurator->import(SetList::TYPE_DECLARATION); | ||
$containerConfigurator->import(SetList::PSR_4); | ||
$containerConfigurator->import(SetList::MYSQL_TO_MYSQLI); | ||
$containerConfigurator->import(SetList::TYPE_DECLARATION_STRICT); | ||
$containerConfigurator->import(SetList::UNWRAP_COMPAT); | ||
|
||
$containerConfigurator->import(SetList::PHP_72); | ||
$containerConfigurator->import(SetList::PHP_73); | ||
$containerConfigurator->import(SetList::PHP_74); | ||
$containerConfigurator->import(SetList::PHP_80); | ||
|
||
$containerConfigurator->import(PHPUnitSetList::PHPUNIT_CODE_QUALITY); | ||
|
||
$parameters = $containerConfigurator->parameters(); | ||
$parameters->set( | ||
Option::PATHS, | ||
[ | ||
__DIR__ . '/../Classes', | ||
__DIR__ . '/rector.php', | ||
] | ||
); | ||
|
||
$parameters->set(Option::AUTO_IMPORT_NAMES, false); | ||
$parameters->set(Option::AUTOLOAD_PATHS, [__DIR__ . '/../Classes']); | ||
$parameters->set( | ||
Option::SKIP, | ||
[ | ||
RecastingRemovalRector::class, | ||
ConsistentPregDelimiterRector::class, | ||
PostIncDecToPreIncDecRector::class, | ||
FinalizeClassesWithoutChildrenRector::class, | ||
ChangeOrIfReturnToEarlyReturnRector::class, | ||
ChangeAndIfToEarlyReturnRector::class, | ||
ReturnBinaryAndToEarlyReturnRector::class, | ||
MakeBoolPropertyRespectIsHasWasMethodNamingRector::class, | ||
MoveOutMethodCallInsideIfConditionRector::class, | ||
ReturnArrayClassMethodToYieldRector::class, | ||
AddArrayParamDocTypeRector::class, | ||
AddArrayReturnDocTypeRector::class, | ||
ReturnFluentChainMethodCallToNormalMethodCallRector::class, | ||
IssetOnPropertyObjectToPropertyExistsRector::class, | ||
FlipTypeControlToUseExclusiveTypeRector::class, | ||
RepeatedLiteralToClassConstantRector::class, | ||
RenameVariableToMatchNewTypeRector::class, | ||
AddLiteralSeparatorToNumberRector::class, | ||
RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class, | ||
ChangeReadOnlyVariableWithDefaultValueToConstantRector::class, | ||
PrivatizeLocalPropertyToPrivatePropertyRector::class, | ||
RemoveDelegatingParentCallRector::class, | ||
|
||
// @todo strict php | ||
ArgumentAdderRector::class, | ||
ParamTypeDeclarationRector::class, | ||
ReturnTypeDeclarationRector::class, | ||
RemoveExtraParametersRector::class, | ||
EncapsedStringsToSprintfRector::class, | ||
AddFalseDefaultToBoolPropertyRector::class, | ||
WrapEncapsedVariableInCurlyBracesRector::class, | ||
UseIdenticalOverEqualWithSameTypeRector::class, | ||
] | ||
); | ||
|
||
$services = $containerConfigurator->services(); | ||
$services->set(RemoveUnusedPrivatePropertyRector::class); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
namespace Aoe\FeatureFlag\Command; | ||
|
||
/*************************************************************** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
namespace Aoe\FeatureFlag\Command; | ||
|
||
/*************************************************************** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
namespace Aoe\FeatureFlag\Command; | ||
|
||
/*************************************************************** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
namespace Aoe\FeatureFlag\Domain\Model; | ||
|
||
/*************************************************************** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.