diff --git a/config/set/nette-code-quality.php b/config/set/nette-code-quality.php
index 12623877c85..18808882b77 100644
--- a/config/set/nette-code-quality.php
+++ b/config/set/nette-code-quality.php
@@ -3,7 +3,6 @@
declare(strict_types=1);
use Rector\Nette\Rector\ClassMethod\TemplateMagicAssignToExplicitVariableArrayRector;
-use Rector\NetteCodeQuality\Rector\ArrayDimFetch\ArrayDimFetchControlToGetComponentMethodCallRector;
use Rector\NetteCodeQuality\Rector\ArrayDimFetch\ChangeControlArrayAccessToAnnotatedControlVariableRector;
use Rector\NetteCodeQuality\Rector\Assign\ArrayAccessGetControlToGetComponentMethodCallRector;
use Rector\NetteCodeQuality\Rector\Assign\ArrayAccessSetControlToAddComponentMethodCallRector;
@@ -19,8 +18,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services->set(ChangeControlArrayAccessToAnnotatedControlVariableRector::class);
- $services->set(ArrayDimFetchControlToGetComponentMethodCallRector::class);
-
$services->set(ArrayAccessSetControlToAddComponentMethodCallRector::class);
$services->set(ArrayAccessGetControlToGetComponentMethodCallRector::class);
diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md
index 166a45ef4b4..a891cecd99c 100644
--- a/docs/rector_rules_overview.md
+++ b/docs/rector_rules_overview.md
@@ -1,4 +1,4 @@
-# All 549 Rectors Overview
+# All 548 Rectors Overview
- [Projects](#projects)
---
@@ -31,7 +31,7 @@
- [MysqlToMysqli](#mysqltomysqli) (4)
- [Naming](#naming) (3)
- [Nette](#nette) (14)
-- [NetteCodeQuality](#nettecodequality) (7)
+- [NetteCodeQuality](#nettecodequality) (6)
- [NetteKdyby](#nettekdyby) (4)
- [NetteTesterToPHPUnit](#nettetestertophpunit) (3)
- [NetteToSymfony](#nettetosymfony) (9)
@@ -6996,33 +6996,6 @@ Change magic arrays access set, to explicit `$this->setComponent(...)` method
-### `ArrayDimFetchControlToGetComponentMethodCallRector`
-
-- class: [`Rector\NetteCodeQuality\Rector\ArrayDimFetch\ArrayDimFetchControlToGetComponentMethodCallRector`](/../master/rules/nette-code-quality/src/Rector/ArrayDimFetch/ArrayDimFetchControlToGetComponentMethodCallRector.php)
-- [test fixtures](/../master/rules/nette-code-quality/tests/Rector/ArrayDimFetch/ArrayDimFetchControlToGetComponentMethodCallRector/Fixture)
-
-Change array dim `$this["someComponent"]` to more explicit `$this->getComponent("someComponent")`
-
-```diff
- use Nette\Application\UI\Presenter;
-
- class SomePresenter extends Presenter
- {
- public function someAction()
- {
-- $form = $this['someForm'];
-+ $form = $this->getComponent('someForm');
- }
-
- protected function createComponentSomeForm()
- {
- return new Form();
- }
- }
-```
-
-
-
### `ChangeControlArrayAccessToAnnotatedControlVariableRector`
- class: [`Rector\NetteCodeQuality\Rector\ArrayDimFetch\ChangeControlArrayAccessToAnnotatedControlVariableRector`](/../master/rules/nette-code-quality/src/Rector/ArrayDimFetch/ChangeControlArrayAccessToAnnotatedControlVariableRector.php)
diff --git a/rules/nette-code-quality/src/Rector/ArrayDimFetch/ArrayDimFetchControlToGetComponentMethodCallRector.php b/rules/nette-code-quality/src/Rector/ArrayDimFetch/ArrayDimFetchControlToGetComponentMethodCallRector.php
deleted file mode 100644
index b22dbd34514..00000000000
--- a/rules/nette-code-quality/src/Rector/ArrayDimFetch/ArrayDimFetchControlToGetComponentMethodCallRector.php
+++ /dev/null
@@ -1,91 +0,0 @@
-getComponent("someComponent")',
- [
- new CodeSample(
- <<<'PHP'
-use Nette\Application\UI\Presenter;
-
-class SomePresenter extends Presenter
-{
- public function someAction()
- {
- $form = $this['someForm'];
- }
-
- protected function createComponentSomeForm()
- {
- return new Form();
- }
-}
-PHP
-,
- <<<'PHP'
-use Nette\Application\UI\Presenter;
-
-class SomePresenter extends Presenter
-{
- public function someAction()
- {
- $form = $this->getComponent('someForm');
- }
-
- protected function createComponentSomeForm()
- {
- return new Form();
- }
-}
-PHP
- ),
- ]
- );
- }
-
- /**
- * @param ArrayDimFetch $node
- */
- public function refactor(Node $node): ?Node
- {
- if ($this->shouldSkip($node)) {
- return null;
- }
-
- $controlName = $this->controlDimFetchAnalyzer->matchNameOnControlVariable($node);
-
- return new MethodCall($node->var, 'getComponent', $this->createArgs([$controlName]));
- }
-
- private function shouldSkip(ArrayDimFetch $arrayDimFetch): bool
- {
- $parent = $arrayDimFetch->getAttribute(AttributeKey::PARENT_NODE);
- if ($parent instanceof Assign && $parent->var === $arrayDimFetch) {
- return true;
- }
-
- return $parent instanceof MethodCall;
- }
-}
diff --git a/rules/nette-code-quality/src/Rector/Assign/MakeGetComponentAssignAnnotatedRector.php b/rules/nette-code-quality/src/Rector/Assign/MakeGetComponentAssignAnnotatedRector.php
index edd2787f383..13c48262d87 100644
--- a/rules/nette-code-quality/src/Rector/Assign/MakeGetComponentAssignAnnotatedRector.php
+++ b/rules/nette-code-quality/src/Rector/Assign/MakeGetComponentAssignAnnotatedRector.php
@@ -14,7 +14,6 @@ use PhpParser\Node\Scalar\String_;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ParametersAcceptorSelector;
use PHPStan\Type\MixedType;
-use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeWithClassName;
use Rector\BetterPhpDocParser\PhpDocManipulator\VarAnnotationManipulator;
@@ -207,7 +206,7 @@ PHP
$methodName = sprintf('createComponent%s', ucfirst($componentName));
$calledOnType = $scope->getType($expr);
- if (! $calledOnType instanceof ObjectType) {
+ if (! $calledOnType instanceof TypeWithClassName) {
return new MixedType();
}
diff --git a/rules/nette-code-quality/tests/Rector/ArrayDimFetch/ArrayDimFetchControlToGetComponentMethodCallRector/ArrayDimFetchControlToGetComponentMethodCallRectorTest.php b/rules/nette-code-quality/tests/Rector/ArrayDimFetch/ArrayDimFetchControlToGetComponentMethodCallRector/ArrayDimFetchControlToGetComponentMethodCallRectorTest.php
deleted file mode 100644
index d59b3f50d14..00000000000
--- a/rules/nette-code-quality/tests/Rector/ArrayDimFetch/ArrayDimFetchControlToGetComponentMethodCallRector/ArrayDimFetchControlToGetComponentMethodCallRectorTest.php
+++ /dev/null
@@ -1,31 +0,0 @@
-doTestFileInfo($fileInfo);
- }
-
- public function provideData(): Iterator
- {
- return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
- }
-
- protected function getRectorClass(): string
- {
- return ArrayDimFetchControlToGetComponentMethodCallRector::class;
- }
-}
diff --git a/rules/nette-code-quality/tests/Rector/ArrayDimFetch/ArrayDimFetchControlToGetComponentMethodCallRector/Fixture/fixture.php.inc b/rules/nette-code-quality/tests/Rector/Assign/ArrayAccessGetControlToGetComponentMethodCallRector/Fixture/create_component.php.inc
similarity index 69%
rename from rules/nette-code-quality/tests/Rector/ArrayDimFetch/ArrayDimFetchControlToGetComponentMethodCallRector/Fixture/fixture.php.inc
rename to rules/nette-code-quality/tests/Rector/Assign/ArrayAccessGetControlToGetComponentMethodCallRector/Fixture/create_component.php.inc
index a3790411c1a..009e4647fa3 100644
--- a/rules/nette-code-quality/tests/Rector/ArrayDimFetch/ArrayDimFetchControlToGetComponentMethodCallRector/Fixture/fixture.php.inc
+++ b/rules/nette-code-quality/tests/Rector/Assign/ArrayAccessGetControlToGetComponentMethodCallRector/Fixture/create_component.php.inc
@@ -1,6 +1,6 @@
getComponent('another');
+ }
+
+ /**
+ * @return AnotherControl
+ */
+ protected function createComponentAnother()
+ {
+ return new AnotherControl();
+ }
+}
+
+?>
+-----
+getComponent('another');
+ }
+
+ /**
+ * @return AnotherControl
+ */
+ protected function createComponentAnother()
+ {
+ return new AnotherControl();
+ }
+}
+
+?>
diff --git a/stubs/Nette/Application/UI/Presenter.php b/stubs/Nette/Application/UI/Presenter.php
index e7ca89ee387..542cc7e792b 100644
--- a/stubs/Nette/Application/UI/Presenter.php
+++ b/stubs/Nette/Application/UI/Presenter.php
@@ -10,5 +10,4 @@ if (class_exists('Nette\Application\UI\Presenter')) {
class Presenter extends Control
{
-
}
diff --git a/stubs/Nette/ComponentModel/Container.php b/stubs/Nette/ComponentModel/Container.php
index ccf3bdc5632..774bb1e47c0 100644
--- a/stubs/Nette/ComponentModel/Container.php
+++ b/stubs/Nette/ComponentModel/Container.php
@@ -98,7 +98,7 @@ abstract class Container implements IContainer
* Returns component specified by name or path.
* @param bool $throw throw exception if component doesn't exist?
*/
- final public function getComponent(string $name, bool $throw = true): ?IComponent
+ public function getComponent(string $name, bool $throw = true): ?IComponent
{
[$name] = $parts = explode(self::NAME_SEPARATOR, $name, 2);