Skip to content

Commit

Permalink
[docs] Remove post Rectors from generated docs (#2833)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba authored Aug 24, 2022
1 parent e66447b commit 041f41f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 178 deletions.
160 changes: 2 additions & 158 deletions build/target-repository/docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 408 Rules Overview
# 401 Rules Overview

<br>

Expand Down Expand Up @@ -54,8 +54,6 @@

- [Php82](#php82) (1)

- [PostRector](#postrector) (6)

- [Privatization](#privatization) (8)

- [Removing](#removing) (6)
Expand All @@ -64,7 +62,7 @@

- [Renaming](#renaming) (11)

- [Restoration](#restoration) (5)
- [Restoration](#restoration) (4)

- [Strict](#strict) (5)

Expand Down Expand Up @@ -6523,123 +6521,6 @@ Decorate read-only class with `readonly` attribute

<br>

## PostRector

### ClassRenamingPostRector

Rename references for classes that were renamed during Rector run

- class: [`Rector\PostRector\Rector\ClassRenamingPostRector`](../packages/PostRector/Rector/ClassRenamingPostRector.php)

```diff
-function (OriginalClass $someClass)
+function (RenamedClass $someClass)
{
}
```

<br>

### NameImportingPostRector

Imports fully qualified names

- class: [`Rector\PostRector\Rector\NameImportingPostRector`](../packages/PostRector/Rector/NameImportingPostRector.php)

```diff
+use App\AnotherClass;
+
class SomeClass
{
- public function run(App\AnotherClass $anotherClass)
+ public function run(AnotherClass $anotherClass)
{
}
}
```

<br>

### NodeAddingPostRector

Add nodes on weird positions

- class: [`Rector\PostRector\Rector\NodeAddingPostRector`](../packages/PostRector/Rector/NodeAddingPostRector.php)

```diff
class SomeClass
{
public function run($value)
{
- return 1;
+ if ($value) {
+ return 1;
+ }
}
}
```

<br>

### NodeRemovingPostRector

Remove nodes from weird positions

- class: [`Rector\PostRector\Rector\NodeRemovingPostRector`](../packages/PostRector/Rector/NodeRemovingPostRector.php)

```diff
class SomeClass
{
public function run($value)
{
- if ($value) {
- return 1;
- }
+ return 1;
}
}
```

<br>

### PropertyAddingPostRector

Add dependency properties

- class: [`Rector\PostRector\Rector\PropertyAddingPostRector`](../packages/PostRector/Rector/PropertyAddingPostRector.php)

```diff
class SomeClass
{
+ private $value;
public function run()
{
return $this->value;
}
}
```

<br>

### UseAddingPostRector

Add unique use imports collected during Rector run

- class: [`Rector\PostRector\Rector\UseAddingPostRector`](../packages/PostRector/Rector/UseAddingPostRector.php)

```diff
+use App\AnotherClass;
+
class SomeClass
{
public function run(AnotherClass $anotherClass)
{
}
}
```

<br>

## Privatization

### ChangeGlobalVariablesToPropertiesRector
Expand Down Expand Up @@ -7424,43 +7305,6 @@ return static function (RectorConfig $rectorConfig): void {

## Restoration

### CompleteImportForPartialAnnotationRector

In case you have accidentally removed use imports but code still contains partial use statements, this will save you

:wrench: **configure it!**

- class: [`Rector\Restoration\Rector\Namespace_\CompleteImportForPartialAnnotationRector`](../rules/Restoration/Rector/Namespace_/CompleteImportForPartialAnnotationRector.php)

```php
use Rector\Config\RectorConfig;
use Rector\Restoration\Rector\Namespace_\CompleteImportForPartialAnnotationRector;
use Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(
CompleteImportForPartialAnnotationRector::class,
[new CompleteImportForPartialAnnotation('Doctrine\ORM\Mapping', 'ORM')]
);
};
```


```diff
+use Doctrine\ORM\Mapping as ORM;
+
class SomeClass
{
/**
* @ORM\Id
*/
public $id;
}
```

<br>

### MakeTypedPropertyNullableIfCheckedRector

Make typed property nullable if checked
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"symplify/monorepo-builder": "^11.1",
"symplify/phpstan-extensions": "^11.1",
"symplify/phpstan-rules": "^11.1",
"symplify/rule-doc-generator": "^11.1",
"symplify/rule-doc-generator": "dev-main",
"symplify/vendor-patches": "^11.1"
},
"replace": {
Expand Down
4 changes: 3 additions & 1 deletion rule-doc-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
declare(strict_types=1);

use Rector\Utils\RuleDocGenerator\Category\RectorCategoryInferer;
use Rector\Utils\RuleDocGenerator\PostRectorOutFilter;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $rectorConfig): void {
$services = $rectorConfig->services();
$services->set(RectorCategoryInferer::class);

$services->set(\Rector\Utils\RuleDocGenerator\PostRectorOutFilter::class);
// remove PostRectorInterface rules from the generated output; they're internal and confusing for end-user
$services->set(PostRectorOutFilter::class);
};
16 changes: 0 additions & 16 deletions utils/RuleDocGenerator/Contract/OutFilterInterface.php

This file was deleted.

4 changes: 2 additions & 2 deletions utils/RuleDocGenerator/PostRectorOutFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace Rector\Utils\RuleDocGenerator;

use Rector\PostRector\Contract\Rector\PostRectorInterface;
use Rector\Utils\RuleDocGenerator\Contract\OutFilterInterface;
use Symplify\RuleDocGenerator\Contract\RuleOutFilterInterface;
use Symplify\RuleDocGenerator\ValueObject\RuleClassWithFilePath;

final class PostRectorOutFilter implements OutFilterInterface
final class PostRectorOutFilter implements RuleOutFilterInterface
{
/**
* @param RuleClassWithFilePath[] $ruleClassWithFilePath
Expand Down

0 comments on commit 041f41f

Please sign in to comment.