Skip to content

Commit

Permalink
feat: add rector rule for deprecated GDToolkit resource methods and p…
Browse files Browse the repository at this point in the history
…roperties in 10.2
  • Loading branch information
timohuisman committed Jan 24, 2024
1 parent 4a2e739 commit 12d8a10
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions config/drupal-10/drupal-10.2-deprecations.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@
declare(strict_types=1);

use DrupalRector\Rector\Deprecation\FunctionToStaticRector;
use DrupalRector\Rector\Deprecation\MethodToMethodWithCheckRector;
use DrupalRector\Rector\ValueObject\FunctionToStaticConfiguration;
use DrupalRector\Rector\ValueObject\MethodToMethodWithCheckConfiguration;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector;
use Rector\Renaming\ValueObject\RenameProperty;

return static function (RectorConfig $rectorConfig): void {
// https://www.drupal.org/node/2999981
$rectorConfig->ruleWithConfiguration(FunctionToStaticRector::class, [
new FunctionToStaticConfiguration('10.2.0', 'format_size', '\Drupal\Core\StringTranslation\ByteSizeMarkup', 'create'),
]);

// https://www.drupal.org/node/3265963
$rectorConfig->ruleWithConfiguration(MethodToMethodWithCheckRector::class, [
new MethodToMethodWithCheckConfiguration('Drupal\system\Plugin\ImageToolkit\GDToolkit', 'getResource', 'getImage'),
new MethodToMethodWithCheckConfiguration('Drupal\system\Plugin\ImageToolkit\GDToolkit', 'setResource', 'setImage'),
]);

// https://www.drupal.org/node/3265963
$rectorConfig->ruleWithConfiguration(RenamePropertyRector::class, [
new RenameProperty('Drupal\system\Plugin\ImageToolkit\GDToolkit', 'resource', 'image'),
]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
DeprecationBase::addClass(MethodToMethodWithCheckRector::class, $rectorConfig, true, [
new MethodToMethodWithCheckConfiguration('Drupal\Core\Session\MetadataBag', 'clearCsrfTokenSeed', 'stampNew'),
new MethodToMethodWithCheckConfiguration('Drupal\Core\Entity\EntityInterface', 'urlInfo', 'toUrl'),
new MethodToMethodWithCheckConfiguration('Drupal\system\Plugin\ImageToolkit\GDToolkit', 'getResource', 'getImage'),
new MethodToMethodWithCheckConfiguration('Drupal\system\Plugin\ImageToolkit\GDToolkit', 'setResource', 'setImage'),
]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ function simple_example() {
/** @var \Drupal\Core\Entity\EntityInterface $untranslated_entity */
$untranslated_entity = \Drupal::entityTypeManager()->getStorage('node')->load(123);
$form_state->setRedirectUrl($untranslated_entity->urlInfo('canonical'));

$toolkit = new \Drupal\system\Plugin\ImageToolkit\GDToolkit;
$toolkit->getResource();
$toolkit->setResource();
}
?>
-----
Expand All @@ -19,5 +23,9 @@ function simple_example() {
/** @var \Drupal\Core\Entity\EntityInterface $untranslated_entity */
$untranslated_entity = \Drupal::entityTypeManager()->getStorage('node')->load(123);
$form_state->setRedirectUrl($untranslated_entity->toUrl('canonical'));

$toolkit = new \Drupal\system\Plugin\ImageToolkit\GDToolkit;
$toolkit->getImage();
$toolkit->setImage();
}
?>

0 comments on commit 12d8a10

Please sign in to comment.