Skip to content

Commit

Permalink
Merge pull request #279 from palantirnet/feature/rector-toInt-to-toNu…
Browse files Browse the repository at this point in the history
…mber

New rector (9.1): \Drupal\Component\Utility\Bytes::toInt() is deprecated
  • Loading branch information
agentrickard authored Dec 27, 2023
2 parents f12360f + 17038a5 commit 1d85602
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions config/drupal-9/drupal-9.1-deprecations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -95,4 +97,14 @@
$rectorConfig->rule(GetRawContentRector::class);
$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',
'toInt',
'Drupal\Component\Utility\Bytes',
'toNumber'
),
]);
};
5 changes: 5 additions & 0 deletions fixtures/d9/rector_examples/rector_examples.module
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Drupal\Component\Utility\Bytes;
function extension_paths() {
drupal_get_path('module', 'node');
drupal_get_path('theme', 'seven');
Expand All @@ -13,3 +14,7 @@ function rector_examples_with_render() {
$build = [];
$output = render($build);
}

function rector_utility_bytes_to_int() {
$int = Bytes::toInt("15");
}
6 changes: 6 additions & 0 deletions fixtures/d9/rector_examples_updated/rector_examples.module
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Drupal\Component\Utility\Bytes;
function extension_paths() {
\Drupal::service('extension.list.module')->getPath('node');
\Drupal::service('extension.list.theme')->getPath('seven');
Expand All @@ -13,3 +14,8 @@ function rector_examples_with_render() {
$build = [];
$output = \Drupal::service('renderer')->render($build);
}

function rector_utility_bytes_to_int() {
$int = Bytes::toNumber("15");
}

0 comments on commit 1d85602

Please sign in to comment.