This commit is contained in:
TomasVotruba 2017-08-08 01:18:55 +02:00
parent 604d4cb521
commit 4d931010d0
5 changed files with 20 additions and 23 deletions

View File

@ -11,7 +11,7 @@ use Rector\Contract\Rector\RectorInterface;
abstract class AbstractRector extends NodeVisitorAbstract implements DeprecationInterface, RectorInterface
{
/**
* @return int|null|Node
* @return null|int|Node
*/
public function enterNode(Node $node)
{

View File

@ -33,7 +33,7 @@ final class FormCallbackRector extends NodeVisitorAbstract implements Deprecatio
}
/**
* @return int|null|Node
* @return null|int|Node
*/
public function enterNode(Node $node)
{
@ -42,16 +42,7 @@ final class FormCallbackRector extends NodeVisitorAbstract implements Deprecatio
return null;
}
return new Array_([
new ArrayItem($node->var),
new ArrayItem(
new String_(
(string) $node->name
)
)
], [
'kind' => Array_::KIND_SHORT
]);
return $this->createShortArray($node);
}
$this->previousNode = $node;
@ -80,4 +71,18 @@ final class FormCallbackRector extends NodeVisitorAbstract implements Deprecatio
return true;
}
private function createShortArray(Node $node): Array_
{
return new Array_([
new ArrayItem($node->var),
new ArrayItem(
new String_(
(string) $node->name
)
)
], [
'kind' => Array_::KIND_SHORT
]);
}
}

View File

@ -4,9 +4,9 @@ namespace Rector\Rector\Contrib\Nette;
use PhpParser\Node;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Scalar\String_;
use Rector\Deprecation\SetNames;
use Rector\Rector\AbstractRector;
use PhpParser\Node\Scalar\String_;
final class RemoveConfiguratorConstantsRector extends AbstractRector
{

View File

@ -5,7 +5,6 @@ namespace Rector\Testing\Application;
use PhpParser\Lexer;
use PhpParser\NodeTraverser;
use PhpParser\Parser;
use Rector\NodeTraverser\StateHolder;
use Rector\Printer\FormatPerservingPrinter;
use SplFileInfo;
@ -31,23 +30,16 @@ final class FileReconstructor
*/
private $nodeTraverser;
/**
* @var StateHolder
*/
private $stateHolder;
public function __construct(
Parser $parser,
FormatPerservingPrinter $codeStyledPrinter,
Lexer $lexer,
NodeTraverser $nodeTraverser,
StateHolder $stateHolder
NodeTraverser $nodeTraverser
) {
$this->parser = $parser;
$this->codeStyledPrinter = $codeStyledPrinter;
$this->lexer = $lexer;
$this->nodeTraverser = $nodeTraverser;
$this->stateHolder = $stateHolder;
}
// ref: https://github.com/nikic/PHP-Parser/issues/344#issuecomment-298162516

View File

@ -12,7 +12,7 @@ final class Test extends AbstractReconstructorTestCase
__DIR__ . '/wrong/wrong.php.inc',
__DIR__ . '/correct/correct.php.inc'
);
// $this->doTestFileMatchesExpectedContent(
// $this->doTestFileMatchesExpectedContent(
// __DIR__ . '/wrong/wrong2.php.inc',
// __DIR__ . '/correct/correct2.php.inc'
// );