Skip to content

Commit

Permalink
[cs] Re-run ECS dev version to try out regression (#4595)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jul 25, 2023
1 parent 20d8c79 commit c1e03db
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 60 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"rector/rector-generator": "dev-main",
"spatie/enum": "^3.13",
"symplify/easy-ci": "^11.1.18",
"symplify/easy-coding-standard": "^11.3",
"symplify/easy-coding-standard": "^11.5",
"symplify/phpstan-extensions": "^11.2",
"symplify/phpstan-rules": "^12.0",
"symplify/rule-doc-generator": "^11.2",
Expand Down
14 changes: 10 additions & 4 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Style\SymfonyStyle;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
use function Symfony\Component\DependencyInjection\Loader\Configurator\tagged_iterator;
use Symfony\Component\Filesystem\Filesystem;
use Symplify\EasyParallel\ValueObject\EasyParallelConfig;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
use function Symfony\Component\DependencyInjection\Loader\Configurator\tagged_iterator;

return static function (RectorConfig $rectorConfig): void {
// make use of https://github.com/symplify/easy-parallel
Expand Down Expand Up @@ -263,9 +263,15 @@

$services->set(\PHPStan\PhpDocParser\Lexer\Lexer::class);
$services->set(TypeParser::class)
->arg('$usedAttributes', ['lines' => true, 'indexes' => true]);
->arg('$usedAttributes', [
'lines' => true,
'indexes' => true,
]);
$services->set(ConstExprParser::class)
->arg('$usedAttributes', ['lines' => true, 'indexes' => true]);
->arg('$usedAttributes', [
'lines' => true,
'indexes' => true,
]);

// tagged services
$services->set(PhpDocNodeMapper::class)
Expand Down
6 changes: 1 addition & 5 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
use PhpCsFixer\Fixer\Phpdoc\PhpdocNoEmptyReturnFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitStrictFixer;
use Symplify\CodingStandard\Fixer\LineLength\DocBlockLineLengthFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ecsConfig): void {
$ecsConfig->sets([SetList::PSR_12, SetList::SYMPLIFY, SetList::COMMON, SetList::CLEAN_CODE]);
$ecsConfig->sets([SetList::SYMPLIFY, SetList::COMMON, SetList::CLEAN_CODE, SetList::PSR_12]);

$ecsConfig->paths([
__DIR__ . '/bin',
Expand Down Expand Up @@ -60,9 +59,6 @@
'*/Fixture/*',
'*/Expected/*',

// buggy - @todo fix on Symplify master
DocBlockLineLengthFixer::class,

PhpdocTypesFixer::class => [
// double to Double false positive
__DIR__ . '/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ public function __construct(
// preserveTypeAliasesWithInvalidTypes
false,
// usedAttributes
['lines' => true, 'indexes' => true],
[
'lines' => true,
'indexes' => true,
],
// parseDoctrineAnnotations
false,
// textBetweenTagsBelongsToDescription, default to false, exists since 1.23.0
Expand Down
22 changes: 13 additions & 9 deletions packages/PHPStanStaticTypeMapper/TypeMapper/ClosureTypeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,21 @@ public function mapToPHPStanPhpDocTypeNode(Type $type): TypeNode
$typeNode = $type->toPhpDocNode();

$phpDocNodeTraverser = new PhpDocNodeTraverser();
$phpDocNodeTraverser->traverseWithCallable($typeNode, '', static function (AstNode $astNode) : ?FullyQualifiedIdentifierTypeNode {
if (! $astNode instanceof IdentifierTypeNode) {
return null;
}
$phpDocNodeTraverser->traverseWithCallable(
$typeNode,
'',
static function (AstNode $astNode): ?FullyQualifiedIdentifierTypeNode {
if (! $astNode instanceof IdentifierTypeNode) {
return null;
}

if ($astNode->name !== 'Closure') {
return null;
}
if ($astNode->name !== 'Closure') {
return null;
}

return new FullyQualifiedIdentifierTypeNode('Closure');
});
return new FullyQualifiedIdentifierTypeNode('Closure');
}
);

return $typeNode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ public function getShortNameType(): ShortenedObjectType
return new ShortenedObjectType($this->getShortName(), $this->getClassName());
}

public function areShortNamesEqual(
AliasedObjectType | \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $comparedObjectType
): bool {
public function areShortNamesEqual(AliasedObjectType | self $comparedObjectType): bool
{
return $this->getShortName() === $comparedObjectType->getShortName();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Stmt\Property;
use Rector\Core\Rector\AbstractRector;
use function strtolower;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use function strtolower;

/**
* @see \Rector\Tests\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector\RemoveNullPropertyInitializationRectorTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public function getRuleDefinition(): RuleDefinition
return new RuleDefinition(
'Add typed public properties based only on strict constructor types in readonly classes',
[
new CodeSample(
<<<'CODE_SAMPLE'
new CodeSample(
<<<'CODE_SAMPLE'
/**
* @immutable
*/
Expand All @@ -65,8 +65,8 @@ public function __construct(string $name)
}
CODE_SAMPLE

,
<<<'CODE_SAMPLE'
,
<<<'CODE_SAMPLE'
/**
* @immutable
*/
Expand All @@ -80,9 +80,10 @@ public function __construct(string $name)
}
}
CODE_SAMPLE
),

]);
),

]
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,10 @@ public function refactor(Node $node): ?Node

// public property can be anything
if ($property->isPublic()) {
if (!$phpDocInfo->getVarType() instanceof MixedType) {
if (! $phpDocInfo->getVarType() instanceof MixedType) {
continue;
}


$this->phpDocTypeChanger->changeVarType($property, $phpDocInfo, $propertyType);
$hasChanged = true;
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/SetupCICommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
use Nette\Utils\FileSystem;
use Nette\Utils\Strings;
use OndraM\CiDetector\CiDetector;
use function sprintf;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Process\Process;
use function sprintf;

final class SetupCICommand extends Command
{
Expand Down
26 changes: 0 additions & 26 deletions stubs/PhpCsFixer/Tokenizer/Tokens.php

This file was deleted.

0 comments on commit c1e03db

Please sign in to comment.