Skip to content

Commit

Permalink
misc (#5439)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba authored Feb 6, 2021
1 parent d402f52 commit 0c830ab
Show file tree
Hide file tree
Showing 19 changed files with 63 additions and 82 deletions.
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
"Rector\\Symfony4\\": "rules/symfony4/src",
"Rector\\Symfony5\\": "rules/symfony5/src",
"Rector\\Transform\\": "rules/transform/src",
"Rector\\Twig\\": "rules/twig/src",
"Rector\\TypeDeclaration\\": "rules/type-declaration/src",
"Rector\\VendorLocker\\": "packages/vendor-locker/src",
"Rector\\Carbon\\": "rules/carbon/src",
Expand Down Expand Up @@ -290,7 +289,6 @@
"Rector\\Symfony4\\Tests\\": "rules/symfony4/tests",
"Rector\\Symfony5\\Tests\\": "rules/symfony5/tests",
"Rector\\Transform\\Tests\\": "rules/transform/tests",
"Rector\\Twig\\Tests\\": "rules/twig/tests",
"Rector\\TypeDeclaration\\Tests\\": "rules/type-declaration/tests",
"Rector\\Utils\\DoctrineAnnotationParserSyncer\\": "utils/doctrine-annotation-parser-syncer/src",
"Rector\\Utils\\NodeDocumentationGenerator\\": "utils/node-documentation-generator/src",
Expand Down
2 changes: 1 addition & 1 deletion config/set/twig134.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

use Rector\Twig\Rector\Return_\SimpleFunctionAndFilterRector;
use Rector\Symfony\Rector\Return_\SimpleFunctionAndFilterRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
Expand Down
2 changes: 1 addition & 1 deletion docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -16550,7 +16550,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {

Changes Twig_Function_Method to Twig_SimpleFunction calls in Twig_Extension.

- class: `Rector\Twig\Rector\Return_\SimpleFunctionAndFilterRector`
- class: `Rector\Symfony\Rector\Return_\SimpleFunctionAndFilterRector`

```diff
class SomeExtension extends Twig_Extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use PhpParser\Node;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Property;
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
Expand All @@ -19,7 +18,6 @@
use Rector\DoctrineCodeQuality\PhpDoc\CollectionTypeFactory;
use Rector\DoctrineCodeQuality\PhpDoc\CollectionTypeResolver;
use Rector\DoctrineCodeQuality\PhpDoc\CollectionVarTagValueNodeResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
Expand Down Expand Up @@ -212,7 +210,7 @@ private function resolveCollectionSetterAssignType(ClassMethod $classMethod): ?T
return null;
}

$property = $this->matchPropertyFetchToClassProperty($propertyFetches[0]);
$property = $this->nodeRepository->findPropertyByPropertyFetch($propertyFetches[0]);
if (! $property instanceof Property) {
return null;
}
Expand All @@ -224,19 +222,4 @@ private function resolveCollectionSetterAssignType(ClassMethod $classMethod): ?T

return $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($varTagValueNode->type, $property);
}

private function matchPropertyFetchToClassProperty(PropertyFetch $propertyFetch): ?Property
{
$propertyName = $this->getName($propertyFetch);
if ($propertyName === null) {
return null;
}

$classLike = $propertyFetch->getAttribute(AttributeKey::CLASS_NODE);
if (! $classLike instanceof Class_) {
return null;
}

return $classLike->getProperty($propertyName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Rector\Twig\Rector\Return_;
namespace Rector\Symfony\Rector\Return_;

use PhpParser\Node;
use PhpParser\Node\Arg;
Expand All @@ -23,7 +23,7 @@
/**
* Covers https://twig.symfony.com/doc/1.x/deprecated.html#function
*
* @see \Rector\Twig\Tests\Rector\Return_\SimpleFunctionAndFilterRector\SimpleFunctionAndFilterRectorTest
* @see \Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\SimpleFunctionAndFilterRectorTest
*/
final class SimpleFunctionAndFilterRector extends AbstractRector
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Twig\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Fixture;
namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Fixture;

final class SomeExtension extends \Twig_Extension
{
Expand All @@ -16,7 +16,7 @@ final class SomeExtension extends \Twig_Extension
-----
<?php

namespace Rector\Twig\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Fixture;
namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Fixture;

final class SomeExtension extends \Twig_Extension
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Twig\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Fixture;
namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Fixture;

use Twig_Extension;
use Twig_Filter_Method;
Expand All @@ -19,7 +19,7 @@ final class SomeExtension2 extends Twig_Extension
-----
<?php

namespace Rector\Twig\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Fixture;
namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Fixture;

use Twig_Extension;
use Twig_Filter_Method;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\Twig\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Fixture;
namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Fixture;

use Twig_Extension;
use Twig_Filter_Method;
Expand All @@ -19,7 +19,7 @@ final class SomeExtension3 extends Twig_Extension
-----
<?php

namespace Rector\Twig\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Fixture;
namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Fixture;

use Twig_Extension;
use Twig_Filter_Method;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

declare(strict_types=1);

namespace Rector\Twig\Tests\Rector\Return_\SimpleFunctionAndFilterRector;
namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector;

use Iterator;
use Rector\Symfony\Rector\Return_\SimpleFunctionAndFilterRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Rector\Twig\Rector\Return_\SimpleFunctionAndFilterRector;
use Symplify\SmartFileSystem\SmartFileInfo;

final class SimpleFunctionAndFilterRectorTest extends AbstractRectorTestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;

abstract class Twig_Extension
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;

final class TwigFilterMethod
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;

final class TwigFunctionMethod
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;

final class TwigSimpleFilter
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;

final class TwigSimpleFunction
{

}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 0c830ab

Please sign in to comment.