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

feat: add rector rule for format_size in 10.2 #286

Merged
merged 3 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions config/drupal-10/drupal-10-all-deprecations.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
$rectorConfig->sets([
Drupal10SetList::DRUPAL_100,
Drupal10SetList::DRUPAL_101,
Drupal10SetList::DRUPAL_102,
]);

$rectorConfig->bootstrapFiles([
Expand Down
19 changes: 19 additions & 0 deletions config/drupal-10/drupal-10.2-deprecations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

use DrupalRector\Rector\Deprecation\FunctionToStaticRector;
use DrupalRector\Rector\ValueObject\FunctionToStaticConfiguration;
use Rector\Config\RectorConfig;
use Rector\Symfony\Set\SymfonyLevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([
SymfonyLevelSetList::UP_TO_SYMFONY_63,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is the same as 10.1, so we dont need this in here.

]);

// https://www.drupal.org/node/2999981
$rectorConfig->ruleWithConfiguration(FunctionToStaticRector::class, [
new FunctionToStaticConfiguration('10.2.0', 'format_size', '\Drupal\Core\StringTranslation\ByteSizeMarkup', 'create'),
]);
};
1 change: 1 addition & 0 deletions src/Set/Drupal10SetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ final class Drupal10SetList implements SetListInterface
public const DRUPAL_10 = __DIR__.'/../../config/drupal-10/drupal-10-all-deprecations.php';
public const DRUPAL_100 = __DIR__.'/../../config/drupal-10/drupal-10.0-deprecations.php';
public const DRUPAL_101 = __DIR__.'/../../config/drupal-10/drupal-10.1-deprecations.php';
public const DRUPAL_102 = __DIR__.'/../../config/drupal-10/drupal-10.2-deprecations.php';
}
2 changes: 1 addition & 1 deletion stubs/Drupal/Drupal.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
}

class Drupal {
const VERSION = '10.1.x-dev';
const VERSION = '10.2.x-dev';
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
DeprecationBase::addClass(FunctionToStaticRector::class, $rectorConfig, false, [
new FunctionToStaticConfiguration('8.1.0', 'file_directory_os_temp', 'Drupal\Component\FileSystem\FileSystem', 'getOsTemporaryDirectory'),
new FunctionToStaticConfiguration('10.1.0', 'drupal_rewrite_settings', 'Drupal\Core\Site\SettingsEditor', 'rewrite', [0 => 1, 1 => 0]),
new FunctionToStaticConfiguration('10.2.0', 'format_size', '\Drupal\Core\StringTranslation\ByteSizeMarkup', 'create'),
]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ function simple_example() {
function simple_example_os_temp() {
$x = file_directory_os_temp();
}

function simple_example_format_size() {
$size_literal = format_size(81862076662);
}
?>
-----
<?php
Expand All @@ -28,4 +32,8 @@ function simple_example() {
function simple_example_os_temp() {
$x = \Drupal\Component\FileSystem\FileSystem::getOsTemporaryDirectory();
}

function simple_example_format_size() {
$size_literal = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.2.0', fn() => format_size(81862076662), fn() => \\Drupal\Core\StringTranslation\ByteSizeMarkup::create(81862076662));
}
?>