Skip to content

Commit

Permalink
Merge pull request #299 from palantirnet/feature/fix-codesample-and-docs
Browse files Browse the repository at this point in the history
doc: Fix doc for AnnotationToAttributeRector and generate new docs.
  • Loading branch information
agentrickard authored Mar 29, 2024
2 parents 712c84f + c0f67f4 commit f74538a
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 6 deletions.
60 changes: 57 additions & 3 deletions docs/rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,56 @@
# 52 Rules Overview
# 54 Rules Overview

<br>

## Categories

- [Drupal10](#drupal10) (2)
- [Drupal10](#drupal10) (3)

- [Drupal8](#drupal8) (18)

- [Drupal9](#drupal9) (26)

- [DrupalRector](#drupalrector) (6)
- [DrupalRector](#drupalrector) (7)

<br>

## Drupal10

### AnnotationToAttributeRector

Change annotations with value to attribute

:wrench: **configure it!**

- class: [`DrupalRector\Drupal10\Rector\Deprecation\AnnotationToAttributeRector`](../src/Drupal10/Rector/Deprecation/AnnotationToAttributeRector.php)

```diff
namespace Drupal\Core\Action\Plugin\Action;

+use Drupal\Core\Action\Plugin\Action\Derivative\EntityPublishedActionDeriver;
+use Drupal\Core\Action\Attribute\Action;
use Drupal\Core\Session\AccountInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
* Publishes an entity.
- *
- * @Action(
- * id = "entity:publish_action",
- * action_label = @Translation("Publish"),
- * deriver = "Drupal\Core\Action\Plugin\Action\Derivative\EntityPublishedActionDeriver",
- * )
*/
+#[Action(
+ id: 'entity:publish_action',
+ action_label: new TranslatableMarkup('Publish'),
+ deriver: EntityPublishedActionDeriver::class
+)]
class PublishAction extends EntityActionBase {
```

<br>

### SystemTimeZonesRector

Fixes deprecated `system_time_zones()` calls
Expand Down Expand Up @@ -843,6 +878,25 @@ Fixes deprecated `user_password()` calls

## DrupalRector

### ClassConstantToClassConstantRector

Fixes deprecated class contant use, used in Drupal 9.1 deprecations

:wrench: **configure it!**

- class: [`DrupalRector\Rector\Deprecation\ClassConstantToClassConstantRector`](../src/Rector/Deprecation/ClassConstantToClassConstantRector.php)

```diff
-$value = Symfony\Cmf\Component\Routing\RouteObjectInterface::ROUTE_NAME;
-$value2 = Symfony\Cmf\Component\Routing\RouteObjectInterface::ROUTE_OBJECT;
-$value3 = Symfony\Cmf\Component\Routing\RouteObjectInterface::CONTROLLER_NAME;
+$value = \Drupal\Core\Routing\RouteObjectInterface::ROUTE_NAME;
+$value2 = \Drupal\Core\Routing\RouteObjectInterface::ROUTE_OBJECT;
+$value3 = \Drupal\Core\Routing\RouteObjectInterface::CONTROLLER_NAME;
```

<br>

### ConstantToClassConstantRector

Fixes deprecated contant use, used in Drupal 8 and 9 deprecations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use Rector\PhpAttribute\AnnotationToAttributeMapper;
use Rector\ValueObject\PhpVersion;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

/**
Expand Down Expand Up @@ -80,7 +80,7 @@ public function configure(array $configuration): void

public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition('Change annotations with value to attribute', [new CodeSample(<<<'CODE_SAMPLE'
return new RuleDefinition('Change annotations with value to attribute', [new ConfiguredCodeSample(<<<'CODE_SAMPLE'
namespace Drupal\Core\Action\Plugin\Action;
Expand Down Expand Up @@ -116,7 +116,10 @@ class PublishAction extends EntityActionBase {
)]
class PublishAction extends EntityActionBase {
CODE_SAMPLE
)]);
,
[
new AnnotationToAttributeConfiguration('10.2.0', '12.0.0', 'Action', 'Drupal\Core\Action\Attribute\Action'),
])]);
}

/**
Expand Down

0 comments on commit f74538a

Please sign in to comment.