mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-05 19:00:49 +00:00
rename TriggerExtractor to DeprecationExtractor
This commit is contained in:
parent
b808383aca
commit
c54ec26137
|
@ -25,14 +25,14 @@
|
|||
"psr-4": {
|
||||
"Rector\\": "src",
|
||||
"Rector\\NodeTypeResolver\\": "packages/NodeTypeResolver/src",
|
||||
"Rector\\TriggerExtractor\\": "packages/TriggerExtractor/src"
|
||||
"Rector\\DeprecationExtractor\\": "packages/DeprecationExtractor/src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Rector\\Tests\\": "tests",
|
||||
"Rector\\NodeTypeResolver\\Tests\\": "packages/NodeTypeResolver/tests",
|
||||
"Rector\\TriggerExtractor\\Tests\\": "packages/TriggerExtractor/tests"
|
||||
"Rector\\DeprecationExtractor\\Tests\\": "packages/DeprecationExtractor/tests"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
@ -49,4 +49,4 @@ parameters:
|
|||
- src/Rector/Contrib/Symfony/FrameworkBundleClassReplacementsRector.php
|
||||
Symplify\CodingStandard\Sniffs\Classes\EqualInterfaceImplementationSniff:
|
||||
# empty parent interface, disable for now
|
||||
- packages/TriggerExtractor/src/Deprecation/ClassMethodDeprecation.php
|
||||
- packages/DeprecationExtractor/src/Deprecation/ClassMethodDeprecation.php
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
# Trigger Extractor
|
||||
# Deprecation Extractor
|
||||
|
||||
This package extracts `trigger_error(*, E_USER_DEPRECATED)` from the code.
|
||||
This package extracts 2 cases:
|
||||
|
||||
- `@deprecate` annotation
|
||||
- `trigger_error(*, E_USER_DEPRECATED)` from the code.
|
||||
|
||||
It helps to generated automate rectors.
|
||||
It helps to generated automate rectors and identify BC changes purely from the code.
|
||||
|
||||
|
||||
## How it works?
|
||||
|
@ -22,4 +25,4 @@ vendor/bin/rector extract-deprecations vendor/nette
|
|||
|
||||
It will show you what changed and how.
|
||||
|
||||
Moreover, it will change the code for you.
|
||||
Moreover, it will change the code for you.
|
|
@ -1,8 +1,8 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\TriggerExtractor\Console\Command;
|
||||
namespace Rector\DeprecationExtractor\Console\Command;
|
||||
|
||||
use Rector\TriggerExtractor\TriggerExtractor;
|
||||
use Rector\DeprecationExtractor\DeprecationExtractor;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
@ -21,13 +21,13 @@ final class ExtractCommand extends Command
|
|||
private const ARGUMENT_SOURCE_NAME = 'source';
|
||||
|
||||
/**
|
||||
* @var TriggerExtractor
|
||||
* @var DeprecationExtractor
|
||||
*/
|
||||
private $triggerExtractor;
|
||||
private $DeprecationExtractor;
|
||||
|
||||
public function __construct(TriggerExtractor $triggerExtractor)
|
||||
public function __construct(DeprecationExtractor $DeprecationExtractor)
|
||||
{
|
||||
$this->triggerExtractor = $triggerExtractor;
|
||||
$this->DeprecationExtractor = $DeprecationExtractor;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ final class ExtractCommand extends Command
|
|||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$source = $input->getArgument(self::ARGUMENT_SOURCE_NAME);
|
||||
$this->triggerExtractor->scanDirectories($source);
|
||||
$this->DeprecationExtractor->scanDirectories($source);
|
||||
|
||||
// write found deprecations...
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\TriggerExtractor\Contract\Deprecation;
|
||||
namespace Rector\DeprecationExtractor\Contract\Deprecation;
|
||||
|
||||
interface DeprecationInterface
|
||||
{
|
|
@ -1,8 +1,8 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\TriggerExtractor\Deprecation;
|
||||
namespace Rector\DeprecationExtractor\Deprecation;
|
||||
|
||||
use Rector\TriggerExtractor\Contract\Deprecation\DeprecationInterface;
|
||||
use Rector\DeprecationExtractor\Contract\Deprecation\DeprecationInterface;
|
||||
|
||||
final class ClassMethodDeprecation implements DeprecationInterface
|
||||
{
|
|
@ -1,8 +1,8 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\TriggerExtractor\Deprecation;
|
||||
namespace Rector\DeprecationExtractor\Deprecation;
|
||||
|
||||
use Rector\TriggerExtractor\Contract\Deprecation\DeprecationInterface;
|
||||
use Rector\DeprecationExtractor\Contract\Deprecation\DeprecationInterface;
|
||||
|
||||
final class DeprecationCollector
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\TriggerExtractor\Deprecation;
|
||||
namespace Rector\DeprecationExtractor\Deprecation;
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
|
@ -10,7 +10,7 @@ use PhpParser\Node\Scalar\String_;
|
|||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use Rector\Exception\NotImplementedException;
|
||||
use Rector\Node\Attribute;
|
||||
use Rector\TriggerExtractor\Contract\Deprecation\DeprecationInterface;
|
||||
use Rector\DeprecationExtractor\Contract\Deprecation\DeprecationInterface;
|
||||
|
||||
final class DeprecationFactory
|
||||
{
|
|
@ -1,15 +1,15 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\TriggerExtractor;
|
||||
namespace Rector\DeprecationExtractor;
|
||||
|
||||
use Rector\Contract\Parser\ParserInterface;
|
||||
use Rector\NodeTraverser\MainNodeTraverser;
|
||||
use Rector\NodeTraverser\StandaloneTraverseNodeTraverser;
|
||||
use Rector\TriggerExtractor\NodeVisitor\DeprecationDetector;
|
||||
use Rector\DeprecationExtractor\NodeVisitor\DeprecationDetector;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\Finder\SplFileInfo;
|
||||
|
||||
final class TriggerExtractor
|
||||
final class DeprecationExtractor
|
||||
{
|
||||
/**
|
||||
* @var ParserInterface
|
|
@ -4,7 +4,7 @@
|
|||
* @todo rename to deprecation extractor
|
||||
*/
|
||||
|
||||
namespace Rector\TriggerExtractor\NodeVisitor;
|
||||
namespace Rector\DeprecationExtractor\NodeVisitor;
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
|
@ -16,8 +16,8 @@ use PhpParser\NodeVisitorAbstract;
|
|||
use PhpParser\PrettyPrinter\Standard;
|
||||
use Rector\Node\Attribute;
|
||||
use Rector\NodeAnalyzer\DocBlockAnalyzer;
|
||||
use Rector\TriggerExtractor\Deprecation\DeprecationCollector;
|
||||
use Rector\TriggerExtractor\Deprecation\DeprecationFactory;
|
||||
use Rector\DeprecationExtractor\Deprecation\DeprecationCollector;
|
||||
use Rector\DeprecationExtractor\Deprecation\DeprecationFactory;
|
||||
|
||||
/**
|
||||
* Inspired by https://github.com/sensiolabs-de/deprecation-detector/blob/master/src/Visitor/Deprecation/FindDeprecatedTagsVisitor.php
|
||||
|
@ -103,11 +103,11 @@ final class DeprecationDetector extends NodeVisitorAbstract
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This detects inside call of: "trigger_error(<some-content>, E_USER_DEPREDCATED)";
|
||||
*/
|
||||
private function hasTriggerErrorUserDeprecated(Node $node): bool
|
||||
{
|
||||
return Strings::contains($this->prettyPrinter->prettyPrint([$node]), 'E_USER_DEPRECATED');
|
||||
return Strings::contains(
|
||||
$this->prettyPrinter->prettyPrint([$node]),
|
||||
'E_USER_DEPRECATED'
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\TriggerExtractor\Rector;
|
||||
namespace Rector\DeprecationExtractor\Rector;
|
||||
|
||||
use Rector\Rector\AbstractChangeMethodNameRector;
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\TriggerExtractor\Rector;
|
||||
namespace Rector\DeprecationExtractor\Rector;
|
||||
|
||||
use Rector\Contract\Rector\RectorInterface;
|
||||
use Rector\Exception\NotImplementedException;
|
||||
use Rector\TriggerExtractor\Contract\Deprecation\DeprecationInterface;
|
||||
use Rector\TriggerExtractor\Deprecation\ClassMethodDeprecation;
|
||||
use Rector\TriggerExtractor\Deprecation\DeprecationCollector;
|
||||
use Rector\DeprecationExtractor\Contract\Deprecation\DeprecationInterface;
|
||||
use Rector\DeprecationExtractor\Deprecation\ClassMethodDeprecation;
|
||||
use Rector\DeprecationExtractor\Deprecation\DeprecationCollector;
|
||||
|
||||
/**
|
||||
* Creates rectors with propper setup based on found deprecations.
|
|
@ -3,6 +3,6 @@ services:
|
|||
autowire: true
|
||||
|
||||
# PSR-4 autodiscovery
|
||||
Rector\TriggerExtractor\:
|
||||
Rector\DeprecationExtractor\:
|
||||
resource: '../../src'
|
||||
exclude: '../../src/{Deprecation/ClassMethodDeprecation.php}'
|
|
@ -1,12 +1,12 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\TriggerExtractor\Tests\Rector;
|
||||
namespace Rector\DeprecationExtractor\Tests\Rector;
|
||||
|
||||
use PHPUnit\Framework\Assert;
|
||||
use Rector\Tests\AbstractContainerAwareTestCase;
|
||||
use Rector\TriggerExtractor\Rector\ConfigurableChangeMethodNameRector;
|
||||
use Rector\TriggerExtractor\Rector\RectorFactory;
|
||||
use Rector\TriggerExtractor\TriggerExtractor;
|
||||
use Rector\DeprecationExtractor\Rector\ConfigurableChangeMethodNameRector;
|
||||
use Rector\DeprecationExtractor\Rector\RectorFactory;
|
||||
use Rector\DeprecationExtractor\DeprecationExtractor;
|
||||
|
||||
final class RectorFactoryTest extends AbstractContainerAwareTestCase
|
||||
{
|
||||
|
@ -19,8 +19,8 @@ final class RectorFactoryTest extends AbstractContainerAwareTestCase
|
|||
{
|
||||
$this->rectorFactory = $this->container->get(RectorFactory::class);
|
||||
|
||||
$triggerExtractor = $this->container->get(TriggerExtractor::class);
|
||||
$triggerExtractor->scanDirectories([__DIR__ . '/../TriggerExtractorSource']);
|
||||
$DeprecationExtractor = $this->container->get(DeprecationExtractor::class);
|
||||
$DeprecationExtractor->scanDirectories([__DIR__ . '/../DeprecationExtractorSource']);
|
||||
}
|
||||
|
||||
public function test(): void
|
|
@ -1,17 +1,17 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\TriggerExtractor\Tests;
|
||||
namespace Rector\DeprecationExtractor\Tests;
|
||||
|
||||
use Rector\Tests\AbstractContainerAwareTestCase;
|
||||
use Rector\TriggerExtractor\Deprecation\DeprecationCollector;
|
||||
use Rector\TriggerExtractor\TriggerExtractor;
|
||||
use Rector\DeprecationExtractor\Deprecation\DeprecationCollector;
|
||||
use Rector\DeprecationExtractor\DeprecationExtractor;
|
||||
|
||||
final class TriggerExtractorTest extends AbstractContainerAwareTestCase
|
||||
final class DeprecationExtractorTest extends AbstractContainerAwareTestCase
|
||||
{
|
||||
/**
|
||||
* @var TriggerExtractor
|
||||
* @var DeprecationExtractor
|
||||
*/
|
||||
private $triggerExtractor;
|
||||
private $DeprecationExtractor;
|
||||
|
||||
/**
|
||||
* @var DeprecationCollector
|
||||
|
@ -20,13 +20,13 @@ final class TriggerExtractorTest extends AbstractContainerAwareTestCase
|
|||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->triggerExtractor = $this->container->get(TriggerExtractor::class);
|
||||
$this->DeprecationExtractor = $this->container->get(DeprecationExtractor::class);
|
||||
$this->deprecationCollector = $this->container->get(DeprecationCollector::class);
|
||||
}
|
||||
|
||||
public function test(): void
|
||||
{
|
||||
$this->triggerExtractor->scanDirectories([__DIR__ . '/TriggerExtractorSource']);
|
||||
$this->DeprecationExtractor->scanDirectories([__DIR__ . '/DeprecationExtractorSource']);
|
||||
$deprecations = $this->deprecationCollector->getDeprecations();
|
||||
|
||||
$this->assertCount(2, $deprecations);
|
|
@ -5,4 +5,4 @@ parameters:
|
|||
- '#Undefined variable: \$container#'
|
||||
- '#Undefined variable: \$application#'
|
||||
excludes_analyse:
|
||||
- *packages/TriggerExtractor/tests/TriggerExtractorSource/Definition.php
|
||||
- *packages/DeprecationExtractor/tests/DeprecationExtractorSource/Definition.php
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
imports:
|
||||
- { resource: '../../packages/TriggerExtractor/src/config/services.yml' }
|
||||
- { resource: '../../packages/DeprecationExtractor/src/config/services.yml' }
|
||||
|
||||
parameters:
|
||||
name: "Rector"
|
||||
|
|
Loading…
Reference in New Issue
Block a user