Skip to content

Commit

Permalink
[DX] Removing more parent abstract circular classes (#5709)
Browse files Browse the repository at this point in the history
Co-authored-by: kaizen-ci <[email protected]>
  • Loading branch information
TomasVotruba and kaizen-ci authored Feb 28, 2021
1 parent a62bb98 commit 8c3443b
Show file tree
Hide file tree
Showing 43 changed files with 505 additions and 458 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,30 @@

namespace Rector\BetterPhpDocParser\ValueObjectFactory\PhpDocNode\Doctrine;

use Rector\BetterPhpDocParser\Printer\ArrayPartPhpDocTagPrinter;
use Rector\BetterPhpDocParser\Printer\TagValueNodePrinter;
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\Doctrine\Property_\ColumnTagValueNode;
use Rector\BetterPhpDocParser\ValueObjectFactory\PhpDocNode\AbstractTagValueNodeFactory;

final class ColumnTagValueNodeFactory extends AbstractTagValueNodeFactory
final class ColumnTagValueNodeFactory
{
/**
* @var ArrayPartPhpDocTagPrinter
*/
private $arrayPartPhpDocTagPrinter;

/**
* @var TagValueNodePrinter
*/
private $tagValueNodePrinter;

public function __construct(
ArrayPartPhpDocTagPrinter $arrayPartPhpDocTagPrinter,
TagValueNodePrinter $tagValueNodePrinter
) {
$this->arrayPartPhpDocTagPrinter = $arrayPartPhpDocTagPrinter;
$this->tagValueNodePrinter = $tagValueNodePrinter;
}

public function create(): ColumnTagValueNode
{
return $this->createFromItems([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,30 @@

namespace Rector\BetterPhpDocParser\ValueObjectFactory\PhpDocNode\Doctrine;

use Rector\BetterPhpDocParser\Printer\ArrayPartPhpDocTagPrinter;
use Rector\BetterPhpDocParser\Printer\TagValueNodePrinter;
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\Doctrine\Class_\EntityTagValueNode;
use Rector\BetterPhpDocParser\ValueObjectFactory\PhpDocNode\AbstractTagValueNodeFactory;

final class EntityTagValueNodeFactory extends AbstractTagValueNodeFactory
final class EntityTagValueNodeFactory
{
/**
* @var ArrayPartPhpDocTagPrinter
*/
private $arrayPartPhpDocTagPrinter;

/**
* @var TagValueNodePrinter
*/
private $tagValueNodePrinter;

public function __construct(
ArrayPartPhpDocTagPrinter $arrayPartPhpDocTagPrinter,
TagValueNodePrinter $tagValueNodePrinter
) {
$this->arrayPartPhpDocTagPrinter = $arrayPartPhpDocTagPrinter;
$this->tagValueNodePrinter = $tagValueNodePrinter;
}

public function create(): EntityTagValueNode
{
return $this->createFromItems([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,30 @@

namespace Rector\BetterPhpDocParser\ValueObjectFactory\PhpDocNode\Doctrine;

use Rector\BetterPhpDocParser\Printer\ArrayPartPhpDocTagPrinter;
use Rector\BetterPhpDocParser\Printer\TagValueNodePrinter;
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\Doctrine\Property_\JoinColumnTagValueNode;
use Rector\BetterPhpDocParser\ValueObjectFactory\PhpDocNode\AbstractTagValueNodeFactory;

final class JoinColumnTagValueNodeFactory extends AbstractTagValueNodeFactory
final class JoinColumnTagValueNodeFactory
{
/**
* @var ArrayPartPhpDocTagPrinter
*/
private $arrayPartPhpDocTagPrinter;

/**
* @var TagValueNodePrinter
*/
private $tagValueNodePrinter;

public function __construct(
ArrayPartPhpDocTagPrinter $arrayPartPhpDocTagPrinter,
TagValueNodePrinter $tagValueNodePrinter
) {
$this->arrayPartPhpDocTagPrinter = $arrayPartPhpDocTagPrinter;
$this->tagValueNodePrinter = $tagValueNodePrinter;
}

/**
* @param array<string, mixed> $items
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,30 @@

namespace Rector\BetterPhpDocParser\ValueObjectFactory\PhpDocNode\Symfony;

use Rector\BetterPhpDocParser\Printer\ArrayPartPhpDocTagPrinter;
use Rector\BetterPhpDocParser\Printer\TagValueNodePrinter;
use Rector\BetterPhpDocParser\ValueObject\PhpDocNode\Symfony\SymfonyRouteTagValueNode;
use Rector\BetterPhpDocParser\ValueObjectFactory\PhpDocNode\AbstractTagValueNodeFactory;

final class SymfonyRouteTagValueNodeFactory extends AbstractTagValueNodeFactory
final class SymfonyRouteTagValueNodeFactory
{
/**
* @var ArrayPartPhpDocTagPrinter
*/
private $arrayPartPhpDocTagPrinter;

/**
* @var TagValueNodePrinter
*/
private $tagValueNodePrinter;

public function __construct(
ArrayPartPhpDocTagPrinter $arrayPartPhpDocTagPrinter,
TagValueNodePrinter $tagValueNodePrinter
) {
$this->arrayPartPhpDocTagPrinter = $arrayPartPhpDocTagPrinter;
$this->tagValueNodePrinter = $tagValueNodePrinter;
}

public function create(): SymfonyRouteTagValueNode
{
return $this->createFromItems([]);
Expand Down
2 changes: 1 addition & 1 deletion packages/testing/src/PHPUnit/RunnableRectorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private function createTemporaryPathWithPrefix(SmartFileInfo $smartFileInfo): st
// warning: if this hash is too short, the file can becom "identical"; took me 1 hour to find out
$hash = Strings::substring(md5($smartFileInfo->getRealPath()), -15);

return sprintf(sys_get_temp_dir() . '/_rector_runnable_%s_%s', $hash, $smartFileInfo->getBasename('.inc'));
return sprintf(sys_get_temp_dir() . '/rector/runnable_%s_%s', $hash, $smartFileInfo->getBasename('.inc'));
}

private function getTemporaryClassSuffix(): string
Expand Down
9 changes: 9 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -597,3 +597,12 @@ parameters:
- '#Cognitive complexity for "Rector\\NetteCodeQuality\\FormControlTypeResolver\\MagicNetteFactoryInterfaceFormControlTypeResolver\:\:resolve\(\)" is 11, keep it under 9#'
- '#Cognitive complexity for "Rector\\NetteCodeQuality\\FormControlTypeResolver\\MagicNetteFactoryInterfaceFormControlTypeResolver\:\:resolve\(\)" is 12, keep it under 9#'
- '#Content of method "matchAssignExprToPropertyName\(\)" is duplicated with method "matchAssignExprToPropertyName\(\)" in "Rector\\TypeDeclaration\\AlreadyAssignDetector\\ConstructorAssignDetector" class\. Use unique content or abstract service instead#'
# make more tolerand, e.g. at least 2-3 lines
- '#Content of method "isConflicting\(\)" is duplicated with method "isConflicting\(\)" in "Rector\\Naming\\Guard\\PropertyConflictingNameGuard\\AbstractPropertyConflictingNameGuard" class\. Use unique content or abstract service instead#'
- '#Content of method "isConflicting\(\)" is duplicated with method "isConflicting\(\)" in "Rector\\Naming\\Guard\\PropertyConflictingNameGuard\\MatchPropertyTypeConflictingNameGuard" class\. Use unique content or abstract service instead#'
- '#Content of method "isConflicting\(\)" is duplicated with method "isConflicting\(\)" in "Rector\\Naming\\Guard\\PropertyConflictingNameGuard\\UnderscoreCamelCaseConflictingNameGuard" class\. Use unique content or abstract service instead#'
- '#Content of method "isConflicting\(\)" is duplicated with method "isConflicting\(\)" in "Rector\\Naming\\Guard\\PropertyConflictingNameGuard\\UnderscoreCamelCaseConflictingNameGuard" class\. Use unique content or abstract service instead#'
- '#Content of method "isConflicting\(\)" is duplicated with method "isConflicting\(\)" in "Rector\\Naming\\Guard\\PropertyConflictingNameGuard\\UnderscoreCamelCaseConflictingNameGuard" class\. Use unique content or abstract service instead#'
- '#Content of method "isConflicting\(\)" is duplicated with method "isConflicting\(\)" in "Rector\\Naming\\Guard\\PropertyConflictingNameGuard\\BoolPropertyConflictingNameGuard" class\. Use unique content or abstract service instead#'
- '#Content of method "isConflicting\(\)" is duplicated with method "isConflicting\(\)" in "Rector\\Naming\\Guard\\PropertyConflictingNameGuard\\BoolPropertyConflictingNameGuard" class\. Use unique content or abstract service instead#'

8 changes: 4 additions & 4 deletions rules/code-quality/src/Rector/For_/ForToForeachRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class ForToForeachRector extends AbstractRector
/**
* @var Expr|null
*/
private $countValueVariable;
private $countValueVariableExpr;

/**
* @var Expr|null
Expand Down Expand Up @@ -160,7 +160,7 @@ public function refactor(Node $node): ?Node
return null;
}

if ($this->forAnalyzer->isCountValueVariableUsedInsideForStatements($node, $this->countValueVariable)) {
if ($this->forAnalyzer->isCountValueVariableUsedInsideForStatements($node, $this->countValueVariableExpr)) {
return null;
}

Expand Down Expand Up @@ -228,7 +228,7 @@ private function createForeachFromForWithIteratedVariableSingle(For_ $for, strin
private function reset(): void
{
$this->keyValueName = null;
$this->countValueVariable = null;
$this->countValueVariableExpr = null;
$this->countValueName = null;
$this->iteratedExpr = null;
}
Expand All @@ -254,7 +254,7 @@ private function matchInit(array $initExprs): void
$funcCall = $initExpr->expr;

if ($this->nodeNameResolver->isFuncCallName($funcCall, self::COUNT)) {
$this->countValueVariable = $initExpr->var;
$this->countValueVariableExpr = $initExpr->var;
$this->countValueName = $this->getName($initExpr->var);
$this->iteratedExpr = $funcCall->args[0]->value;
}
Expand Down

This file was deleted.

10 changes: 0 additions & 10 deletions rules/naming/src/Contract/Guard/ConflictingGuardAwareInterface.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Rector\Naming\Contract\RenameValueObjectInterface;

interface ConflictingGuardInterface
interface ConflictingNameGuardInterface
{
public function check(RenameValueObjectInterface $renameValueObject): bool;
public function isConflicting(RenameValueObjectInterface $renameValueObject): bool;
}
16 changes: 0 additions & 16 deletions rules/naming/src/Contract/RenameGuard/RenameGuardInterface.php

This file was deleted.

12 changes: 0 additions & 12 deletions rules/naming/src/Contract/RenamerInterface.php

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8c3443b

Please sign in to comment.