mirror of
https://github.com/rectorphp/rector.git
synced 2024-07-30 21:30:23 +00:00
drop nette rules
This commit is contained in:
parent
d4edb5e18e
commit
3ccf1bcb56
@ -1,69 +0,0 @@
|
||||
services:
|
||||
Rector\Nette\Rector\Utils\NetteObjectToSmartTraitRector: ~
|
||||
Rector\Nette\Rector\Utils\MagicMethodRector: ~
|
||||
|
||||
# application
|
||||
Rector\Nette\Rector\Application\TemplateMagicInvokeFilterCallRector: ~
|
||||
Rector\Nette\Rector\Application\TemplateRegisterHelperRector: ~
|
||||
|
||||
# di
|
||||
Rector\Nette\Rector\DI\SetEntityToStatementRector: ~
|
||||
Rector\Nette\Rector\DI\ExpandFunctionToParametersArrayRector: ~
|
||||
Rector\Nette\Rector\DI\ExpandFunctionToStaticExpandFunctionRector: ~
|
||||
|
||||
# forms
|
||||
Rector\Nette\Rector\Forms\ChoiceDefaultValueRector: ~
|
||||
Rector\Nette\Rector\Forms\FormNegativeRulesRector: ~
|
||||
Rector\Nette\Rector\Forms\FormCallbackRector: ~
|
||||
|
||||
Rector\Rector\MagicDisclosure\GetAndSetToMethodCallRector:
|
||||
$typeToMethodCalls:
|
||||
# di
|
||||
'Nette\DI\Container':
|
||||
'get': 'getService'
|
||||
'set': 'setService'
|
||||
|
||||
Rector\Rector\MagicDisclosure\UnsetAndIssetToMethodCallRector:
|
||||
$typeToMethodCalls:
|
||||
# di
|
||||
'Nette\DI\Container':
|
||||
'isset': 'hasService'
|
||||
'unset': 'removeService'
|
||||
|
||||
Rector\Rector\Dynamic\MethodNameReplacerRector:
|
||||
$perClassOldToNewMethods:
|
||||
# application
|
||||
'Nette\Application\UI\Control':
|
||||
'invalidateControl': 'redrawControl'
|
||||
|
||||
# di
|
||||
'Nette\DI\ServiceDefinition':
|
||||
'setImplementType': 'setImplementMode'
|
||||
'getImplementType': 'getImplementMode'
|
||||
|
||||
# forms
|
||||
'Nette\Bridges\FormsLatte\FormMacros':
|
||||
'renderFormBegin': ['Nette\Bridges\FormsLatte\Runtime', 'renderFormBegin']
|
||||
'renderFormEnd': ['Nette\Bridges\FormsLatte\Runtime', 'renderFormEnd']
|
||||
|
||||
# php-generator
|
||||
'Nette\PhpGenerator\ClassType':
|
||||
'addDocument': 'addComment'
|
||||
'setDocuments': 'setComment'
|
||||
'getDocuments': 'getComment'
|
||||
'Nette\PhpGenerator\Method':
|
||||
'addDocument': 'addComment'
|
||||
'setDocuments': 'setComment'
|
||||
'getDocuments': 'getComment'
|
||||
'Nette\PhpGenerator\PhpFile':
|
||||
'addDocument': 'addComment'
|
||||
'setDocuments': 'setComment'
|
||||
'getDocuments': 'getComment'
|
||||
'Nette\PhpGenerator\Property':
|
||||
'addDocument': 'addComment'
|
||||
'setDocuments': 'setComment'
|
||||
'getDocuments': 'getComment'
|
||||
|
||||
# utils
|
||||
'Nette\Utils\Html':
|
||||
'add': 'addHtml'
|
@ -1,99 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Nette\Rector\Application;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use Rector\Builder\IdentifierRenamer;
|
||||
use Rector\Node\Attribute;
|
||||
use Rector\Node\MethodCallNodeFactory;
|
||||
use Rector\Node\NodeFactory;
|
||||
use Rector\NodeAnalyzer\MethodCallAnalyzer;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\RectorDefinition\CodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
|
||||
final class TemplateMagicInvokeFilterCallRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var MethodCallAnalyzer
|
||||
*/
|
||||
private $methodCallAnalyzer;
|
||||
|
||||
/**
|
||||
* @var IdentifierRenamer
|
||||
*/
|
||||
private $identifierRenamer;
|
||||
|
||||
/**
|
||||
* @var NodeFactory
|
||||
*/
|
||||
private $nodeFactory;
|
||||
|
||||
/**
|
||||
* @var MethodCallNodeFactory
|
||||
*/
|
||||
private $methodCallNodeFactory;
|
||||
|
||||
public function __construct(
|
||||
MethodCallAnalyzer $methodCallAnalyzer,
|
||||
IdentifierRenamer $identifierRenamer,
|
||||
NodeFactory $nodeFactory,
|
||||
MethodCallNodeFactory $methodCallNodeFactory
|
||||
) {
|
||||
$this->methodCallAnalyzer = $methodCallAnalyzer;
|
||||
$this->identifierRenamer = $identifierRenamer;
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
$this->methodCallNodeFactory = $methodCallNodeFactory;
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition('Turns properties with @inject to private properties and constructor injection', [
|
||||
new CodeSample(
|
||||
'$this->template->someFilter(...)',
|
||||
'$this->template->getLatte()->invokeFilter("someFilter", ...)'
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
public function isCandidate(Node $node): bool
|
||||
{
|
||||
// skip just added calls
|
||||
if ($node->getAttribute(Attribute::ORIGINAL_NODE) === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->methodCallAnalyzer->isTypeAndMagic($node, 'Nette\Bridges\ApplicationLatte\Template');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MethodCall $methodCallNode
|
||||
*/
|
||||
public function refactor(Node $methodCallNode): Node
|
||||
{
|
||||
$this->changeToInvokeFilterMethodCall($methodCallNode);
|
||||
|
||||
$methodCallNode->var = $this->methodCallNodeFactory->createWithVariableAndMethodName(
|
||||
$methodCallNode->var,
|
||||
'getLatte'
|
||||
);
|
||||
|
||||
return $methodCallNode;
|
||||
}
|
||||
|
||||
private function changeToInvokeFilterMethodCall(MethodCall $methodCallNode): void
|
||||
{
|
||||
/** @var Identifier $identifierNode */
|
||||
$identifierNode = $methodCallNode->name;
|
||||
|
||||
$filterName = $identifierNode->toString();
|
||||
$filterArguments = $methodCallNode->args;
|
||||
|
||||
$this->identifierRenamer->renameNode($methodCallNode, 'invokeFilter');
|
||||
|
||||
$methodCallNode->args[0] = $this->nodeFactory->createArg($filterName);
|
||||
$methodCallNode->args = array_merge($methodCallNode->args, $filterArguments);
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Nette\Rector\Application;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use Rector\Builder\IdentifierRenamer;
|
||||
use Rector\Node\MethodCallNodeFactory;
|
||||
use Rector\NodeAnalyzer\MethodCallAnalyzer;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\RectorDefinition\CodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
|
||||
final class TemplateRegisterHelperRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var MethodCallAnalyzer
|
||||
*/
|
||||
private $methodCallAnalyzer;
|
||||
|
||||
/**
|
||||
* @var IdentifierRenamer
|
||||
*/
|
||||
private $identifierRenamer;
|
||||
|
||||
/**
|
||||
* @var MethodCallNodeFactory
|
||||
*/
|
||||
private $methodCallNodeFactory;
|
||||
|
||||
public function __construct(
|
||||
MethodCallAnalyzer $methodCallAnalyzer,
|
||||
IdentifierRenamer $identifierRenamer,
|
||||
MethodCallNodeFactory $methodCallNodeFactory
|
||||
) {
|
||||
$this->methodCallAnalyzer = $methodCallAnalyzer;
|
||||
$this->identifierRenamer = $identifierRenamer;
|
||||
$this->methodCallNodeFactory = $methodCallNodeFactory;
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition('Turns properties with @inject to private properties and constructor injection', [
|
||||
new CodeSample(
|
||||
'$this->template->registerHelper("someFilter", ...);',
|
||||
'$this->template->getLatte()->addFilter("someFilter", ...)'
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
public function isCandidate(Node $node): bool
|
||||
{
|
||||
return $this->methodCallAnalyzer->isTypeAndMethod(
|
||||
$node,
|
||||
'Nette\Bridges\ApplicationLatte\Template',
|
||||
'registerHelper'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MethodCall $methodCallNode
|
||||
*/
|
||||
public function refactor(Node $methodCallNode): Node
|
||||
{
|
||||
$this->identifierRenamer->renameNode($methodCallNode, 'addFilter');
|
||||
|
||||
$methodCallNode->var = $this->methodCallNodeFactory->createWithVariableAndMethodName(
|
||||
$methodCallNode->var,
|
||||
'getLatte'
|
||||
);
|
||||
|
||||
return $methodCallNode;
|
||||
}
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Nette\Rector\DI;
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use Rector\Node\Attribute;
|
||||
use Rector\Node\NodeFactory;
|
||||
use Rector\NodeAnalyzer\MethodArgumentAnalyzer;
|
||||
use Rector\NodeAnalyzer\MethodCallAnalyzer;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\RectorDefinition\CodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
|
||||
/**
|
||||
* Covers https://github.com/Kdyby/Doctrine/pull/298/files
|
||||
*/
|
||||
final class ExpandFunctionToParametersArrayRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var MethodCallAnalyzer
|
||||
*/
|
||||
private $methodCallAnalyzer;
|
||||
|
||||
/**
|
||||
* @var MethodArgumentAnalyzer
|
||||
*/
|
||||
private $methodArgumentAnalyzer;
|
||||
|
||||
/**
|
||||
* @var NodeFactory
|
||||
*/
|
||||
private $nodeFactory;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $compilerExtensionClass;
|
||||
|
||||
public function __construct(
|
||||
MethodCallAnalyzer $methodCallAnalyzer,
|
||||
MethodArgumentAnalyzer $methodArgumentAnalyzer,
|
||||
NodeFactory $nodeFactory,
|
||||
string $compilerExtensionClass = 'Nette\DI\CompilerExtension'
|
||||
) {
|
||||
$this->methodCallAnalyzer = $methodCallAnalyzer;
|
||||
$this->methodArgumentAnalyzer = $methodArgumentAnalyzer;
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
$this->compilerExtensionClass = $compilerExtensionClass;
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition('Turns expand() to parameters value in Nette\DI\CompilerExtension', [
|
||||
new CodeSample('$builder->expand("argument");', '$builder->parameters["argument"];'),
|
||||
new CodeSample('$builder->expand("%argument%");', '$builder->parameters["argument"];'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function isCandidate(Node $node): bool
|
||||
{
|
||||
$parentClassName = $node->getAttribute(Attribute::PARENT_CLASS_NAME);
|
||||
if ($parentClassName !== $this->compilerExtensionClass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $this->methodCallAnalyzer->isMethod($node, 'expand')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @var MethodCall $methodCallNode */
|
||||
$methodCallNode = $node;
|
||||
|
||||
return $this->methodArgumentAnalyzer->isMethodNthArgumentString($methodCallNode, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MethodCall $methodCallNode
|
||||
*
|
||||
* Returns $builder->parameters['argument']
|
||||
*/
|
||||
public function refactor(Node $methodCallNode): ?Node
|
||||
{
|
||||
/** @var String_ $argument */
|
||||
$argument = $methodCallNode->args[0]->value;
|
||||
$argument->value = Strings::trim($argument->value, '%');
|
||||
|
||||
return $this->nodeFactory->createVariablePropertyArrayFetch($methodCallNode->var, 'parameters', $argument);
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Nette\Rector\DI;
|
||||
|
||||
use PhpParser\BuilderFactory;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use Rector\Node\Attribute;
|
||||
use Rector\NodeAnalyzer\MethodArgumentAnalyzer;
|
||||
use Rector\NodeAnalyzer\MethodCallAnalyzer;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\RectorDefinition\CodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
|
||||
/**
|
||||
* Covers https://github.com/Kdyby/Doctrine/pull/298/files
|
||||
*/
|
||||
final class ExpandFunctionToStaticExpandFunctionRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var MethodCallAnalyzer
|
||||
*/
|
||||
private $methodCallAnalyzer;
|
||||
|
||||
/**
|
||||
* @var MethodArgumentAnalyzer
|
||||
*/
|
||||
private $methodArgumentAnalyzer;
|
||||
|
||||
/**
|
||||
* @var BuilderFactory
|
||||
*/
|
||||
private $builderFactory;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $compilerExtensionClass;
|
||||
|
||||
public function __construct(
|
||||
MethodCallAnalyzer $methodCallAnalyzer,
|
||||
MethodArgumentAnalyzer $methodArgumentAnalyzer,
|
||||
BuilderFactory $builderFactory,
|
||||
string $compilerExtensionClass = 'Nette\DI\CompilerExtension'
|
||||
) {
|
||||
$this->methodCallAnalyzer = $methodCallAnalyzer;
|
||||
$this->methodArgumentAnalyzer = $methodArgumentAnalyzer;
|
||||
$this->builderFactory = $builderFactory;
|
||||
$this->compilerExtensionClass = $compilerExtensionClass;
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition(
|
||||
'Turns expand() to Nette\DI\Helpers::expand() value in Nette\DI\CompilerExtension',
|
||||
[
|
||||
new CodeSample(
|
||||
'$builder->expand(object|array)',
|
||||
'\Nette\DI\Helpers::expand(object|array, $builder->parameters);'
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function isCandidate(Node $node): bool
|
||||
{
|
||||
$parentClassName = $node->getAttribute(Attribute::PARENT_CLASS_NAME);
|
||||
if ($parentClassName !== $this->compilerExtensionClass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @var MethodCall $methodCallNode */
|
||||
$methodCallNode = $node;
|
||||
|
||||
if (! $this->methodCallAnalyzer->isMethod($methodCallNode, 'expand')
|
||||
|| $this->methodArgumentAnalyzer->isMethodNthArgumentString($methodCallNode, 1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MethodCall $methodCallNode
|
||||
*
|
||||
* Returns \Nette\DI\Helpers::expand('argument', $builder->parameters)
|
||||
*/
|
||||
public function refactor(Node $methodCallNode): ?Node
|
||||
{
|
||||
$arguments = [$methodCallNode->args[0], new PropertyFetch($methodCallNode->var, 'parameters')];
|
||||
|
||||
return $this->builderFactory->staticCall('Nette\DI\Helpers', 'expand', $arguments);
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Nette\Rector\DI;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Name;
|
||||
use Rector\Node\Attribute;
|
||||
use Rector\Node\NodeFactory;
|
||||
use Rector\NodeAnalyzer\MethodCallAnalyzer;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\RectorDefinition\CodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
|
||||
/**
|
||||
* Covers https://github.com/Kdyby/Doctrine/pull/269/files
|
||||
*/
|
||||
final class SetEntityToStatementRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @var MethodCallAnalyzer
|
||||
*/
|
||||
private $methodCallAnalyzer;
|
||||
|
||||
/**
|
||||
* @var NodeFactory
|
||||
*/
|
||||
private $nodeFactory;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $compilerExtensionClass;
|
||||
|
||||
public function __construct(
|
||||
MethodCallAnalyzer $methodCallAnalyzer,
|
||||
NodeFactory $nodeFactory,
|
||||
string $compilerExtensionClass = 'Nette\DI\CompilerExtension'
|
||||
) {
|
||||
$this->methodCallAnalyzer = $methodCallAnalyzer;
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
$this->compilerExtensionClass = $compilerExtensionClass;
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition(
|
||||
'Turns setDefinition() to Nette\DI\Helpers::expand() value in Nette\DI\CompilerExtension',
|
||||
[
|
||||
new CodeSample(
|
||||
'$definition->setEntity("someEntity");',
|
||||
'$definition = new Statement("someEntity", $definition->arguments);'
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function isCandidate(Node $node): bool
|
||||
{
|
||||
$parentClassName = $node->getAttribute(Attribute::PARENT_CLASS_NAME);
|
||||
if ($parentClassName !== $this->compilerExtensionClass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->methodCallAnalyzer->isMethod($node, 'setEntity');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MethodCall $methodCallNode
|
||||
*
|
||||
* Returns $variable = new Nette\DI\Statement($oldArg, $variable->arguments);
|
||||
*/
|
||||
public function refactor(Node $methodCallNode): ?Node
|
||||
{
|
||||
return new Assign(
|
||||
$methodCallNode->var,
|
||||
new New_(
|
||||
new Name('Nette\DI\Statement'),
|
||||
[
|
||||
$methodCallNode->args[0],
|
||||
$this->nodeFactory->createArg(new PropertyFetch($methodCallNode->var, 'arguments')),
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<?php declare (strict_types=1);
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
/**
|
||||
* @var Nette\Bridges\ApplicationLatte\Template
|
||||
*/
|
||||
private $template;
|
||||
|
||||
public function action()
|
||||
{
|
||||
$this->template->getLatte()->invokeFilter('someFilter', 'value');
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Nette\Tests\Rector\Application\TemplateMagicInvokeFilterCallRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
|
||||
/**
|
||||
* @covers \Rector\Nette\Rector\Application\TemplateMagicInvokeFilterCallRector
|
||||
*/
|
||||
final class TemplateMagicInvokeFilterCallRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideWrongToFixedFiles()
|
||||
*/
|
||||
public function test(string $wrong, string $fixed): void
|
||||
{
|
||||
$this->doTestFileMatchesExpectedContent($wrong, $fixed);
|
||||
}
|
||||
|
||||
public function provideWrongToFixedFiles(): Iterator
|
||||
{
|
||||
yield [__DIR__ . '/Wrong/wrong.php.inc', __DIR__ . '/Correct/correct.php.inc'];
|
||||
}
|
||||
|
||||
protected function provideConfig(): string
|
||||
{
|
||||
return __DIR__ . '/config.yml';
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<?php declare (strict_types=1);
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
/**
|
||||
* @var Nette\Bridges\ApplicationLatte\Template
|
||||
*/
|
||||
private $template;
|
||||
|
||||
public function action()
|
||||
{
|
||||
$this->template->someFilter('value');
|
||||
}
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
services:
|
||||
Rector\Nette\Rector\Application\TemplateMagicInvokeFilterCallRector: ~
|
@ -1,14 +0,0 @@
|
||||
<?php declare (strict_types=1);
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
/**
|
||||
* @var Nette\Bridges\ApplicationLatte\Template
|
||||
*/
|
||||
private $template;
|
||||
|
||||
public function action()
|
||||
{
|
||||
$this->template->getLatte()->addFilter('value', 'callback');
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Nette\Tests\Rector\Application\TemplateRegisterHelperRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
|
||||
/**
|
||||
* @covers \Rector\Nette\Rector\Application\TemplateRegisterHelperRector
|
||||
*/
|
||||
final class TemplateRegisterHelperRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideWrongToFixedFiles()
|
||||
*/
|
||||
public function test(string $wrong, string $fixed): void
|
||||
{
|
||||
$this->doTestFileMatchesExpectedContent($wrong, $fixed);
|
||||
}
|
||||
|
||||
public function provideWrongToFixedFiles(): Iterator
|
||||
{
|
||||
yield [__DIR__ . '/Wrong/wrong.php.inc', __DIR__ . '/Correct/correct.php.inc'];
|
||||
}
|
||||
|
||||
protected function provideConfig(): string
|
||||
{
|
||||
return __DIR__ . '/config.yml';
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<?php declare (strict_types=1);
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
/**
|
||||
* @var Nette\Bridges\ApplicationLatte\Template
|
||||
*/
|
||||
private $template;
|
||||
|
||||
public function action()
|
||||
{
|
||||
$this->template->registerHelper('value', 'callback');
|
||||
}
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
services:
|
||||
Rector\Nette\Rector\Application\TemplateRegisterHelperRector: ~
|
@ -1,19 +0,0 @@
|
||||
<?php declare (strict_types=1);
|
||||
|
||||
use Rector\Nette\Tests\Rector\DI\Source\NetteCompilerExtension;
|
||||
|
||||
class SomeNetteExtension extends NetteCompilerExtension
|
||||
{
|
||||
/**
|
||||
* @var SomeBuilder
|
||||
*/
|
||||
private $builder;
|
||||
|
||||
public function loadConfiguration()
|
||||
{
|
||||
$builder = new SomeBuilder;
|
||||
$builder->parameters['appDir'];
|
||||
$this->builder->parameters['appDir'];
|
||||
$this->getContainerBuilder()->parameters['appDir'];
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Nette\Tests\Rector\DI\ExpandFunctionToParametersArrayRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
|
||||
/**
|
||||
* @covers \Rector\Nette\Rector\DI\ExpandFunctionToParametersArrayRector
|
||||
*/
|
||||
final class ExpandFunctionToParametersArrayRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideWrongToFixedFiles()
|
||||
*/
|
||||
public function test(string $wrong, string $fixed): void
|
||||
{
|
||||
$this->doTestFileMatchesExpectedContent($wrong, $fixed);
|
||||
}
|
||||
|
||||
public function provideWrongToFixedFiles(): Iterator
|
||||
{
|
||||
yield [__DIR__ . '/Wrong/wrong.php.inc', __DIR__ . '/Correct/correct.php.inc'];
|
||||
}
|
||||
|
||||
protected function provideConfig(): string
|
||||
{
|
||||
return __DIR__ . '/config.yml';
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php declare (strict_types=1);
|
||||
|
||||
use Rector\Nette\Tests\Rector\DI\Source\NetteCompilerExtension;
|
||||
|
||||
class SomeNetteExtension extends NetteCompilerExtension
|
||||
{
|
||||
/**
|
||||
* @var SomeBuilder
|
||||
*/
|
||||
private $builder;
|
||||
|
||||
public function loadConfiguration()
|
||||
{
|
||||
$builder = new SomeBuilder;
|
||||
$builder->expand('%appDir%');
|
||||
$this->builder->expand('%appDir%');
|
||||
$this->getContainerBuilder()->expand('%appDir%');
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
services:
|
||||
Rector\Nette\Rector\DI\ExpandFunctionToParametersArrayRector:
|
||||
$compilerExtensionClass: 'Rector\Nette\Tests\Rector\DI\Source\NetteCompilerExtension'
|
@ -1,21 +0,0 @@
|
||||
<?php declare (strict_types=1);
|
||||
|
||||
use Rector\Nette\Tests\Rector\DI\Source\NetteCompilerExtension;
|
||||
|
||||
class SomeNetteExtension extends NetteCompilerExtension
|
||||
{
|
||||
public function loadConfiguration()
|
||||
{
|
||||
Nette\DI\Helpers::expand($config['logging'], $builder->parameters);
|
||||
Nette\DI\Helpers::expand(Nette\DI\Config\Helpers::merge(
|
||||
array_diff_key(
|
||||
$provided,
|
||||
array_diff_key(
|
||||
$diff,
|
||||
$defaults
|
||||
)
|
||||
),
|
||||
$defaults
|
||||
), $this->getContainerBuilder()->parameters);
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Nette\Tests\Rector\DI\ExpandFunctionToStaticExpandFunctionRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
|
||||
/**
|
||||
* @covers \Rector\Nette\Rector\DI\ExpandFunctionToStaticExpandFunctionRector
|
||||
*/
|
||||
final class ExpandFunctionToStaticExpandFunctionRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideWrongToFixedFiles()
|
||||
*/
|
||||
public function test(string $wrong, string $fixed): void
|
||||
{
|
||||
$this->doTestFileMatchesExpectedContent($wrong, $fixed);
|
||||
}
|
||||
|
||||
public function provideWrongToFixedFiles(): Iterator
|
||||
{
|
||||
yield [__DIR__ . '/Wrong/wrong.php.inc', __DIR__ . '/Correct/correct.php.inc'];
|
||||
}
|
||||
|
||||
protected function provideConfig(): string
|
||||
{
|
||||
return __DIR__ . '/config.yml';
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?php declare (strict_types=1);
|
||||
|
||||
use Rector\Nette\Tests\Rector\DI\Source\NetteCompilerExtension;
|
||||
|
||||
class SomeNetteExtension extends NetteCompilerExtension
|
||||
{
|
||||
public function loadConfiguration()
|
||||
{
|
||||
$builder->expand($config['logging']);
|
||||
$this->getContainerBuilder()->expand(Nette\DI\Config\Helpers::merge(
|
||||
array_diff_key(
|
||||
$provided,
|
||||
array_diff_key(
|
||||
$diff,
|
||||
$defaults
|
||||
)
|
||||
),
|
||||
$defaults
|
||||
));
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
services:
|
||||
Rector\Nette\Rector\DI\ExpandFunctionToStaticExpandFunctionRector:
|
||||
$compilerExtensionClass: 'Rector\Nette\Tests\Rector\DI\Source\NetteCompilerExtension'
|
@ -1,12 +0,0 @@
|
||||
<?php declare (strict_types=1);
|
||||
|
||||
use Rector\Nette\Tests\Rector\DI\Source\NetteCompilerExtension;
|
||||
|
||||
class SomeNetteExtension extends NetteCompilerExtension
|
||||
{
|
||||
public function loadConfiguration()
|
||||
{
|
||||
$statement = new Nette\DI\Statement('oldEntity');
|
||||
$statement = new Nette\DI\Statement('newEntity', $statement->arguments);
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Nette\Tests\Rector\DI\SetEntityToStatementRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
|
||||
/**
|
||||
* @covers \Rector\Nette\Rector\DI\SetEntityToStatementRector
|
||||
*/
|
||||
final class SetEntityToStatementRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideWrongToFixedFiles()
|
||||
*/
|
||||
public function test(string $wrong, string $fixed): void
|
||||
{
|
||||
$this->doTestFileMatchesExpectedContent($wrong, $fixed);
|
||||
}
|
||||
|
||||
public function provideWrongToFixedFiles(): Iterator
|
||||
{
|
||||
yield [__DIR__ . '/Wrong/wrong.php.inc', __DIR__ . '/Correct/correct.php.inc'];
|
||||
}
|
||||
|
||||
protected function provideConfig(): string
|
||||
{
|
||||
return __DIR__ . '/config.yml';
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
<?php declare (strict_types=1);
|
||||
|
||||
use Rector\Nette\Tests\Rector\DI\Source\NetteCompilerExtension;
|
||||
|
||||
class SomeNetteExtension extends NetteCompilerExtension
|
||||
{
|
||||
public function loadConfiguration()
|
||||
{
|
||||
$statement = new Nette\DI\Statement('oldEntity');
|
||||
$statement->setEntity('newEntity');
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
services:
|
||||
Rector\Nette\Rector\DI\SetEntityToStatementRector:
|
||||
$compilerExtensionClass: 'Rector\Nette\Tests\Rector\DI\Source\NetteCompilerExtension'
|
@ -1,8 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Nette\Tests\Rector\DI\Source;
|
||||
|
||||
class NetteCompilerExtension
|
||||
{
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user