mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 00:40:52 +00:00
misc
This commit is contained in:
parent
a542a49e48
commit
34bdfa0d9d
|
@ -38,6 +38,7 @@ final class DeprecationCollector
|
|||
* @var MessageToDeprecationTransformer
|
||||
*/
|
||||
private $messageToDeprecationTransformer;
|
||||
|
||||
/**
|
||||
* @var ArgumentToDeprecationTransformer
|
||||
*/
|
||||
|
@ -93,6 +94,7 @@ final class DeprecationCollector
|
|||
if (! $this->areDeprecationsTransformed) {
|
||||
$this->transformDeprecations();
|
||||
}
|
||||
|
||||
$this->areDeprecationsTransformed = true;
|
||||
|
||||
return $this->deprecations;
|
||||
|
|
|
@ -4,4 +4,20 @@ namespace Rector\DeprecationExtractor\RegExp;
|
|||
|
||||
final class ClassAndMethodMatcher
|
||||
{
|
||||
}
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const CLASS_WITH_METHOD_PATTERN = '#^(?<classMethod>[A-Za-z]+[\\\\A-Za-z]+::[A-Za-z]+\([A-Za-z\']*\))#s';
|
||||
|
||||
public function matchLocalMethod(string $content): ?string
|
||||
{
|
||||
dump($content);
|
||||
die;
|
||||
}
|
||||
|
||||
public function matchClassWithMethod(string $content): ?string
|
||||
{
|
||||
dump($content);
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,14 +8,24 @@ use PhpParser\Node\Arg;
|
|||
use PhpParser\Node\Expr\BinaryOp\Concat;
|
||||
use PhpParser\Node\Scalar\MagicConst\Method;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use Rector\DeprecationExtractor\Contract\Deprecation\DeprecationInterface;
|
||||
use Rector\DeprecationExtractor\Deprecation\ClassMethodDeprecation;
|
||||
use Rector\DeprecationExtractor\RegExp\ClassAndMethodMatcher;
|
||||
use Rector\Exception\NotImplementedException;
|
||||
use Rector\Node\Attribute;
|
||||
|
||||
final class ArgumentToDeprecationTransformer
|
||||
{
|
||||
/**
|
||||
* @var ClassAndMethodMatcher
|
||||
*/
|
||||
private $classAndMethodMatcher;
|
||||
|
||||
public function __construct(ClassAndMethodMatcher $classAndMethodMatcher)
|
||||
{
|
||||
$this->classAndMethodMatcher = $classAndMethodMatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Probably resolve by recursion, similar too
|
||||
* @see \Rector\NodeTypeResolver\NodeVisitor\TypeResolver::__construct()
|
||||
|
@ -65,7 +75,7 @@ final class ArgumentToDeprecationTransformer
|
|||
private function processConcatNode(Node $node): string
|
||||
{
|
||||
if ($node instanceof Method) {
|
||||
$classMethodNode = $this->findParentOfType($node, ClassMethod::class);
|
||||
$classMethodNode = $node->getAttribute(Attribute::SCOPE_NODE);
|
||||
|
||||
return $node->getAttribute(Attribute::CLASS_NAME) . '::' . $classMethodNode->name->name;
|
||||
}
|
||||
|
@ -82,17 +92,6 @@ final class ArgumentToDeprecationTransformer
|
|||
));
|
||||
}
|
||||
|
||||
private function findParentOfType(Node $node, string $type): Node
|
||||
{
|
||||
$parentNode = $node->getAttribute(Attribute::PARENT_NODE);
|
||||
|
||||
while (! is_a($parentNode, $type, true)) {
|
||||
$parentNode = $parentNode->getAttribute(Attribute::PARENT_NODE);
|
||||
}
|
||||
|
||||
return $parentNode;
|
||||
}
|
||||
|
||||
private function completeClassToLocalMethods(string $message, string $class): string
|
||||
{
|
||||
$completeMessage = '';
|
||||
|
|
|
@ -25,7 +25,7 @@ final class DeprecationExtractorTest extends AbstractContainerAwareTestCase
|
|||
public function testDeprectaionMessages(): void
|
||||
{
|
||||
$deprecationMessages = $this->deprecationCollector->getDeprecationMessages();
|
||||
$this->assertCount(0 , $deprecationMessages);
|
||||
$this->assertCount(0, $deprecationMessages);
|
||||
}
|
||||
|
||||
public function testDeprecationNodes(): void
|
||||
|
|
Loading…
Reference in New Issue
Block a user