Skip to content

Commit

Permalink
[CodeQuality] Remove SimplifyIfExactValueReturnValueRector, as overly…
Browse files Browse the repository at this point in the history
… defensive + InlineSimplePropertyAnnotationRector as purely coding standard area (#3764)
  • Loading branch information
TomasVotruba committed May 7, 2023
1 parent ea3d4f1 commit be53013
Show file tree
Hide file tree
Showing 34 changed files with 8 additions and 917 deletions.
70 changes: 5 additions & 65 deletions build/target-repository/docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# 420 Rules Overview
# 418 Rules Overview

<br>

## Categories

- [Arguments](#arguments) (6)

- [CodeQuality](#codequality) (78)
- [CodeQuality](#codequality) (77)

- [CodingStyle](#codingstyle) (39)
- [CodingStyle](#codingstyle) (38)

- [Compatibility](#compatibility) (1)

Expand Down Expand Up @@ -1404,23 +1404,6 @@ Changes if/else for same value as assign to ternary

<br>

### SimplifyIfExactValueReturnValueRector

Changes compared to value and return of expr to direct return

- class: [`Rector\CodeQuality\Rector\If_\SimplifyIfExactValueReturnValueRector`](../rules/CodeQuality/Rector/If_/SimplifyIfExactValueReturnValueRector.php)

```diff
$value = 'something';
-if ($value === 52) {
- return 52;
-}
-
return $value;
```

<br>

### SimplifyIfNotNullReturnRector

Changes redundant null check to instant return
Expand Down Expand Up @@ -2143,51 +2126,6 @@ Refactor `func_get_args()` in to a variadic param

<br>

### InlineSimplePropertyAnnotationRector

Inline simple `@var` annotations (or other annotations) when they are the only thing in the phpdoc

:wrench: **configure it!**

- class: [`Rector\CodingStyle\Rector\Property\InlineSimplePropertyAnnotationRector`](../rules/CodingStyle/Rector/Property/InlineSimplePropertyAnnotationRector.php)

```php
<?php

declare(strict_types=1);

use Rector\CodingStyle\Rector\Property\InlineSimplePropertyAnnotationRector;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(InlineSimplePropertyAnnotationRector::class, [
'var',
'phpstan-var',
]);
};
```


```diff
final class SomeClass
{
- /**
- * @phpstan-var string
- */
+ /** @phpstan-var string */
private const TEXT = 'text';

- /**
- * @var DateTime[]
- */
+ /** @var DateTime[] */
private ?array $dateTimes;
}
```

<br>

### MakeInheritedMethodVisibilitySameAsParentRector

Make method visibility same as parent one
Expand Down Expand Up @@ -5398,11 +5336,13 @@ Replace `each()` assign outside loop

```diff
$array = ['b' => 1, 'a' => 2];

-$eachedArray = each($array);
+$eachedArray[1] = current($array);
+$eachedArray['value'] = current($array);
+$eachedArray[0] = key($array);
+$eachedArray['key'] = key($array);
+
+next($array);
```

Expand Down
2 changes: 0 additions & 2 deletions config/set/code-quality.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
use Rector\CodeQuality\Rector\If_\ShortenElseIfRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfExactValueReturnValueRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfNotNullReturnRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
Expand Down Expand Up @@ -192,7 +191,6 @@
InlineIsAInstanceOfRector::class,
TernaryFalseExpressionToIfRector::class,
InlineConstructorDefaultToPropertyRector::class,
SimplifyIfExactValueReturnValueRector::class,
SimplifyUselessLastVariableAssignRector::class,
ReturnTypeFromStrictScalarReturnExprRector::class,
TernaryEmptyArrayArrayDimFetchToCoalesceRector::class,
Expand Down
5 changes: 0 additions & 5 deletions packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,6 @@ public function isNewNode(): bool
return $this->betterTokenIterator->count() === 0;
}

public function makeSingleLined(): void
{
$this->isSingleLine = true;
}

public function isSingleLine(): bool
{
return $this->isSingleLine;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit be53013

Please sign in to comment.