diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md index eefb9a2054a..110c5f4f57a 100644 --- a/docs/rector_rules_overview.md +++ b/docs/rector_rules_overview.md @@ -1,4 +1,4 @@ -# All 501 Rectors Overview +# All 500 Rectors Overview - [Projects](#projects) - [General](#general) @@ -4288,7 +4288,7 @@ Nextras/Form upgrade of addDatePicker method call to DateControl assign - class: [`Rector\Nette\Rector\Identical\EndsWithFunctionToNetteUtilsStringsRector`](/../master/rules/nette/src/Rector/Identical/EndsWithFunctionToNetteUtilsStringsRector.php) - [test fixtures](/../master/rules/nette/tests/Rector/Identical/EndsWithFunctionToNetteUtilsStringsRector/Fixture) -Use Nette\Utils\Strings over bare string-functions +Use Nette\Utils\Strings::endWith() over bare string-functions ```diff class SomeClass @@ -4298,9 +4298,7 @@ Use Nette\Utils\Strings over bare string-functions $content = 'Hi, my name is Tom'; - $yes = substr($content, -strlen($needle)) === $needle; -- $no = $needle !== substr($content, -strlen($needle)); + $yes = \Nette\Utils\Strings::endsWith($content, $needle); -+ $no = !\Nette\Utils\Strings::endsWith($content, $needle); } } ``` @@ -4437,7 +4435,7 @@ Change setClass with class and arguments to separated methods - class: [`Rector\Nette\Rector\Identical\StartsWithFunctionToNetteUtilsStringsRector`](/../master/rules/nette/src/Rector/Identical/StartsWithFunctionToNetteUtilsStringsRector.php) - [test fixtures](/../master/rules/nette/tests/Rector/Identical/StartsWithFunctionToNetteUtilsStringsRector/Fixture) -Use Nette\Utils\Strings over bare string-functions +Use Nette\Utils\Strings::startsWith() over bare string-functions ```diff class SomeClass @@ -4447,9 +4445,7 @@ Use Nette\Utils\Strings over bare string-functions $content = 'Hi, my name is Tom'; - $yes = substr($content, 0, strlen($needle)) === $needle; -- $no = $needle !== substr($content, 0, strlen($needle)); -+ $yes = \Nette\Utils\Strings::startwith($content, $needle); -+ $no = !\Nette\Utils\Strings::startwith($content, $needle); ++ $yes = \Nette\Utils\Strings::startsWith($content, $needle); } } ``` @@ -5777,29 +5773,6 @@ Use explicit API for expecting PHP errors, warnings, and notices
-### `FixDataProviderAnnotationTypoRector` - -- class: [`Rector\PHPUnit\Rector\ClassMethod\FixDataProviderAnnotationTypoRector`](/../master/rules/phpunit/src/Rector/ClassMethod/FixDataProviderAnnotationTypoRector.php) -- [test fixtures](/../master/rules/phpunit/tests/Rector/ClassMethod/FixDataProviderAnnotationTypoRector/Fixture) - -Fix data provider annotation typos - -```diff - class SomeClass extends \PHPUnit\Framework\TestCase - { - /** -- * @dataProvidor testProvideData() -+ * @dataProvider testProvideData() - */ - public function test() - { - $nothing = 5; - } - } -``` - -
- ### `GetMockBuilderGetMockToCreateMockRector` - class: [`Rector\PHPUnit\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector`](/../master/rules/phpunit/src/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector.php) diff --git a/rules/phpunit/src/Rector/ClassMethod/FixDataProviderAnnotationTypoRector.php b/rules/phpunit/src/Rector/ClassMethod/FixDataProviderAnnotationTypoRector.php deleted file mode 100644 index 6e918533908..00000000000 --- a/rules/phpunit/src/Rector/ClassMethod/FixDataProviderAnnotationTypoRector.php +++ /dev/null @@ -1,96 +0,0 @@ -isInTestClass($node)) { - return null; - } - - /** @var PhpDocInfo $phpDocInfo */ - $phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO); - - $phpDocNode = $phpDocInfo->getPhpDocNode(); - foreach ($phpDocNode->children as $phpDocChildNode) { - if (! $phpDocChildNode instanceof PhpDocTagNode) { - continue; - } - - $annotationName = $phpDocChildNode->name; - $annotationName = trim($annotationName, '()@'); - - // more than 2 letter difference, probably not a typo - if (levenshtein($annotationName, 'dataProvider') > 4) { - continue; - } - - $phpDocChildNode->name = '@dataProvider '; - } - - return $node; - } -} diff --git a/rules/phpunit/tests/Rector/ClassMethod/FixDataProviderAnnotationTypoRector/FixDataProviderAnnotationTypoRectorTest.php b/rules/phpunit/tests/Rector/ClassMethod/FixDataProviderAnnotationTypoRector/FixDataProviderAnnotationTypoRectorTest.php deleted file mode 100644 index f3a76f40a4b..00000000000 --- a/rules/phpunit/tests/Rector/ClassMethod/FixDataProviderAnnotationTypoRector/FixDataProviderAnnotationTypoRectorTest.php +++ /dev/null @@ -1,30 +0,0 @@ -doTestFile($file); - } - - public function provideData(): Iterator - { - return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - protected function getRectorClass(): string - { - return FixDataProviderAnnotationTypoRector::class; - } -} diff --git a/rules/phpunit/tests/Rector/ClassMethod/FixDataProviderAnnotationTypoRector/Fixture/fixture.php.inc b/rules/phpunit/tests/Rector/ClassMethod/FixDataProviderAnnotationTypoRector/Fixture/fixture.php.inc deleted file mode 100644 index 9051c80757f..00000000000 --- a/rules/phpunit/tests/Rector/ClassMethod/FixDataProviderAnnotationTypoRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,39 +0,0 @@ - ------ -