mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-05 10:50:48 +00:00
[Rector] FormCallbackRector - use type
This commit is contained in:
parent
279a233f66
commit
ffc94f276e
|
@ -30,6 +30,7 @@ parameters:
|
|||
- PhpCsFixer\Fixer\Operator\NewWithBracesFixer
|
||||
- PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer
|
||||
- PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer
|
||||
- PhpCsFixer\Fixer\Phpdoc\PhpdocSummaryFixer
|
||||
|
||||
skip:
|
||||
Symplify\CodingStandard\Fixer\Php\ClassStringToClassConstantFixer:
|
||||
|
|
|
@ -71,7 +71,7 @@ final class FormCallbackRector extends NodeVisitorAbstract implements Deprecatio
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($node->var->name !== 'form') {
|
||||
if ($node->var->getAttribute('type') !== $this->getDesiredClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,9 @@ final class FormCallbackRector extends NodeVisitorAbstract implements Deprecatio
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* [$this, 'something']
|
||||
*/
|
||||
private function createShortArray(Node $node): Array_
|
||||
{
|
||||
return new Array_([
|
||||
|
@ -96,4 +99,9 @@ final class FormCallbackRector extends NodeVisitorAbstract implements Deprecatio
|
|||
'kind' => Array_::KIND_SHORT,
|
||||
]);
|
||||
}
|
||||
|
||||
private function getDesiredClass(): string
|
||||
{
|
||||
return 'Nette\Application\UI\Form';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,15 @@ class SomePresenter
|
|||
{
|
||||
$form = new Form;
|
||||
|
||||
$form->onSuccess[] = $this->someMethod;
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function createNetteForm()
|
||||
{
|
||||
$form = new \Nette\Application\UI\Form;
|
||||
|
||||
$form->onSuccess[] = [$this, 'someMethod'];
|
||||
|
||||
return $form;
|
||||
|
|
|
@ -10,4 +10,13 @@ class SomePresenter
|
|||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function createNetteForm()
|
||||
{
|
||||
$form = new \Nette\Application\UI\Form;
|
||||
|
||||
$form->onSuccess[] = $this->someMethod;
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user