From 4919535569dc4a6287039644e44223988119792e Mon Sep 17 00:00:00 2001 From: bjorn Date: Sat, 23 Dec 2023 12:18:13 +0100 Subject: [PATCH 1/3] New rector: \Drupal\Component\Utility\Bytes::toInt() is deprecated \Drupal\Component\Utility\Bytes::toInt() is deprecated in favor of \Drupal\Component\Utility\Bytes::toNumber() https://www.drupal.org/node/3162663 --- config/drupal-9/drupal-9.1-deprecations.php | 11 +++++++++++ fixtures/d9/rector_examples/rector_examples.module | 4 ++++ .../d9/rector_examples_updated/rector_examples.module | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/config/drupal-9/drupal-9.1-deprecations.php b/config/drupal-9/drupal-9.1-deprecations.php index c62eee8f..fd8df5a8 100644 --- a/config/drupal-9/drupal-9.1-deprecations.php +++ b/config/drupal-9/drupal-9.1-deprecations.php @@ -18,6 +18,8 @@ use DrupalRector\Services\AddCommentService; use Rector\Config\RectorConfig; use Rector\PHPUnit\Set\PHPUnitSetList; +use Rector\Renaming\Rector\StaticCall\RenameStaticMethodRector; +use Rector\Renaming\ValueObject\RenameStaticMethod; return static function (RectorConfig $rectorConfig): void { $rectorConfig->singleton(AddCommentService::class, function () { @@ -95,4 +97,13 @@ $rectorConfig->rule(GetRawContentRector::class); $rectorConfig->rule(GetAllOptionsRector::class); $rectorConfig->rule(UserPasswordRector::class); + + $rectorConfig->ruleWithConfiguration(RenameStaticMethodRector::class, [ + new RenameStaticMethod( + 'Drupal\Component\Utility\Bytes', + 'toInt', + 'Drupal\Component\Utility\Bytes', + 'toNumber' + ), + ]); }; diff --git a/fixtures/d9/rector_examples/rector_examples.module b/fixtures/d9/rector_examples/rector_examples.module index 937e4b4f..f629deb8 100644 --- a/fixtures/d9/rector_examples/rector_examples.module +++ b/fixtures/d9/rector_examples/rector_examples.module @@ -13,3 +13,7 @@ function rector_examples_with_render() { $build = []; $output = render($build); } + +function rector_utility_bytes_to_int() { + $int = \Drupal\Component\Utility\Bytes::toInt("15"); +} diff --git a/fixtures/d9/rector_examples_updated/rector_examples.module b/fixtures/d9/rector_examples_updated/rector_examples.module index 6e116901..068e6be1 100644 --- a/fixtures/d9/rector_examples_updated/rector_examples.module +++ b/fixtures/d9/rector_examples_updated/rector_examples.module @@ -13,3 +13,8 @@ function rector_examples_with_render() { $build = []; $output = \Drupal::service('renderer')->render($build); } + +function rector_utility_bytes_to_int() { + $int = \Drupal\Component\Utility\Bytes::toNumber("15"); +} + From 781039bc4c2f44235e1067bc32a8e6a98a0e390f Mon Sep 17 00:00:00 2001 From: bjorn Date: Sat, 23 Dec 2023 12:20:22 +0100 Subject: [PATCH 2/3] Functinoal test confuse me. Namespace included. --- fixtures/d9/rector_examples/rector_examples.module | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fixtures/d9/rector_examples/rector_examples.module b/fixtures/d9/rector_examples/rector_examples.module index f629deb8..61738d50 100644 --- a/fixtures/d9/rector_examples/rector_examples.module +++ b/fixtures/d9/rector_examples/rector_examples.module @@ -1,5 +1,6 @@ Date: Sat, 23 Dec 2023 12:22:23 +0100 Subject: [PATCH 3/3] Functinoal test confuse me. Namespace included. Also add change record reference --- config/drupal-9/drupal-9.1-deprecations.php | 1 + fixtures/d9/rector_examples_updated/rector_examples.module | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config/drupal-9/drupal-9.1-deprecations.php b/config/drupal-9/drupal-9.1-deprecations.php index fd8df5a8..8a6d1999 100644 --- a/config/drupal-9/drupal-9.1-deprecations.php +++ b/config/drupal-9/drupal-9.1-deprecations.php @@ -98,6 +98,7 @@ $rectorConfig->rule(GetAllOptionsRector::class); $rectorConfig->rule(UserPasswordRector::class); + // Change record: https://www.drupal.org/node/3162663 $rectorConfig->ruleWithConfiguration(RenameStaticMethodRector::class, [ new RenameStaticMethod( 'Drupal\Component\Utility\Bytes', diff --git a/fixtures/d9/rector_examples_updated/rector_examples.module b/fixtures/d9/rector_examples_updated/rector_examples.module index 068e6be1..dc068537 100644 --- a/fixtures/d9/rector_examples_updated/rector_examples.module +++ b/fixtures/d9/rector_examples_updated/rector_examples.module @@ -1,5 +1,6 @@ getPath('node'); \Drupal::service('extension.list.theme')->getPath('seven'); @@ -15,6 +16,6 @@ function rector_examples_with_render() { } function rector_utility_bytes_to_int() { - $int = \Drupal\Component\Utility\Bytes::toNumber("15"); + $int = Bytes::toNumber("15"); }