remove comments

This commit is contained in:
TomasVotruba 2017-11-01 22:37:57 +01:00
parent d2ae52e417
commit 452e6748fa
5 changed files with 50 additions and 18 deletions

View File

@ -76,4 +76,12 @@ final class BetterNodeFinder
{
return $this->nodeFinder->find($nodes, $filter);
}
/**
* @param Node|Node[] $nodes
*/
public function findFirst($nodes, callable $filter): ?Node
{
return $this->nodeFinder->findFirst($nodes, $filter);
}
}

View File

@ -70,12 +70,24 @@ final class CallerTypeResolver extends NodeVisitorAbstract
private function processMethodCallNode(MethodCall $methodCallNode): void
{
$node = $this->betterNodeFinder->findFirstInstanceOfAny(
$callerNode = $this->betterNodeFinder->findFirst(
$methodCallNode,
[Variable::class, PropertyFetch::class]
function (Node $node) use ($methodCallNode) {
if ($node instanceof Variable || $node instanceof PropertyFetch /* || $node instanceof MethodCall*/) {
return $node;
}
if ($node === $methodCallNode) {
return null;
}
}
);
$nodeTypes = (array) $node->getAttribute(Attribute::TYPES);
if ($callerNode === null) {
return;
}
$nodeTypes = (array) $callerNode->getAttribute(Attribute::TYPES);
if ($nodeTypes) {
$methodCallNode->setAttribute(Attribute::CALLER_TYPES, $nodeTypes);
}

View File

@ -2,8 +2,14 @@
class SomeNetteExtension extends Nette\DI\CompilerExtension
{
/**
* @var SomeBuilder
*/
private $builder;
public function loadConfiguration()
{
$builder = new SomeBuilder;
$builder->parameters['appDir'];
$this->builder->parameters['appDir'];
$this->getContainerBuilder()->parameters['appDir'];

View File

@ -2,8 +2,14 @@
class SomeNetteExtension extends Nette\DI\CompilerExtension
{
/**
* @var SomeBuilder
*/
private $builder;
public function loadConfiguration()
{
$builder = new SomeBuilder;
$builder->expand('%appDir%');
$this->builder->expand('%appDir%');
$this->getContainerBuilder()->expand('%appDir%');

View File

@ -9,25 +9,25 @@ final class Test extends AbstractConfigurableRectorTestCase
{
public function test(): void
{
// $this->doTestFileMatchesExpectedContent(
// __DIR__ . '/wrong/wrong.php.inc',
// __DIR__ . '/correct/correct.php.inc'
// );
//
// $this->doTestFileMatchesExpectedContent(
// __DIR__ . '/wrong/wrong2.php.inc',
// __DIR__ . '/correct/correct2.php.inc'
// );
//
$this->doTestFileMatchesExpectedContent(
__DIR__ . '/wrong/wrong.php.inc',
__DIR__ . '/correct/correct.php.inc'
);
$this->doTestFileMatchesExpectedContent(
__DIR__ . '/wrong/wrong2.php.inc',
__DIR__ . '/correct/correct2.php.inc'
);
$this->doTestFileMatchesExpectedContent(
__DIR__ . '/wrong/wrong3.php.inc',
__DIR__ . '/correct/correct3.php.inc'
);
//
// $this->doTestFileMatchesExpectedContent(
// __DIR__ . '/wrong/wrong4.php.inc',
// __DIR__ . '/correct/correct4.php.inc'
// );
$this->doTestFileMatchesExpectedContent(
__DIR__ . '/wrong/wrong4.php.inc',
__DIR__ . '/correct/correct4.php.inc'
);
}
protected function provideConfig(): string