This commit is contained in:
Tomas Votruba 2021-02-06 23:20:57 +01:00 committed by GitHub
parent d402f52238
commit 0c830ab123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 63 additions and 82 deletions

View File

@ -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",
@ -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",

View File

@ -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 {

View File

@ -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

View File

@ -6,7 +6,6 @@ namespace Rector\DoctrineCodeQuality\Rector\Property;
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;
@ -19,7 +18,6 @@ use Rector\Doctrine\PhpDocParser\DoctrineDocBlockResolver;
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;
@ -212,7 +210,7 @@ CODE_SAMPLE
return null;
}
$property = $this->matchPropertyFetchToClassProperty($propertyFetches[0]);
$property = $this->nodeRepository->findPropertyByPropertyFetch($propertyFetches[0]);
if (! $property instanceof Property) {
return null;
}
@ -224,19 +222,4 @@ CODE_SAMPLE
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);
}
}

View File

@ -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;
@ -23,7 +23,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* 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
{

View File

@ -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
{
@ -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
{

View File

@ -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;
@ -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;

View File

@ -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;
@ -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;

View File

@ -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

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;
abstract class Twig_Extension
{
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;
final class TwigFilterMethod
{
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;
final class TwigFunctionMethod
{
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;
final class TwigSimpleFilter
{
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Rector\Symfony\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;
final class TwigSimpleFunction
{
}

View File

@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Twig\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;
abstract class Twig_Extension
{
}

View File

@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Twig\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;
final class TwigFilterMethod
{
}

View File

@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Twig\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;
final class TwigFunctionMethod
{
}

View File

@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Twig\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;
final class TwigSimpleFilter
{
}

View File

@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Twig\Tests\Rector\Return_\SimpleFunctionAndFilterRector\Source;
final class TwigSimpleFunction
{
}