mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 00:40:52 +00:00
40 lines
869 B
PHP
40 lines
869 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace Rector\Analyzer;
|
|
|
|
use Nette\Utils\Strings;
|
|
use PhpParser\Node;
|
|
use PhpParser\Node\Name;
|
|
use PhpParser\Node\Stmt\Class_;
|
|
|
|
final class ClassAnalyzer
|
|
{
|
|
public function isControllerClassNode(Node $node): bool
|
|
{
|
|
if (! $node instanceof Class_) {
|
|
return false;
|
|
}
|
|
|
|
if ($node->extends instanceof Name) {
|
|
return Strings::endsWith($node->extends->getLast(), 'Controller');
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public function isContainerAwareClassNode(Node $node): bool
|
|
{
|
|
if (! $node instanceof Class_) {
|
|
return false;
|
|
}
|
|
|
|
foreach ($node->implements as $nameNode) {
|
|
if (Strings::endsWith($nameNode->getLast(), 'ContainerAwareInterface')) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|