diff --git a/config/drupal-10/drupal-10.2-deprecations.php b/config/drupal-10/drupal-10.2-deprecations.php index e7c3122c..9e7d547e 100644 --- a/config/drupal-10/drupal-10.2-deprecations.php +++ b/config/drupal-10/drupal-10.2-deprecations.php @@ -3,7 +3,9 @@ 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; return static function (RectorConfig $rectorConfig): void { @@ -11,4 +13,10 @@ $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'), + ]); }; diff --git a/tests/src/Rector/Deprecation/MethodToMethodWithCheckRector/config/configured_rule.php b/tests/src/Rector/Deprecation/MethodToMethodWithCheckRector/config/configured_rule.php index 736c7322..9e886e74 100644 --- a/tests/src/Rector/Deprecation/MethodToMethodWithCheckRector/config/configured_rule.php +++ b/tests/src/Rector/Deprecation/MethodToMethodWithCheckRector/config/configured_rule.php @@ -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'), ]); }; diff --git a/tests/src/Rector/Deprecation/MethodToMethodWithCheckRector/fixture/basic.php.inc b/tests/src/Rector/Deprecation/MethodToMethodWithCheckRector/fixture/basic.php.inc index 75b9b885..c4d2afdd 100644 --- a/tests/src/Rector/Deprecation/MethodToMethodWithCheckRector/fixture/basic.php.inc +++ b/tests/src/Rector/Deprecation/MethodToMethodWithCheckRector/fixture/basic.php.inc @@ -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(); } ?> ----- @@ -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(); } ?>