Skip to content

Commit 32e547b

Browse files
committed
refactor(HasOptionsRector): remove unused doc comment and simplify code
- Eliminated the getRuleDefinition method and its associated doc comment. - Streamlined the HasOptionsRector class by removing unnecessary code. - Improved code clarity and maintainability by focusing on essential functionality.
1 parent 3c7ae47 commit 32e547b

File tree

3 files changed

+5
-45
lines changed

3 files changed

+5
-45
lines changed

rector-php82.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
use Guanguans\Notify\Foundation\Rectors\HasHttpClientDocCommentRector;
17-
use Guanguans\Notify\Foundation\Rectors\HasOptionsRector;
17+
use Guanguans\Notify\Foundation\Rectors\MessageRector;
1818
use Rector\Config\RectorConfig;
1919
use Rector\Php82\Rector\Param\AddSensitiveParameterAttributeRector;
2020
use Rector\ValueObject\PhpVersion;
@@ -33,7 +33,7 @@
3333
->withPhpVersion(PhpVersion::PHP_82)
3434
->withRules([
3535
HasHttpClientDocCommentRector::class,
36-
HasOptionsRector::class,
36+
MessageRector::class,
3737
])
3838
->withConfiguredRule(AddSensitiveParameterAttributeRector::class, [
3939
AddSensitiveParameterAttributeRector::SENSITIVE_PARAMETERS => [

rector.dist.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Guanguans\Notify\Foundation\Concerns\HasOptions;
2121
use Guanguans\Notify\Foundation\Method;
2222
use Guanguans\Notify\Foundation\Rectors\HasHttpClientDocCommentRector;
23-
use Guanguans\Notify\Foundation\Rectors\HasOptionsRector;
23+
use Guanguans\Notify\Foundation\Rectors\MessageRector;
2424
use Guanguans\Notify\Foundation\Response;
2525
use Guanguans\RectorRules\Rector\File\AddNoinspectionDocblockToFileFirstStmtRector;
2626
use Guanguans\RectorRules\Rector\FunctionLike\RenameGarbageParamNameRector;
@@ -106,7 +106,7 @@
106106
])
107107
->withRules([
108108
HasHttpClientDocCommentRector::class,
109-
HasOptionsRector::class,
109+
MessageRector::class,
110110

111111
ArraySpreadInsteadOfArrayMergeRector::class,
112112
JsonThrowOnErrorRector::class,

src/Foundation/Rectors/HasOptionsRector.php renamed to src/Foundation/Rectors/MessageRector.php

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@
3434
use Rector\PhpParser\Node\Value\ValueResolver;
3535
use Rector\PhpParser\Parser\SimplePhpParser;
3636
use Rector\Rector\AbstractRector;
37-
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
38-
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
3937

4038
/**
4139
* @internal
4240
*/
43-
final class HasOptionsRector extends AbstractRector
41+
final class MessageRector extends AbstractRector
4442
{
4543
public function __construct(
4644
private readonly DocBlockUpdater $docBlockUpdater,
@@ -49,44 +47,6 @@ public function __construct(
4947
private readonly ValueResolver $valueResolver,
5048
) {}
5149

52-
/**
53-
* @throws \Symplify\RuleDocGenerator\Exception\PoorDocumentationException
54-
* @throws \Symplify\RuleDocGenerator\Exception\ShouldNotHappenException
55-
*/
56-
public function getRuleDefinition(): RuleDefinition
57-
{
58-
return new RuleDefinition(
59-
'Has options doc comment',
60-
[
61-
new ConfiguredCodeSample(
62-
<<<'CODE_SAMPLE'
63-
class Message extends \Guanguans\Notify\Foundation\Message
64-
{
65-
protected array $defined = [
66-
'title',
67-
'content',
68-
];
69-
}
70-
CODE_SAMPLE,
71-
<<<'CODE_SAMPLE'
72-
/**
73-
* @method self title($title)
74-
* @method self content($content)
75-
*/
76-
class Message extends \Guanguans\Notify\Foundation\Message
77-
{
78-
protected array $defined = [
79-
'title',
80-
'content',
81-
];
82-
}
83-
CODE_SAMPLE,
84-
[Message::class => Message::class],
85-
),
86-
],
87-
);
88-
}
89-
9050
public function getNodeTypes(): array
9151
{
9252
return [Class_::class];

0 commit comments

Comments
 (0)