Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Bump to Symplify 3.1 #74

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions composer.json
Expand Up @@ -9,12 +9,12 @@
"nette/utils": "^2.4"
},
"require-dev": {
"phpunit/phpunit": "^6.4",
"phpstan/phpstan": "^0.8",
"phpunit/phpunit": "^6.5",
"phpstan/phpstan": "^0.9",
"tracy/tracy": "^2.4",
"symplify/easy-coding-standard": "^2.5",
"symplify/coding-standard": "^2.5",
"slevomat/coding-standard": "^4.0"
"symplify/easy-coding-standard": "^3.1",
"symplify/coding-standard": "^3.1",
"slevomat/coding-standard": "^4.1"
},
"autoload": {
"psr-4": {
Expand Down
52 changes: 5 additions & 47 deletions easy-coding-standard.neon
@@ -1,11 +1,7 @@
includes:
- vendor/symplify/easy-coding-standard/config/symfony-checkers.neon
- vendor/symplify/easy-coding-standard/config/php54-checkers.neon
- vendor/symplify/easy-coding-standard/config/php70-checkers.neon
- vendor/symplify/easy-coding-standard/config/php71-checkers.neon
# custom
- vendor/symplify/easy-coding-standard/config/symplify.neon
- vendor/symplify/easy-coding-standard/config/php71.neon
- vendor/symplify/easy-coding-standard/config/common.neon
- vendor/symplify/easy-coding-standard/config/spaces.neon

checkers:
# All rules with default values
Expand Down Expand Up @@ -61,49 +57,11 @@ checkers:
SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff:
enableEachParameterAndReturnInspection: true

# Symplify
- Symplify\CodingStandard\Fixer\Php\ClassStringToClassConstantFixer
- Symplify\CodingStandard\Sniffs\PHPUnit\FinalTestCaseSniff
- Symplify\CodingStandard\Sniffs\Debug\DebugFunctionCallSniff
- Symplify\CodingStandard\Sniffs\Property\DynamicPropertySniff

# Control Structures
- Symplify\CodingStandard\Sniffs\ControlStructures\NewClassSniff
- Symplify\CodingStandard\Fixer\Property\ArrayPropertyDefaultValueFixer
- Symplify\CodingStandard\Fixer\ArrayNotation\StandaloneLineInMultilineArrayFixer
- Symplify\CodingStandard\Fixer\ControlStructure\RequireFollowedByAbsolutePathFixer

# Spaces
- Symplify\CodingStandard\Fixer\ClassNotation\PropertyAndConstantSeparationFixer
- Symplify\CodingStandard\Fixer\ClassNotation\LastPropertyAndFirstMethodSeparationFixer

# Comments
- Symplify\CodingStandard\Fixer\Commenting\BlockPropertyCommentFixer
- Symplify\CodingStandard\Sniffs\Commenting\VarConstantCommentSniff
- Symplify\CodingStandard\Sniffs\Debug\CommentedOutCodeSniff
- Symplify\CodingStandard\Fixer\Commenting\AnnotateMagicContainerGetterFixer

# Naming
- Symplify\CodingStandard\Sniffs\Naming\AbstractClassNameSniff
- Symplify\CodingStandard\Sniffs\Naming\InterfaceNameSniff
- Symplify\CodingStandard\Sniffs\Naming\TraitNameSniff
- Symplify\CodingStandard\Fixer\Naming\MagicMethodsNamingFixer
- Symplify\CodingStandard\Fixer\Naming\PropertyNameMatchingTypeFixer

# Architecture
- Symplify\CodingStandard\Sniffs\Classes\EqualInterfaceImplementationSniff
- Symplify\CodingStandard\Sniffs\Classes\FinalInterfaceSniff

parameters:
skip:
SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff:
- *src/ObjectCalisthenics/Sniffs/*/*Sniff.php

exclude_checkers:
# Symfony ruleset
- PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer
- PhpCsFixer\Fixer\Operator\NewWithBracesFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer
# mutually excluded
- SlevomatCodingStandard\Sniffs\ControlStructures\DisallowYodaComparisonSniff
- PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer
PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff:
# while() assign
- src/ObjectCalisthenics/Helper/ClassAnalyzer.php
4 changes: 0 additions & 4 deletions phpstan.neon
@@ -1,7 +1,3 @@
parameters:
autoload_files:
- %currentWorkingDirectory%/vendor/squizlabs/php_codesniffer/autoload.php
excludes_analyse:
- **/ObjectCalisthenics/Helper/Slevomat/**
ignoreErrors:
- '#Method ObjectCalisthenics\\Sniffs\\Metrics\\MaxNestingLevelSniff::register\(\) should return int\[\] but returns \(int\|string\)\[\]#'
Expand Up @@ -24,7 +24,6 @@ public function register(): array
}

/**
* @param File $file
* @param int $position
*/
public function process(File $file, $position): void
Expand Down
Expand Up @@ -68,7 +68,6 @@ public function register(): array
}

/**
* @param File $file
* @param int $position
*/
public function process(File $file, $position): void
Expand Down Expand Up @@ -134,7 +133,7 @@ private function isInFluentInterfaceMode(): bool
$lastEndPoint = $this->computeLastCallOfAnyFrom($this->methodsEndingAFluentInterface);
$lastStartPoint = $this->computeLastCallOfAnyFrom($this->methodsStartingAFluentInterface);

if (in_array($this->variableName, $this->variablesHoldingAFluentInterface)) {
if (in_array($this->variableName, $this->variablesHoldingAFluentInterface, true)) {
$lastStartPoint = max($lastStartPoint, -1);
}

Expand All @@ -151,7 +150,7 @@ private function isInFluentInterfaceMode(): bool
private function computeLastCallOfAnyFrom(array $methods): int
{
$calls = array_filter($this->callerTokens, function (array $token) use ($methods) {
return in_array($token['token']['content'], $methods);
return in_array($token['token']['content'], $methods, true);
});
if (count($calls) > 0) {
return array_search(end($calls), $this->callerTokens);
Expand Down
Expand Up @@ -21,7 +21,6 @@ public function register(): array
}

/**
* @param File $file
* @param int $position
*/
public function process(File $file, $position): void
Expand Down
Expand Up @@ -27,7 +27,6 @@ public function register(): array
}

/**
* @param File $file
* @param int $position
*/
public function process(File $file, $position): void
Expand Down
Expand Up @@ -27,7 +27,6 @@ public function register(): array
}

/**
* @param File $file
* @param int $position
*/
public function process(File $file, $position): void
Expand Down
Expand Up @@ -43,16 +43,15 @@ final class MaxNestingLevelSniff implements Sniff
private $currentPtr;

/**
* @return int[]
* @return int[]|string[]
*/
public function register(): array
{
return [T_FUNCTION, T_CLOSURE];
}

/**
* @param File $file
* @param int $position
* @param int $position
*/
public function process(File $file, $position): void
{
Expand Down Expand Up @@ -151,7 +150,7 @@ private function handleClosureToken(array $nestedToken): void
*/
private function handleCaseToken(array $nestedToken): void
{
if (in_array($nestedToken['code'], [T_CASE, T_DEFAULT])) {
if (in_array($nestedToken['code'], [T_CASE, T_DEFAULT], true)) {
array_push($this->ignoredScopeStack, $nestedToken);

return;
Expand Down
Expand Up @@ -28,8 +28,7 @@ public function register(): array
}

/**
* @param File $file
* @param int $position
* @param int $position
*/
public function process(File $file, $position): void
{
Expand Down
Expand Up @@ -27,8 +27,7 @@ public function register(): array
}

/**
* @param File $file
* @param int $position
* @param int $position
*/
public function process(File $file, $position): void
{
Expand Down
Expand Up @@ -32,7 +32,6 @@ public function register(): array
}

/**
* @param File $file
* @param int $position
*/
public function process(File $file, $position): void
Expand Down Expand Up @@ -70,6 +69,6 @@ private function shouldBeSkipped(int $elementNameLength, string $elementName): b

private function isShortNameAllowed(string $variableName): bool
{
return in_array($variableName, $this->allowedShortNames);
return in_array($variableName, $this->allowedShortNames, true);
}
}
Expand Up @@ -27,8 +27,7 @@ public function register(): array
}

/**
* @param File $file
* @param int $position
* @param int $position
*/
public function process(File $file, $position): void
{
Expand Down
6 changes: 3 additions & 3 deletions tests/FileFactory.php
Expand Up @@ -20,13 +20,13 @@ public function __construct()

// initialize Token constants
if (! defined('T_NONE')) {
new Tokens;
new Tokens();
}
}

public function createFile(string $filePath): File
{
$config = new Config;
$config = new Config();
$ruleset = new Ruleset($config);

$file = new File($filePath, $ruleset, $config);
Expand All @@ -38,7 +38,7 @@ public function createFile(string $filePath): File

public function createFileWithSniffClass(string $filePath, string $sniffClass): File
{
$config = new Config;
$config = new Config();
$ruleset = $this->createRulesetWithConfigAndSniffClass($sniffClass, $config);

$file = new File($filePath, $ruleset, $config);
Expand Down
2 changes: 1 addition & 1 deletion tests/Helper/ClassAnalyzerTest.php
Expand Up @@ -21,7 +21,7 @@ final class ClassAnalyzerTest extends TestCase

protected function setUp(): void
{
$fileFactory = new FileFactory;
$fileFactory = new FileFactory();
$this->file = $fileFactory->createFile(__DIR__ . '/ClassAnalyzerSource/SomeFile.php.inc');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Helper/NamingTest.php
Expand Up @@ -30,7 +30,7 @@ final class NamingTest extends TestCase

protected function setUp(): void
{
$this->fileFactory = new FileFactory;
$this->fileFactory = new FileFactory();
}

public function test(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Helper/PropertyHelperTest.php
Expand Up @@ -10,7 +10,7 @@ final class PropertyHelperTest extends TestCase
{
public function test(): void
{
$fileFactory = new FileFactory;
$fileFactory = new FileFactory();
$file = $fileFactory->createFile(__DIR__ . '/PropertyHelperSource/SomeFile.php.inc');

$this->assertTrue(PropertyHelper::isProperty($file, 11));
Expand Down
2 changes: 1 addition & 1 deletion tests/Helper/Structure/StructureMetricsTest.php
Expand Up @@ -25,7 +25,7 @@ final class StructureMetricsTest extends TestCase

protected function setUp(): void
{
$this->fileFactory = new FileFactory;
$this->fileFactory = new FileFactory();
}

public function test(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Sniffs/AbstractSniffTestCase.php
Expand Up @@ -30,7 +30,7 @@ abstract class AbstractSniffTestCase extends TestCase

protected function runSniffTestForDirectory(string $sniffClass, string $directory): void
{
$container = (new ContainerFactory)->create();
$container = (new ContainerFactory())->create();
$this->sniffFileProcessor = $container->get(SniffFileProcessor::class);
$this->errorCollector = $container->get(ErrorCollector::class);
$this->fixer = $container->get(Fixer::class);
Expand Down Expand Up @@ -101,7 +101,7 @@ private function processFileWithSniff(string $sniffClass, SplFileInfo $fileInfo)
{
$this->errorCollector->resetCounters();
$this->sniffFileProcessor->setIsFixer(true); // to test changed content of file
$this->sniffFileProcessor->setSingleSniff(new $sniffClass);
$this->sniffFileProcessor->setSingleSniff(new $sniffClass());
$this->sniffFileProcessor->processFile($fileInfo, true);
}
}