Skip to content

Commit f74538a

Browse files
authored
Merge pull request #299 from palantirnet/feature/fix-codesample-and-docs
doc: Fix doc for AnnotationToAttributeRector and generate new docs.
2 parents 712c84f + c0f67f4 commit f74538a

File tree

2 files changed

+63
-6
lines changed

2 files changed

+63
-6
lines changed

docs/rules_overview.md

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,56 @@
1-
# 52 Rules Overview
1+
# 54 Rules Overview
22

33
<br>
44

55
## Categories
66

7-
- [Drupal10](#drupal10) (2)
7+
- [Drupal10](#drupal10) (3)
88

99
- [Drupal8](#drupal8) (18)
1010

1111
- [Drupal9](#drupal9) (26)
1212

13-
- [DrupalRector](#drupalrector) (6)
13+
- [DrupalRector](#drupalrector) (7)
1414

1515
<br>
1616

1717
## Drupal10
1818

19+
### AnnotationToAttributeRector
20+
21+
Change annotations with value to attribute
22+
23+
:wrench: **configure it!**
24+
25+
- class: [`DrupalRector\Drupal10\Rector\Deprecation\AnnotationToAttributeRector`](../src/Drupal10/Rector/Deprecation/AnnotationToAttributeRector.php)
26+
27+
```diff
28+
namespace Drupal\Core\Action\Plugin\Action;
29+
30+
+use Drupal\Core\Action\Plugin\Action\Derivative\EntityPublishedActionDeriver;
31+
+use Drupal\Core\Action\Attribute\Action;
32+
use Drupal\Core\Session\AccountInterface;
33+
+use Drupal\Core\StringTranslation\TranslatableMarkup;
34+
35+
/**
36+
* Publishes an entity.
37+
- *
38+
- * @Action(
39+
- * id = "entity:publish_action",
40+
- * action_label = @Translation("Publish"),
41+
- * deriver = "Drupal\Core\Action\Plugin\Action\Derivative\EntityPublishedActionDeriver",
42+
- * )
43+
*/
44+
+#[Action(
45+
+ id: 'entity:publish_action',
46+
+ action_label: new TranslatableMarkup('Publish'),
47+
+ deriver: EntityPublishedActionDeriver::class
48+
+)]
49+
class PublishAction extends EntityActionBase {
50+
```
51+
52+
<br>
53+
1954
### SystemTimeZonesRector
2055

2156
Fixes deprecated `system_time_zones()` calls
@@ -843,6 +878,25 @@ Fixes deprecated `user_password()` calls
843878

844879
## DrupalRector
845880

881+
### ClassConstantToClassConstantRector
882+
883+
Fixes deprecated class contant use, used in Drupal 9.1 deprecations
884+
885+
:wrench: **configure it!**
886+
887+
- class: [`DrupalRector\Rector\Deprecation\ClassConstantToClassConstantRector`](../src/Rector/Deprecation/ClassConstantToClassConstantRector.php)
888+
889+
```diff
890+
-$value = Symfony\Cmf\Component\Routing\RouteObjectInterface::ROUTE_NAME;
891+
-$value2 = Symfony\Cmf\Component\Routing\RouteObjectInterface::ROUTE_OBJECT;
892+
-$value3 = Symfony\Cmf\Component\Routing\RouteObjectInterface::CONTROLLER_NAME;
893+
+$value = \Drupal\Core\Routing\RouteObjectInterface::ROUTE_NAME;
894+
+$value2 = \Drupal\Core\Routing\RouteObjectInterface::ROUTE_OBJECT;
895+
+$value3 = \Drupal\Core\Routing\RouteObjectInterface::CONTROLLER_NAME;
896+
```
897+
898+
<br>
899+
846900
### ConstantToClassConstantRector
847901

848902
Fixes deprecated contant use, used in Drupal 8 and 9 deprecations

src/Drupal10/Rector/Deprecation/AnnotationToAttributeRector.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
use Rector\PhpAttribute\AnnotationToAttributeMapper;
2828
use Rector\ValueObject\PhpVersion;
2929
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
30-
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
30+
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
3131
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
3232

3333
/**
@@ -80,7 +80,7 @@ public function configure(array $configuration): void
8080

8181
public function getRuleDefinition(): RuleDefinition
8282
{
83-
return new RuleDefinition('Change annotations with value to attribute', [new CodeSample(<<<'CODE_SAMPLE'
83+
return new RuleDefinition('Change annotations with value to attribute', [new ConfiguredCodeSample(<<<'CODE_SAMPLE'
8484
8585
namespace Drupal\Core\Action\Plugin\Action;
8686
@@ -116,7 +116,10 @@ class PublishAction extends EntityActionBase {
116116
)]
117117
class PublishAction extends EntityActionBase {
118118
CODE_SAMPLE
119-
)]);
119+
,
120+
[
121+
new AnnotationToAttributeConfiguration('10.2.0', '12.0.0', 'Action', 'Drupal\Core\Action\Attribute\Action'),
122+
])]);
120123
}
121124

122125
/**

0 commit comments

Comments
 (0)