Skip to content

Commit

Permalink
[RuleDefinition] Fix Sample Code docs generation (#768)
Browse files Browse the repository at this point in the history
* [RuleDefinition] Fix Sample Code docs generation

* clean up
  • Loading branch information
samsonasik authored Aug 26, 2021
1 parent 4731c3f commit fff52c3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
39 changes: 34 additions & 5 deletions build/target-repository/docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 476 Rules Overview
# 477 Rules Overview

<br>

Expand All @@ -24,7 +24,7 @@

- [DowngradePhp53](#downgradephp53) (1)

- [DowngradePhp70](#downgradephp70) (10)
- [DowngradePhp70](#downgradephp70) (11)

- [DowngradePhp71](#downgradephp71) (9)

Expand Down Expand Up @@ -3840,7 +3840,9 @@ Removes unneeded $a = $a assigns
- class: [`Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector`](../rules/DeadCode/Rector/Expression/SimplifyMirrorAssignRector.php)

```diff
-$a = $a;
function run() {
- $a = $a;
}
```

<br>
Expand Down Expand Up @@ -4311,6 +4313,32 @@ Change null coalesce to isset ternary check

<br>

### DowngradeParentTypeDeclarationRector

Remove "parent" return type, add a `"@return` parent" tag instead

- class: [`Rector\DowngradePhp70\Rector\ClassMethod\DowngradeParentTypeDeclarationRector`](../rules/DowngradePhp70/Rector/ClassMethod/DowngradeParentTypeDeclarationRector.php)

```diff
class ParentClass
{
}

class SomeClass extends ParentClass
{
- public function foo(): parent
+ /**
+ * @return parent
+ */
+ public function foo()
{
return $this;
}
}
```

<br>

### DowngradeScalarTypeDeclarationRector

Remove the type params and return type, add `@param` and `@return` tags instead
Expand Down Expand Up @@ -4395,6 +4423,7 @@ Remove the declare(strict_types=1)

```diff
-declare(strict_types=1);
echo 'something';
```

<br>
Expand Down Expand Up @@ -8765,8 +8794,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services->set(ArgumentRemoverRector::class)
->call('configure', [[
ArgumentRemoverRector::REMOVED_ARGUMENTS => ValueObjectInliner::inline([
new ArgumentRemover('ExampleClass', 'someMethod', 0, 'true'),
]),
new ArgumentRemover('ExampleClass', 'someMethod', 0, [true]), ]
),
]]);
};
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ final class SimplifyMirrorAssignRector extends AbstractRector
{
public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition('Removes unneeded $a = $a assigns', [new CodeSample('$a = $a;', '')]);
return new RuleDefinition('Removes unneeded $a = $a assigns', [new CodeSample(
'function run() {
$a = $a;
}',
'function run() {
}'
)]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ public function getRuleDefinition(): RuleDefinition
new CodeSample(
<<<'CODE_SAMPLE'
declare(strict_types=1);
echo 'something';
CODE_SAMPLE
,
<<<'CODE_SAMPLE'
echo 'something';
CODE_SAMPLE
),
]
Expand Down

0 comments on commit fff52c3

Please sign in to comment.