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 (10.3): Add rule for file_icon_class() and file_icon_map() #304

Merged
merged 1 commit into from
Jun 7, 2024
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
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 @@ -10,6 +10,7 @@
Drupal10SetList::DRUPAL_100,
Drupal10SetList::DRUPAL_101,
Drupal10SetList::DRUPAL_102,
Drupal10SetList::DRUPAL_103,
]);

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

declare(strict_types=1);

use DrupalRector\Rector\Deprecation\FunctionToStaticRector;
use DrupalRector\Rector\ValueObject\FunctionToStaticConfiguration;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
// https://www.drupal.org/node/3411269 file_icon_class, file_icon_map
$rectorConfig->ruleWithConfiguration(FunctionToStaticRector::class, [
new FunctionToStaticConfiguration('10.3.0', 'file_icon_class', 'Drupal\file\IconMimeTypes', 'getIconClass'),
new FunctionToStaticConfiguration('10.3.0', 'file_icon_map', 'Drupal\file\IconMimeTypes', 'getGenericMimeType'),
]);
};
1 change: 1 addition & 0 deletions src/Set/Drupal10SetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ final class Drupal10SetList implements SetListInterface
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';
public const DRUPAL_103 = __DIR__.'/../../config/drupal-10/drupal-10.3-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.2.x-dev';
const VERSION = '10.99.x-dev';
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
new FunctionToServiceConfiguration('9.3.0', 'file_move', 'file.repository', 'move'),
new FunctionToServiceConfiguration('9.3.0', 'file_save_data', 'file.repository', 'writeData'),
new FunctionToServiceConfiguration('10.1.0', 'drupal_theme_rebuild', 'theme.registry', 'reset'),
new FunctionToServiceConfiguration('10.2.0', '_drupal_flush_css_js', 'asset.query_string', 'reset'),
]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
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'),
new FunctionToStaticConfiguration('10.3.0', 'file_icon_class', 'Drupal\file\IconMimeTypes', 'getIconClass'),
new FunctionToStaticConfiguration('10.3.0', 'file_icon_map', 'Drupal\file\IconMimeTypes', 'getGenericMimeType'),
]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ function simple_example_os_temp() {
function simple_example_format_size() {
$size_literal = format_size(81862076662);
}

function simple_example_file_icon_class() {
$mime_type = 'application/pdf';
$classes = [
'file',
'file--' . file_icon_class($mime_type),
];

$generic_mime = file_icon_map($mime_type);
}
?>
-----
<?php
Expand All @@ -36,4 +46,14 @@ function simple_example_os_temp() {
function simple_example_format_size() {
$size_literal = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.2.0', fn() => \Drupal\Core\StringTranslation\ByteSizeMarkup::create(81862076662), fn() => format_size(81862076662));
}

function simple_example_file_icon_class() {
$mime_type = 'application/pdf';
$classes = [
'file',
'file--' . \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.3.0', fn() => \Drupal\file\IconMimeTypes::getIconClass($mime_type), fn() => file_icon_class($mime_type)),
];

$generic_mime = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.3.0', fn() => \Drupal\file\IconMimeTypes::getGenericMimeType($mime_type), fn() => file_icon_map($mime_type));
}
?>
Loading