Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New rector (9.1): \Drupal\Component\Utility\Bytes::toInt() is deprecated #279

Merged
merged 3 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}