This commit is contained in:
TomasVotruba 2017-09-11 16:29:29 +02:00
parent a542a49e48
commit 34bdfa0d9d
4 changed files with 32 additions and 15 deletions

View File

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

View File

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

View File

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

View File

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