diff --git a/.github/workflows/functional_test__rector_examples.yml b/.github/workflows/functional_test__rector_examples.yml
index 18f97385..2402ecf3 100644
--- a/.github/workflows/functional_test__rector_examples.yml
+++ b/.github/workflows/functional_test__rector_examples.yml
@@ -15,6 +15,7 @@ jobs:
run_functional_test:
name: Functional Test | PHP ${{ matrix.php-version }} | Drupal ${{ matrix.drupal }}"
strategy:
+ fail-fast: false
matrix:
include:
- php-version: "7.4"
diff --git a/composer.json b/composer.json
index a1f6857e..2bb3d2ea 100644
--- a/composer.json
+++ b/composer.json
@@ -10,7 +10,7 @@
"ast"
],
"require": {
- "rector/rector": "~0.18.0",
+ "rector/rector": "~0.19.0",
"webflo/drupal-finder": "^1.2"
},
"license": "MIT",
diff --git a/config/drupal-10/drupal-10.2-deprecations.php b/config/drupal-10/drupal-10.2-deprecations.php
index 7b3b63e5..87fd2f6f 100644
--- a/config/drupal-10/drupal-10.2-deprecations.php
+++ b/config/drupal-10/drupal-10.2-deprecations.php
@@ -3,9 +3,16 @@
declare(strict_types=1);
use DrupalRector\Drupal10\Rector\Deprecation\ActionAnnotationToAttributeRector;
+use DrupalRector\Rector\Deprecation\FunctionToStaticRector;
+use DrupalRector\Rector\ValueObject\FunctionToStaticConfiguration;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
- // @see https://www.drupal.org/node/3395575
+ // https://www.drupal.org/node/3395575
$rectorConfig->rule(ActionAnnotationToAttributeRector::class);
+
+ // https://www.drupal.org/node/2999981
+ $rectorConfig->ruleWithConfiguration(FunctionToStaticRector::class, [
+ new FunctionToStaticConfiguration('10.2.0', 'format_size', '\Drupal\Core\StringTranslation\ByteSizeMarkup', 'create'),
+ ]);
};
diff --git a/config/drupal-8/drupal-8.2-deprecations.php b/config/drupal-8/drupal-8.2-deprecations.php
index 7081b39b..439256be 100644
--- a/config/drupal-8/drupal-8.2-deprecations.php
+++ b/config/drupal-8/drupal-8.2-deprecations.php
@@ -12,7 +12,7 @@
});
// https://www.drupal.org/node/2802569
$rectorConfig->ruleWithConfiguration(FunctionToStaticRector::class, [
- new \DrupalRector\Rector\ValueObject\FunctionToStaticConfiguration(
+ new DrupalRector\Rector\ValueObject\FunctionToStaticConfiguration(
'8.2.0',
'file_directory_os_temp',
'Drupal\Component\FileSystem\FileSystem',
diff --git a/config/drupal-8/drupal-8.6-deprecations.php b/config/drupal-8/drupal-8.6-deprecations.php
index dffe011b..34a09607 100644
--- a/config/drupal-8/drupal-8.6-deprecations.php
+++ b/config/drupal-8/drupal-8.6-deprecations.php
@@ -10,7 +10,7 @@
$rectorConfig->singleton(AddCommentService::class, function () {
return new AddCommentService();
});
- $rectorConfig->ruleWithConfiguration(\DrupalRector\Drupal8\Rector\Deprecation\StaticToFunctionRector::class, [
+ $rectorConfig->ruleWithConfiguration(DrupalRector\Drupal8\Rector\Deprecation\StaticToFunctionRector::class, [
// https://www.drupal.org/node/2850048
new StaticToFunctionConfiguration('Drupal\Component\Utility\Unicode', 'strlen', 'mb_strlen'),
// https://www.drupal.org/node/2850048
diff --git a/config/drupal-9/drupal-9.1-deprecations.php b/config/drupal-9/drupal-9.1-deprecations.php
index c62eee8f..a2f5125c 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 () {
@@ -40,7 +42,7 @@
$rectorConfig->rule(AssertNoFieldByNameRector::class);
$rectorConfig->rule(AssertFieldByIdRector::class);
- $rectorConfig->ruleWithConfiguration(\DrupalRector\Drupal9\Rector\Deprecation\AssertLegacyTraitRector::class, [
+ $rectorConfig->ruleWithConfiguration(DrupalRector\Drupal9\Rector\Deprecation\AssertLegacyTraitRector::class, [
new AssertLegacyTraitConfiguration('assertLinkByHref', 'linkByHrefExists'),
new AssertLegacyTraitConfiguration('assertLink', 'linkExists'),
new AssertLegacyTraitConfiguration('assertNoEscaped', 'assertNoEscaped'),
@@ -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'
+ ),
+ ]);
};
diff --git a/config/drupal-9/drupal-9.3-deprecations.php b/config/drupal-9/drupal-9.3-deprecations.php
index 5289e421..6b6166a3 100644
--- a/config/drupal-9/drupal-9.3-deprecations.php
+++ b/config/drupal-9/drupal-9.3-deprecations.php
@@ -2,6 +2,8 @@
declare(strict_types=1);
+use DrupalRector\Drupal8\Rector\Deprecation\ConstantToClassConstantRector;
+use DrupalRector\Drupal8\Rector\ValueObject\ConstantToClassConfiguration;
use DrupalRector\Drupal9\Rector\Deprecation\ExtensionPathRector;
use DrupalRector\Drupal9\Rector\Deprecation\FileBuildUriRector;
use DrupalRector\Drupal9\Rector\Deprecation\FunctionToEntityTypeStorageMethod;
@@ -31,9 +33,9 @@
]);
// Change record: https://www.drupal.org/node/2940031
- $rectorConfig->rule(\DrupalRector\Drupal9\Rector\Deprecation\FileCreateUrlRector::class);
- $rectorConfig->rule(\DrupalRector\Drupal9\Rector\Deprecation\FileUrlTransformRelativeRector::class);
- $rectorConfig->rule(\DrupalRector\Drupal9\Rector\Deprecation\FromUriRector::class);
+ $rectorConfig->rule(DrupalRector\Drupal9\Rector\Deprecation\FileCreateUrlRector::class);
+ $rectorConfig->rule(DrupalRector\Drupal9\Rector\Deprecation\FileUrlTransformRelativeRector::class);
+ $rectorConfig->rule(DrupalRector\Drupal9\Rector\Deprecation\FromUriRector::class);
// Change record: https://www.drupal.org/node/3223520
$rectorConfig->ruleWithConfiguration(FunctionToServiceRector::class, [
@@ -66,4 +68,13 @@
new FunctionToFirstArgMethodConfiguration('taxonomy_term_uri', 'toUrl'),
new FunctionToFirstArgMethodConfiguration('taxonomy_term_title', 'label'),
]);
+
+ // Change record: https://www.drupal.org/node/3022147
+ $rectorConfig->ruleWithConfiguration(ConstantToClassConstantRector::class, [
+ new ConstantToClassConfiguration(
+ 'FILE_STATUS_PERMANENT',
+ 'Drupal\file\FileInterface',
+ 'STATUS_PERMANENT',
+ ),
+ ]);
};
diff --git a/config/drupal-9/drupal-9.4-deprecations.php b/config/drupal-9/drupal-9.4-deprecations.php
index 16d66f83..bff0e627 100644
--- a/config/drupal-9/drupal-9.4-deprecations.php
+++ b/config/drupal-9/drupal-9.4-deprecations.php
@@ -4,5 +4,5 @@
return static function (Rector\Config\RectorConfig $rectorConfig): void {
// Change record https://www.drupal.org/node/3220952
- $rectorConfig->rule(\DrupalRector\Drupal9\Rector\Deprecation\ModuleLoadInstallRector::class);
+ $rectorConfig->rule(DrupalRector\Drupal9\Rector\Deprecation\ModuleLoadRector::class);
};
diff --git a/docs/rules_overview.md b/docs/rules_overview.md
index 251bb3b1..c6d108cd 100644
--- a/docs/rules_overview.md
+++ b/docs/rules_overview.md
@@ -715,15 +715,22 @@ Fixes deprecated `AssertLegacyTrait::getRawContent()` calls
-### ModuleLoadInstallRector
+### ModuleLoadRector
Fixes deprecated `module_load_install()` calls
-- class: [`DrupalRector\Drupal9\Rector\Deprecation\ModuleLoadInstallRector`](../src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector.php)
+- class: [`DrupalRector\Drupal9\Rector\Deprecation\ModuleLoadRector`](../src/Drupal9/Rector/Deprecation/ModuleLoadRector.php)
```diff
-module_load_install('example');
-+\Drupal\Core\Extension\ModuleHandler::loadInclude('example', 'install');
++\Drupal::moduleHandler()->loadInclude('example', 'install');
+ $type = 'install';
+ $module = 'example';
+ $name = 'name';
+-module_load_include($type, $module, $name);
+-module_load_include($type, $module);
++\Drupal::moduleHandler()->loadInclude($module, $type, $name);
++\Drupal::moduleHandler()->loadInclude($module, $type);
```
@@ -862,10 +869,10 @@ Remove DeprecationHelper calls for versions before configured minimum requiremen
```diff
$settings = [];
$filename = 'simple_filename.yaml';
--DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => old_function(), fn() => new_function());
--DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => drupal_rewrite_settings($settings, $filename), fn() => SettingsEditor::rewrite($filename, $settings));
+-DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => new_function(), fn() => old_function());
+-DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => SettingsEditor::rewrite($filename, $settings), fn() => drupal_rewrite_settings($settings, $filename));
+drupal_rewrite_settings($settings, $filename);
- DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.1.0', fn() => old_function(), fn() => new_function());
+ DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.1.0', fn() => new_function(), fn() => old_function());
```
diff --git a/fixtures/d10/rector_examples_updated/function_to_static_call.php b/fixtures/d10/rector_examples_updated/function_to_static_call.php
index 6e316785..91a260ae 100644
--- a/fixtures/d10/rector_examples_updated/function_to_static_call.php
+++ b/fixtures/d10/rector_examples_updated/function_to_static_call.php
@@ -5,5 +5,5 @@
function simple_example() {
$settings = [];
$filename = 'simple_filename.yaml';
- DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => drupal_rewrite_settings($settings, $filename), fn() => SettingsEditor::rewrite($filename, $settings));
+ DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => SettingsEditor::rewrite($filename, $settings), fn() => drupal_rewrite_settings($settings, $filename));
}
diff --git a/fixtures/d9/rector_examples/rector_examples.module b/fixtures/d9/rector_examples/rector_examples.module
index 937e4b4f..61738d50 100644
--- a/fixtures/d9/rector_examples/rector_examples.module
+++ b/fixtures/d9/rector_examples/rector_examples.module
@@ -1,5 +1,6 @@
getPath('node');
\Drupal::service('extension.list.theme')->getPath('seven');
@@ -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");
+}
+
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 1ef10e01..e7a5893b 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -109,3 +109,11 @@ parameters:
message: "#^Call to an undefined method PHPStan\\\\Type\\\\Type\\:\\:getValue\\(\\)\\.$#"
count: 1
path: src/Drupal9/Rector/Deprecation/ExtensionPathRector.php
+
+ -
+ message: """
+ #^Fetching deprecated class constant REMOVE_NODE of class PhpParser\\\\NodeTraverser\\:
+ Use NodeVisitor\\:\\:REMOVE_NODE instead\\.$#
+ """
+ count: 1
+ path: src/Drupal9/Rector/Deprecation/PassRector.php
diff --git a/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php b/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php
index e154e402..8299e6b2 100644
--- a/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php
+++ b/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php
@@ -9,7 +9,7 @@
use DrupalRector\Rector\ValueObject\DrupalIntroducedVersionConfiguration;
use PhpParser\Node;
use PhpParser\Node\Expr\ConstFetch;
-use Rector\Core\PhpParser\Node\Value\ValueResolver;
+use Rector\PhpParser\Node\Value\ValueResolver;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -21,7 +21,7 @@ class SystemTimeZonesRector extends AbstractDrupalCoreRector
protected array $configuration;
/**
- * @var \Rector\Core\PhpParser\Node\Value\ValueResolver
+ * @var ValueResolver
*/
private ValueResolver $valueResolver;
diff --git a/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector.php b/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector.php
index a8a6bb0e..3ee74eb7 100644
--- a/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector.php
+++ b/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector.php
@@ -6,8 +6,8 @@
use DrupalRector\Drupal8\Rector\ValueObject\ConstantToClassConfiguration;
use PhpParser\Node;
-use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal8/Rector/Deprecation/DBRector.php b/src/Drupal8/Rector/Deprecation/DBRector.php
index c44a85cd..feb8aeb7 100644
--- a/src/Drupal8/Rector/Deprecation/DBRector.php
+++ b/src/Drupal8/Rector/Deprecation/DBRector.php
@@ -9,8 +9,8 @@
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\MethodCall;
-use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -61,7 +61,7 @@ class DBRector extends AbstractRector implements ConfigurableRectorInterface
private array $configuration;
/**
- * @var \DrupalRector\Services\AddCommentService
+ * @var AddCommentService
*/
private AddCommentService $commentService;
diff --git a/src/Drupal8/Rector/Deprecation/DrupalLRector.php b/src/Drupal8/Rector/Deprecation/DrupalLRector.php
index 3852086f..ce176653 100644
--- a/src/Drupal8/Rector/Deprecation/DrupalLRector.php
+++ b/src/Drupal8/Rector/Deprecation/DrupalLRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal8\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php b/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php
index de2c0b60..43726353 100644
--- a/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php
+++ b/src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php
@@ -6,8 +6,8 @@
use DrupalRector\Drupal8\Rector\ValueObject\DrupalServiceRenameConfiguration;
use PhpParser\Node;
-use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php b/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php
index a7c18578..4d3addba 100644
--- a/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php
+++ b/src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php
@@ -11,8 +11,8 @@
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
-use Rector\Core\Rector\AbstractRector;
use Rector\NodeTypeResolver\Node\AttributeKey;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -36,7 +36,7 @@ final class DrupalSetMessageRector extends AbstractRector
use FindParentByTypeTrait;
/**
- * @var \DrupalRector\Services\AddCommentService
+ * @var AddCommentService
*/
private AddCommentService $commentService;
diff --git a/src/Drupal8/Rector/Deprecation/DrupalURLRector.php b/src/Drupal8/Rector/Deprecation/DrupalURLRector.php
index d560e90b..59c799f1 100644
--- a/src/Drupal8/Rector/Deprecation/DrupalURLRector.php
+++ b/src/Drupal8/Rector/Deprecation/DrupalURLRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal8\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal8/Rector/Deprecation/EntityCreateRector.php b/src/Drupal8/Rector/Deprecation/EntityCreateRector.php
index 6dec3a4a..8570c6f9 100644
--- a/src/Drupal8/Rector/Deprecation/EntityCreateRector.php
+++ b/src/Drupal8/Rector/Deprecation/EntityCreateRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal8\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal8/Rector/Deprecation/EntityDeleteMultipleRector.php b/src/Drupal8/Rector/Deprecation/EntityDeleteMultipleRector.php
index 64205e96..18cbf65b 100644
--- a/src/Drupal8/Rector/Deprecation/EntityDeleteMultipleRector.php
+++ b/src/Drupal8/Rector/Deprecation/EntityDeleteMultipleRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal8\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php b/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php
index 69cd36ca..31b85b90 100644
--- a/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php
+++ b/src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php
@@ -6,7 +6,7 @@
use DrupalRector\Services\AddCommentService;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -24,7 +24,7 @@
final class EntityInterfaceLinkRector extends AbstractRector
{
/**
- * @var \DrupalRector\Services\AddCommentService
+ * @var AddCommentService
*/
private AddCommentService $commentService;
diff --git a/src/Drupal8/Rector/Deprecation/EntityLoadRector.php b/src/Drupal8/Rector/Deprecation/EntityLoadRector.php
index 20ca3e8d..66e9bcc2 100644
--- a/src/Drupal8/Rector/Deprecation/EntityLoadRector.php
+++ b/src/Drupal8/Rector/Deprecation/EntityLoadRector.php
@@ -7,8 +7,8 @@
use DrupalRector\Drupal8\Rector\ValueObject\EntityLoadConfiguration;
use DrupalRector\Services\AddCommentService;
use PhpParser\Node;
-use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -32,7 +32,7 @@ final class EntityLoadRector extends AbstractRector implements ConfigurableRecto
protected array $entityTypes;
/**
- * @var \DrupalRector\Services\AddCommentService
+ * @var AddCommentService
*/
private AddCommentService $commentService;
@@ -169,9 +169,15 @@ public function refactor(Node $node): ?Node
$resetCache_method_name = new Node\Identifier('resetCache');
+ if (!class_exists('\PhpParser\Node\ArrayItem')) {
+ $arrayItems = [new Node\Expr\ArrayItem($entity_id->value)];
+ } else {
+ $arrayItems = [new \PhpParser\Node\ArrayItem($entity_id->value)];
+ }
+
$reset_args = [
// This creates a new argument that wraps the entity ID in an array.
- new Node\Arg(new Node\Expr\Array_([new Node\Expr\ArrayItem($entity_id->value)])),
+ new Node\Arg(new Node\Expr\Array_($arrayItems)),
];
$entity_load_reset_node = new Node\Expr\MethodCall($getStorage_node,
diff --git a/src/Drupal8/Rector/Deprecation/EntityManagerRector.php b/src/Drupal8/Rector/Deprecation/EntityManagerRector.php
index 37931121..9b26d5b6 100644
--- a/src/Drupal8/Rector/Deprecation/EntityManagerRector.php
+++ b/src/Drupal8/Rector/Deprecation/EntityManagerRector.php
@@ -7,10 +7,10 @@
use DrupalRector\Services\AddCommentService;
use PhpParser\Node;
use PHPStan\Analyser\Scope;
-use Rector\Core\Exception\ShouldNotHappenException;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Exception\ShouldNotHappenException;
use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -41,7 +41,7 @@ final class EntityManagerRector extends AbstractRector
protected $parentClassScopeResolver;
/**
- * @var \DrupalRector\Services\AddCommentService
+ * @var AddCommentService
*/
private AddCommentService $commentService;
diff --git a/src/Drupal8/Rector/Deprecation/EntityViewRector.php b/src/Drupal8/Rector/Deprecation/EntityViewRector.php
index 1a602de1..26e035b1 100644
--- a/src/Drupal8/Rector/Deprecation/EntityViewRector.php
+++ b/src/Drupal8/Rector/Deprecation/EntityViewRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal8\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal8/Rector/Deprecation/FileDefaultSchemeRector.php b/src/Drupal8/Rector/Deprecation/FileDefaultSchemeRector.php
index 224df6f0..2d98cd86 100644
--- a/src/Drupal8/Rector/Deprecation/FileDefaultSchemeRector.php
+++ b/src/Drupal8/Rector/Deprecation/FileDefaultSchemeRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal8\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php b/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php
index 26d7820e..68316c57 100644
--- a/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php
+++ b/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php
@@ -10,9 +10,9 @@
use PHPStan\Analyser\Scope;
use PHPStan\Type\ObjectType;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
-use Rector\Core\Exception\ShouldNotHappenException;
-use Rector\Core\PhpParser\Node\Value\ValueResolver;
-use Rector\Core\Rector\AbstractScopeAwareRector;
+use Rector\Exception\ShouldNotHappenException;
+use Rector\PhpParser\Node\Value\ValueResolver;
+use Rector\Rector\AbstractScopeAwareRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -24,12 +24,12 @@
final class FunctionalTestDefaultThemePropertyRector extends AbstractScopeAwareRector
{
/**
- * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
+ * @var PhpDocInfoFactory
*/
private PhpDocInfoFactory $phpDocInfoFactory;
/**
- * @var \Rector\Core\PhpParser\Node\Value\ValueResolver
+ * @var ValueResolver
*/
private ValueResolver $valueResolver;
diff --git a/src/Drupal8/Rector/Deprecation/GetMockRector.php b/src/Drupal8/Rector/Deprecation/GetMockRector.php
index a30f3f1e..2f9f673d 100644
--- a/src/Drupal8/Rector/Deprecation/GetMockRector.php
+++ b/src/Drupal8/Rector/Deprecation/GetMockRector.php
@@ -7,10 +7,10 @@
use DrupalRector\Drupal8\Rector\ValueObject\GetMockConfiguration;
use PhpParser\Node;
use PHPStan\Analyser\Scope;
-use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php b/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php
index 28fc08cb..4195de5c 100644
--- a/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php
+++ b/src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php
@@ -7,8 +7,8 @@
use DrupalRector\Services\AddCommentService;
use DrupalRector\Utility\FindParentByTypeTrait;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
use Rector\NodeTypeResolver\Node\AttributeKey;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -28,7 +28,7 @@ final class LinkGeneratorTraitLRector extends AbstractRector
use FindParentByTypeTrait;
/**
- * @var \DrupalRector\Services\AddCommentService
+ * @var AddCommentService
*/
private AddCommentService $commentService;
diff --git a/src/Drupal8/Rector/Deprecation/RequestTimeConstRector.php b/src/Drupal8/Rector/Deprecation/RequestTimeConstRector.php
index 8a98da03..526f61b8 100644
--- a/src/Drupal8/Rector/Deprecation/RequestTimeConstRector.php
+++ b/src/Drupal8/Rector/Deprecation/RequestTimeConstRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal8\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal8/Rector/Deprecation/SafeMarkupFormatRector.php b/src/Drupal8/Rector/Deprecation/SafeMarkupFormatRector.php
index 5bf6b0fa..d59b7acd 100644
--- a/src/Drupal8/Rector/Deprecation/SafeMarkupFormatRector.php
+++ b/src/Drupal8/Rector/Deprecation/SafeMarkupFormatRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal8\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal8/Rector/Deprecation/StaticToFunctionRector.php b/src/Drupal8/Rector/Deprecation/StaticToFunctionRector.php
index 52ef5b9a..59ab837e 100644
--- a/src/Drupal8/Rector/Deprecation/StaticToFunctionRector.php
+++ b/src/Drupal8/Rector/Deprecation/StaticToFunctionRector.php
@@ -6,8 +6,8 @@
use DrupalRector\Drupal8\Rector\ValueObject\StaticToFunctionConfiguration;
use PhpParser\Node;
-use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal8/Rector/ValueObject/ConstantToClassConfiguration.php b/src/Drupal8/Rector/ValueObject/ConstantToClassConfiguration.php
index 131274be..b8bfe544 100644
--- a/src/Drupal8/Rector/ValueObject/ConstantToClassConfiguration.php
+++ b/src/Drupal8/Rector/ValueObject/ConstantToClassConfiguration.php
@@ -4,7 +4,7 @@
namespace DrupalRector\Drupal8\Rector\ValueObject;
-use Rector\Core\Validation\RectorAssert;
+use Rector\Validation\RectorAssert;
final class ConstantToClassConfiguration
{
diff --git a/src/Drupal8/Rector/ValueObject/EntityLoadConfiguration.php b/src/Drupal8/Rector/ValueObject/EntityLoadConfiguration.php
index f5b96729..bdf2aa4f 100644
--- a/src/Drupal8/Rector/ValueObject/EntityLoadConfiguration.php
+++ b/src/Drupal8/Rector/ValueObject/EntityLoadConfiguration.php
@@ -4,7 +4,7 @@
namespace DrupalRector\Drupal8\Rector\ValueObject;
-use Rector\Core\Validation\RectorAssert;
+use Rector\Validation\RectorAssert;
final class EntityLoadConfiguration
{
diff --git a/src/Drupal9/Rector/Deprecation/AssertFieldByIdRector.php b/src/Drupal9/Rector/Deprecation/AssertFieldByIdRector.php
index 5fc330d4..677f5355 100644
--- a/src/Drupal9/Rector/Deprecation/AssertFieldByIdRector.php
+++ b/src/Drupal9/Rector/Deprecation/AssertFieldByIdRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal9\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/AssertFieldByNameRector.php b/src/Drupal9/Rector/Deprecation/AssertFieldByNameRector.php
index 6200835a..69ca6451 100644
--- a/src/Drupal9/Rector/Deprecation/AssertFieldByNameRector.php
+++ b/src/Drupal9/Rector/Deprecation/AssertFieldByNameRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal9\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php b/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php
index 30e6e723..95e3a374 100644
--- a/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php
+++ b/src/Drupal9/Rector/Deprecation/AssertLegacyTraitRector.php
@@ -10,8 +10,8 @@
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\VariadicPlaceholder;
-use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -25,7 +25,7 @@ class AssertLegacyTraitRector extends AbstractRector implements ConfigurableRect
private array $assertLegacyTraitMethods;
/**
- * @var \DrupalRector\Services\AddCommentService
+ * @var AddCommentService
*/
private AddCommentService $commentService;
diff --git a/src/Drupal9/Rector/Deprecation/AssertNoFieldByIdRector.php b/src/Drupal9/Rector/Deprecation/AssertNoFieldByIdRector.php
index 77934191..202a8b27 100644
--- a/src/Drupal9/Rector/Deprecation/AssertNoFieldByIdRector.php
+++ b/src/Drupal9/Rector/Deprecation/AssertNoFieldByIdRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal9\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php b/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php
index 657724a1..72fc873a 100644
--- a/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php
+++ b/src/Drupal9/Rector/Deprecation/AssertNoFieldByNameRector.php
@@ -9,7 +9,7 @@
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\VariadicPlaceholder;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -22,7 +22,7 @@ final class AssertNoFieldByNameRector extends AbstractRector
protected string $comment = 'Verify the assertion: buttonNotExists() if this is for a button.';
/**
- * @var \DrupalRector\Services\AddCommentService
+ * @var AddCommentService
*/
private AddCommentService $commentService;
diff --git a/src/Drupal9/Rector/Deprecation/AssertNoUniqueTextRector.php b/src/Drupal9/Rector/Deprecation/AssertNoUniqueTextRector.php
index 6407459c..caabeefa 100644
--- a/src/Drupal9/Rector/Deprecation/AssertNoUniqueTextRector.php
+++ b/src/Drupal9/Rector/Deprecation/AssertNoUniqueTextRector.php
@@ -6,8 +6,8 @@
use DrupalRector\Utility\GetDeclaringSourceTrait;
use PhpParser\Node;
-use Rector\Core\Exception\ShouldNotHappenException;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Exception\ShouldNotHappenException;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/AssertOptionSelectedRector.php b/src/Drupal9/Rector/Deprecation/AssertOptionSelectedRector.php
index b090a2ab..09b7ae71 100644
--- a/src/Drupal9/Rector/Deprecation/AssertOptionSelectedRector.php
+++ b/src/Drupal9/Rector/Deprecation/AssertOptionSelectedRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal9\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/ConstructFieldXpathRector.php b/src/Drupal9/Rector/Deprecation/ConstructFieldXpathRector.php
index 1de4caff..f6c9b14e 100644
--- a/src/Drupal9/Rector/Deprecation/ConstructFieldXpathRector.php
+++ b/src/Drupal9/Rector/Deprecation/ConstructFieldXpathRector.php
@@ -6,7 +6,7 @@
use DrupalRector\Utility\GetDeclaringSourceTrait;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php b/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php
index 836a7e9b..e0d9ca33 100644
--- a/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php
+++ b/src/Drupal9/Rector/Deprecation/ExtensionPathRector.php
@@ -7,8 +7,8 @@
use DrupalRector\Drupal9\Rector\ValueObject\ExtensionPathConfiguration;
use DrupalRector\Services\AddCommentService;
use PhpParser\Node;
-use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -20,7 +20,7 @@ class ExtensionPathRector extends AbstractRector implements ConfigurableRectorIn
private array $configuration;
/**
- * @var \DrupalRector\Services\AddCommentService
+ * @var AddCommentService
*/
private AddCommentService $commentService;
diff --git a/src/Drupal9/Rector/Deprecation/FileBuildUriRector.php b/src/Drupal9/Rector/Deprecation/FileBuildUriRector.php
index 57864646..8ebefe34 100644
--- a/src/Drupal9/Rector/Deprecation/FileBuildUriRector.php
+++ b/src/Drupal9/Rector/Deprecation/FileBuildUriRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal9\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/FileCreateUrlRector.php b/src/Drupal9/Rector/Deprecation/FileCreateUrlRector.php
index bfd72b0f..1054a6d1 100644
--- a/src/Drupal9/Rector/Deprecation/FileCreateUrlRector.php
+++ b/src/Drupal9/Rector/Deprecation/FileCreateUrlRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal9\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/FileUrlTransformRelativeRector.php b/src/Drupal9/Rector/Deprecation/FileUrlTransformRelativeRector.php
index b6896ab4..1fa90220 100644
--- a/src/Drupal9/Rector/Deprecation/FileUrlTransformRelativeRector.php
+++ b/src/Drupal9/Rector/Deprecation/FileUrlTransformRelativeRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal9\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/FromUriRector.php b/src/Drupal9/Rector/Deprecation/FromUriRector.php
index 891b6ea6..f88f83e7 100644
--- a/src/Drupal9/Rector/Deprecation/FromUriRector.php
+++ b/src/Drupal9/Rector/Deprecation/FromUriRector.php
@@ -6,7 +6,7 @@
use DrupalRector\Utility\GetDeclaringSourceTrait;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/FunctionToEntityTypeStorageMethod.php b/src/Drupal9/Rector/Deprecation/FunctionToEntityTypeStorageMethod.php
index 84619b7d..74c02230 100644
--- a/src/Drupal9/Rector/Deprecation/FunctionToEntityTypeStorageMethod.php
+++ b/src/Drupal9/Rector/Deprecation/FunctionToEntityTypeStorageMethod.php
@@ -6,8 +6,8 @@
use DrupalRector\Drupal9\Rector\ValueObject\FunctionToEntityTypeStorageConfiguration;
use PhpParser\Node;
-use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/FunctionToFirstArgMethodRector.php b/src/Drupal9/Rector/Deprecation/FunctionToFirstArgMethodRector.php
index 240253a0..7a89089e 100644
--- a/src/Drupal9/Rector/Deprecation/FunctionToFirstArgMethodRector.php
+++ b/src/Drupal9/Rector/Deprecation/FunctionToFirstArgMethodRector.php
@@ -6,8 +6,8 @@
use DrupalRector\Drupal9\Rector\ValueObject\FunctionToFirstArgMethodConfiguration;
use PhpParser\Node;
-use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/GetAllOptionsRector.php b/src/Drupal9/Rector/Deprecation/GetAllOptionsRector.php
index 9038a88b..68a57c69 100644
--- a/src/Drupal9/Rector/Deprecation/GetAllOptionsRector.php
+++ b/src/Drupal9/Rector/Deprecation/GetAllOptionsRector.php
@@ -6,8 +6,8 @@
use DrupalRector\Utility\GetDeclaringSourceTrait;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/GetRawContentRector.php b/src/Drupal9/Rector/Deprecation/GetRawContentRector.php
index a0425cef..cf6d9dcb 100644
--- a/src/Drupal9/Rector/Deprecation/GetRawContentRector.php
+++ b/src/Drupal9/Rector/Deprecation/GetRawContentRector.php
@@ -6,8 +6,8 @@
use DrupalRector\Utility\GetDeclaringSourceTrait;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector.php b/src/Drupal9/Rector/Deprecation/ModuleLoadRector.php
similarity index 62%
rename from src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector.php
rename to src/Drupal9/Rector/Deprecation/ModuleLoadRector.php
index bffa01d9..37c38d55 100644
--- a/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector.php
+++ b/src/Drupal9/Rector/Deprecation/ModuleLoadRector.php
@@ -5,14 +5,14 @@
namespace DrupalRector\Drupal9\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* Replaces deprecated module_load_install call with ModuleHandler call.
*/
-class ModuleLoadInstallRector extends AbstractRector
+class ModuleLoadRector extends AbstractRector
{
/**
* {@inheritdoc}
@@ -35,6 +35,12 @@ public function refactor(Node $node): ?Node\Expr\CallLike
$args[] = new Node\Arg(new Node\Scalar\String_('install'));
return $this->nodeFactory->createMethodCall($this->nodeFactory->createStaticCall('Drupal', 'moduleHandler'), 'loadInclude', $args);
+ } elseif ($this->getName($node->name) === 'module_load_include') {
+ $newArgs = $args = $node->getArgs();
+ $newArgs[0] = $args[1];
+ $newArgs[1] = $args[0];
+
+ return $this->nodeFactory->createMethodCall($this->nodeFactory->createStaticCall('Drupal', 'moduleHandler'), 'loadInclude', $newArgs);
}
return null;
@@ -46,10 +52,20 @@ public function getRuleDefinition(): RuleDefinition
new CodeSample(
<<<'CODE_BEFORE'
module_load_install('example');
+$type = 'install';
+$module = 'example';
+$name = 'name';
+module_load_include($type, $module, $name);
+module_load_include($type, $module);
CODE_BEFORE
,
<<<'CODE_AFTER'
-\Drupal\Core\Extension\ModuleHandler::loadInclude('example', 'install');
+\Drupal::moduleHandler()->loadInclude('example', 'install');
+$type = 'install';
+$module = 'example';
+$name = 'name';
+\Drupal::moduleHandler()->loadInclude($module, $type, $name);
+\Drupal::moduleHandler()->loadInclude($module, $type);
CODE_AFTER
),
]);
diff --git a/src/Drupal9/Rector/Deprecation/PassRector.php b/src/Drupal9/Rector/Deprecation/PassRector.php
index 7b12b400..60b68900 100644
--- a/src/Drupal9/Rector/Deprecation/PassRector.php
+++ b/src/Drupal9/Rector/Deprecation/PassRector.php
@@ -7,7 +7,7 @@
use DrupalRector\Utility\GetDeclaringSourceTrait;
use PhpParser\Node;
use PhpParser\NodeTraverser;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/SystemSortByInfoNameRector.php b/src/Drupal9/Rector/Deprecation/SystemSortByInfoNameRector.php
index c30334f3..b99f44e4 100644
--- a/src/Drupal9/Rector/Deprecation/SystemSortByInfoNameRector.php
+++ b/src/Drupal9/Rector/Deprecation/SystemSortByInfoNameRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal9\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/TaxonomyTermLoadMultipleByNameRector.php b/src/Drupal9/Rector/Deprecation/TaxonomyTermLoadMultipleByNameRector.php
index 9e69b2e1..37be4883 100644
--- a/src/Drupal9/Rector/Deprecation/TaxonomyTermLoadMultipleByNameRector.php
+++ b/src/Drupal9/Rector/Deprecation/TaxonomyTermLoadMultipleByNameRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal9\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesDrupalStaticResetRector.php b/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesDrupalStaticResetRector.php
index 8579d38a..85843ad4 100644
--- a/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesDrupalStaticResetRector.php
+++ b/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesDrupalStaticResetRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal9\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesRector.php b/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesRector.php
index a8d525e0..d19ba3f1 100644
--- a/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesRector.php
+++ b/src/Drupal9/Rector/Deprecation/TaxonomyVocabularyGetNamesRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal9\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php b/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php
index f2a6acf0..eb2a9421 100644
--- a/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php
+++ b/src/Drupal9/Rector/Deprecation/UiHelperTraitDrupalPostFormRector.php
@@ -5,8 +5,8 @@
namespace DrupalRector\Drupal9\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Exception\ShouldNotHappenException;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Exception\ShouldNotHappenException;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -46,7 +46,7 @@ public function getNodeTypes(): array
/**
* @param \PhpParser\Node\Expr\MethodCall $node
*
- * @throws \Rector\Core\Exception\ShouldNotHappenException
+ * @throws ShouldNotHappenException
*
* @return array
*/
diff --git a/src/Drupal9/Rector/Deprecation/UserPasswordRector.php b/src/Drupal9/Rector/Deprecation/UserPasswordRector.php
index 19ba03af..e6c10d26 100644
--- a/src/Drupal9/Rector/Deprecation/UserPasswordRector.php
+++ b/src/Drupal9/Rector/Deprecation/UserPasswordRector.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Drupal9\Rector\Deprecation;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector.php b/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector.php
index 72dba517..b7a6ae09 100644
--- a/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector.php
+++ b/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector.php
@@ -5,8 +5,8 @@
namespace DrupalRector\Drupal9\Rector\Property;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
use Rector\Privatization\NodeManipulator\VisibilityManipulator;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Rector/AbstractDrupalCoreRector.php b/src/Rector/AbstractDrupalCoreRector.php
index 9459e342..70634a7b 100644
--- a/src/Rector/AbstractDrupalCoreRector.php
+++ b/src/Rector/AbstractDrupalCoreRector.php
@@ -8,8 +8,8 @@
use DrupalRector\Contract\VersionedConfigurationInterface;
use PhpParser\Node;
use PhpParser\Node\Expr\ArrowFunction;
-use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\Rector\AbstractRector;
abstract class AbstractDrupalCoreRector extends AbstractRector implements ConfigurableRectorInterface
{
@@ -78,8 +78,8 @@ private function createBcCallOnCallLike(Node\Expr\CallLike $node, Node\Expr\Call
return $this->nodeFactory->createStaticCall(DeprecationHelper::class, 'backwardsCompatibleCall', [
$this->nodeFactory->createClassConstFetch(\Drupal::class, 'VERSION'),
$introducedVersion,
- new ArrowFunction(['expr' => $clonedNode]),
new ArrowFunction(['expr' => $result]),
+ new ArrowFunction(['expr' => $clonedNode]),
]);
}
diff --git a/src/Rector/Deprecation/Base/FunctionToFunctionBase.php b/src/Rector/Deprecation/Base/FunctionToFunctionBase.php
index 92b90c27..8d2ce507 100644
--- a/src/Rector/Deprecation/Base/FunctionToFunctionBase.php
+++ b/src/Rector/Deprecation/Base/FunctionToFunctionBase.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Rector\Deprecation\Base;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
/**
* Replaces deprecated function call with a function call.
diff --git a/src/Rector/Deprecation/Base/StaticToServiceBase.php b/src/Rector/Deprecation/Base/StaticToServiceBase.php
index fb185a3e..618399d5 100644
--- a/src/Rector/Deprecation/Base/StaticToServiceBase.php
+++ b/src/Rector/Deprecation/Base/StaticToServiceBase.php
@@ -5,7 +5,7 @@
namespace DrupalRector\Rector\Deprecation\Base;
use PhpParser\Node;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Rector\AbstractRector;
/**
* Replaces deprecated static call with service method call.
diff --git a/src/Rector/Deprecation/DeprecationHelperRemoveRector.php b/src/Rector/Deprecation/DeprecationHelperRemoveRector.php
index af240ea2..634c6857 100644
--- a/src/Rector/Deprecation/DeprecationHelperRemoveRector.php
+++ b/src/Rector/Deprecation/DeprecationHelperRemoveRector.php
@@ -6,8 +6,8 @@
use DrupalRector\Rector\ValueObject\DeprecationHelperRemoveConfiguration;
use PhpParser\Node;
-use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -28,16 +28,16 @@ public function getRuleDefinition(): RuleDefinition
<<<'CODE_BEFORE'
$settings = [];
$filename = 'simple_filename.yaml';
-DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => old_function(), fn() => new_function());
-DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => drupal_rewrite_settings($settings, $filename), fn() => SettingsEditor::rewrite($filename, $settings));
-DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.1.0', fn() => old_function(), fn() => new_function());
+DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => new_function(), fn() => old_function());
+DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => SettingsEditor::rewrite($filename, $settings), fn() => drupal_rewrite_settings($settings, $filename));
+DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.1.0', fn() => new_function(), fn() => old_function());
CODE_BEFORE
,
<<<'CODE_AFTER'
$settings = [];
$filename = 'simple_filename.yaml';
drupal_rewrite_settings($settings, $filename);
-DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.1.0', fn() => old_function(), fn() => new_function());
+DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.1.0', fn() => new_function(), fn() => old_function());
CODE_AFTER
,
[
@@ -88,7 +88,7 @@ public function refactor(Node $node): ?Node
continue;
}
- $newCall = $args[3]->value;
+ $newCall = $args[2]->value;
if ($newCall instanceof Node\Expr\ArrowFunction) {
return $newCall->expr;
}
diff --git a/src/Rector/Deprecation/FunctionToServiceRector.php b/src/Rector/Deprecation/FunctionToServiceRector.php
index 124e0e4a..3465c936 100644
--- a/src/Rector/Deprecation/FunctionToServiceRector.php
+++ b/src/Rector/Deprecation/FunctionToServiceRector.php
@@ -6,8 +6,8 @@
use DrupalRector\Rector\ValueObject\FunctionToServiceConfiguration;
use PhpParser\Node;
-use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
diff --git a/src/Rector/Deprecation/MethodToMethodWithCheckRector.php b/src/Rector/Deprecation/MethodToMethodWithCheckRector.php
index b99c4f3d..409feee4 100644
--- a/src/Rector/Deprecation/MethodToMethodWithCheckRector.php
+++ b/src/Rector/Deprecation/MethodToMethodWithCheckRector.php
@@ -8,9 +8,9 @@
use DrupalRector\Services\AddCommentService;
use PhpParser\Node;
use PHPStan\Type\ObjectType;
-use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
-use Rector\Core\Exception\ShouldNotHappenException;
-use Rector\Core\Rector\AbstractRector;
+use Rector\Contract\Rector\ConfigurableRectorInterface;
+use Rector\Exception\ShouldNotHappenException;
+use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -31,7 +31,7 @@ class MethodToMethodWithCheckRector extends AbstractRector implements Configurab
private array $configuration;
/**
- * @var \DrupalRector\Services\AddCommentService
+ * @var AddCommentService
*/
private AddCommentService $commentService;
diff --git a/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php b/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php
index 72512166..934ef7fa 100644
--- a/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php
+++ b/src/Rector/PHPUnit/ShouldCallParentMethodsRector.php
@@ -6,7 +6,7 @@
use PhpParser\Node;
use PHPStan\Analyser\Scope;
-use Rector\Core\Rector\AbstractScopeAwareRector;
+use Rector\Rector\AbstractScopeAwareRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -22,8 +22,8 @@ public function getNodeTypes(): array
/**
* @phpstan-param Node\Stmt\ClassMethod $node
*
- * @param \PhpParser\Node $node
- * @param \PHPStan\Analyser\Scope $scope
+ * @param Node $node
+ * @param Scope $scope
*
* @return \PhpParser\Node|null
*/
diff --git a/tests/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector/fixture/system_time_zones.php.inc b/tests/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector/fixture/system_time_zones.php.inc
index 09f79684..ca8669f4 100644
--- a/tests/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector/fixture/system_time_zones.php.inc
+++ b/tests/src/Drupal10/Rector/Deprecation/SystemTimeZonesRector/fixture/system_time_zones.php.inc
@@ -15,12 +15,12 @@ function simple_example() {
system_time_zones(), fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList());
+ \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(), fn() => system_time_zones());
- \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => system_time_zones(FALSE, TRUE), fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsListByRegion());
+ \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsListByRegion(), fn() => system_time_zones(FALSE, TRUE));
- \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => system_time_zones(NULL, FALSE), fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(NULL));
+ \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(NULL), fn() => system_time_zones(NULL, FALSE));
- \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => system_time_zones(TRUE, FALSE), fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(TRUE));
+ \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(TRUE), fn() => system_time_zones(TRUE, FALSE));
}
?>
diff --git a/tests/src/Drupal10/Rector/Deprecation/WatchdogExceptionRector/fixture/watchdog_exception.php.inc b/tests/src/Drupal10/Rector/Deprecation/WatchdogExceptionRector/fixture/watchdog_exception.php.inc
index c61ede53..8d40c958 100644
--- a/tests/src/Drupal10/Rector/Deprecation/WatchdogExceptionRector/fixture/watchdog_exception.php.inc
+++ b/tests/src/Drupal10/Rector/Deprecation/WatchdogExceptionRector/fixture/watchdog_exception.php.inc
@@ -17,15 +17,15 @@ function advanced() {
watchdog_exception('update', $exception), fn() => \Drupal\Core\Utility\Error::logException(\Drupal::logger('update'), $exception));
+ \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Utility\Error::logException(\Drupal::logger('update'), $exception), fn() => watchdog_exception('update', $exception));
}
/**
* A simple example.
*/
function advanced() {
- \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => watchdog_exception('update', $exception, 'My custom message @foo', ['@foo' => 'bar', 'link' => 'http://example.com'], RfcLogLevel::CRITICAL, 'http://example.com'), fn() => \Drupal\Core\Utility\Error::logException(\Drupal::logger('update'), $exception, 'My custom message @foo', ['@foo' => 'bar', 'link' => 'http://example.com'], RfcLogLevel::CRITICAL));
+ \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Utility\Error::logException(\Drupal::logger('update'), $exception, 'My custom message @foo', ['@foo' => 'bar', 'link' => 'http://example.com'], RfcLogLevel::CRITICAL), fn() => watchdog_exception('update', $exception, 'My custom message @foo', ['@foo' => 'bar', 'link' => 'http://example.com'], RfcLogLevel::CRITICAL, 'http://example.com'));
- \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => watchdog_exception('update', $exception, 'My custom message @foo', ['@foo' => 'bar']), fn() => \Drupal\Core\Utility\Error::logException(\Drupal::logger('update'), $exception, 'My custom message @foo', ['@foo' => 'bar']));
+ \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Utility\Error::logException(\Drupal::logger('update'), $exception, 'My custom message @foo', ['@foo' => 'bar']), fn() => watchdog_exception('update', $exception, 'My custom message @foo', ['@foo' => 'bar']));
}
?>
diff --git a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php b/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php
index c43f965a..aeec0664 100644
--- a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php
+++ b/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/config/configured_rule.php
@@ -15,4 +15,11 @@
'STORAGE_TIMEZONE',
),
]);
+ DeprecationBase::addClass(ConstantToClassConstantRector::class, $rectorConfig, false, [
+ new ConstantToClassConfiguration(
+ 'FILE_STATUS_PERMANENT',
+ 'Drupal\file\FileInterface',
+ 'STATUS_PERMANENT',
+ ),
+ ]);
};
diff --git a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc b/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc
index d10ece7c..c49f064a 100644
--- a/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc
+++ b/tests/src/Drupal8/Rector/Deprecation/ConstantToClassConstantRector/fixture/fixture.php.inc
@@ -2,20 +2,42 @@
function simple_example() {
$timezone = DATETIME_STORAGE_TIMEZONE;
+
+ $file_status = FILE_STATUS_PERMANENT;
}
function as_an_argument() {
$timezone = new \DateTimeZone(DATETIME_STORAGE_TIMEZONE);
+
+ $class = new \TestClass(FILE_STATUS_PERMANENT);
}
+
+class ClassDefault {
+ public function test($status = FILE_STATUS_PERMANENT) {
+ return true;
+ }
+}
+
?>
-----
diff --git a/tests/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector/config/configured_rule.php b/tests/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector/config/configured_rule.php
index fe548ec0..4aa74c8f 100644
--- a/tests/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector/config/configured_rule.php
+++ b/tests/src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector/config/configured_rule.php
@@ -5,5 +5,5 @@
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
- $rectorConfig->rule(\DrupalRector\Drupal8\Rector\Deprecation\FunctionalTestDefaultThemePropertyRector::class);
+ $rectorConfig->rule(DrupalRector\Drupal8\Rector\Deprecation\FunctionalTestDefaultThemePropertyRector::class);
};
diff --git a/tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/fixture/basic.php.inc b/tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/fixture/basic.php.inc
deleted file mode 100644
index 7857c2fc..00000000
--- a/tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/fixture/basic.php.inc
+++ /dev/null
@@ -1,25 +0,0 @@
-
------
-loadInclude('example', 'install');
-
- $module = 'simple';
- \Drupal::moduleHandler()->loadInclude($module, 'install');
-}
-?>
diff --git a/tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/ModuleLoadInstallRectorTest.php b/tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/ModuleLoadRectorTest.php
similarity index 82%
rename from tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/ModuleLoadInstallRectorTest.php
rename to tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/ModuleLoadRectorTest.php
index 37e36032..cebd2d9c 100644
--- a/tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/ModuleLoadInstallRectorTest.php
+++ b/tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/ModuleLoadRectorTest.php
@@ -2,12 +2,12 @@
declare(strict_types=1);
-namespace Drupal9\Rector\Deprecation\ModuleLoadInstallRector;
+namespace Drupal9\Rector\Deprecation\ModuleLoadRector;
use Iterator;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
-class ModuleLoadInstallRectorTest extends AbstractRectorTestCase
+class ModuleLoadRectorTest extends AbstractRectorTestCase
{
/**
* @covers ::refactor
diff --git a/tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/config/configured_rule.php b/tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/config/configured_rule.php
similarity index 54%
rename from tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/config/configured_rule.php
rename to tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/config/configured_rule.php
index eab586ad..f9b9c03a 100644
--- a/tests/src/Drupal9/Rector/Deprecation/ModuleLoadInstallRector/config/configured_rule.php
+++ b/tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/config/configured_rule.php
@@ -2,10 +2,10 @@
declare(strict_types=1);
-use DrupalRector\Drupal9\Rector\Deprecation\ModuleLoadInstallRector;
+use DrupalRector\Drupal9\Rector\Deprecation\ModuleLoadRector;
use DrupalRector\Tests\Rector\Deprecation\DeprecationBase;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
- DeprecationBase::addClass(ModuleLoadInstallRector::class, $rectorConfig, false);
+ DeprecationBase::addClass(ModuleLoadRector::class, $rectorConfig, false);
};
diff --git a/tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/fixture/basic.php.inc b/tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/fixture/basic.php.inc
new file mode 100644
index 00000000..11609627
--- /dev/null
+++ b/tests/src/Drupal9/Rector/Deprecation/ModuleLoadRector/fixture/basic.php.inc
@@ -0,0 +1,43 @@
+
+-----
+loadInclude('example', 'install');
+
+ $module = 'simple';
+ \Drupal::moduleHandler()->loadInclude($module, 'install');
+
+ $type = 'install';
+ $module = 'example';
+ $name = 'name';
+ \Drupal::moduleHandler()->loadInclude($module, $type, $name);
+ \Drupal::moduleHandler()->loadInclude($module, $type);
+
+ \Drupal::moduleHandler()->loadInclude('example', 'install', 'name');
+ \Drupal::moduleHandler()->loadInclude('example', 'install');
+}
+?>
diff --git a/tests/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector/config/configured_rule.php b/tests/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector/config/configured_rule.php
index 58043016..d424bb27 100644
--- a/tests/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector/config/configured_rule.php
+++ b/tests/src/Drupal9/Rector/Property/ProtectedStaticModulesPropertyRector/config/configured_rule.php
@@ -5,5 +5,5 @@
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
- $rectorConfig->rule(\DrupalRector\Drupal9\Rector\Property\ProtectedStaticModulesPropertyRector::class);
+ $rectorConfig->rule(DrupalRector\Drupal9\Rector\Property\ProtectedStaticModulesPropertyRector::class);
};
diff --git a/tests/src/Rector/Deprecation/DeprecationBase.php b/tests/src/Rector/Deprecation/DeprecationBase.php
index 251316c7..b324f1ff 100644
--- a/tests/src/Rector/Deprecation/DeprecationBase.php
+++ b/tests/src/Rector/Deprecation/DeprecationBase.php
@@ -15,14 +15,10 @@ class DeprecationBase
/**
* Adds a class to a test.
*
- * @param string $rectorClass
- * The class being tested
- * @param \Rector\Config\RectorConfig $rectorConfig
- * The Rector Config handler
- * @param bool $add_config
- * Indicates that config should be added to the test
- * @param array $configuration
- * Configuration for the configured rule
+ * @param string $rectorClass The class being tested
+ * @param RectorConfig $rectorConfig The Rector Config handler
+ * @param bool $add_config Indicates that config should be added to the test
+ * @param array $configuration Configuration for the configured rule
*/
public static function addClass(string $rectorClass, RectorConfig $rectorConfig, bool $add_notice_config = true, array $configuration = [])
{
diff --git a/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password.php.inc b/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password.php.inc
index f557476e..29341a6a 100644
--- a/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password.php.inc
+++ b/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password.php.inc
@@ -2,10 +2,10 @@
function simple_example()
{
- $password = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => user_password(), fn() => \Drupal::service('password_generator')->generate());
- $other_password = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => user_password(8), fn() => \Drupal::service('password_generator')->generate(8));
+ $password = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => \Drupal::service('password_generator')->generate(), fn() => user_password());
+ $other_password = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => \Drupal::service('password_generator')->generate(8), fn() => user_password(8));
$password_length = 12;
- $last_password = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => user_password($password_length), fn() => \Drupal::service('password_generator')->generate($password_length));
+ $last_password = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '9.1.0', fn() => \Drupal::service('password_generator')->generate($password_length), fn() => user_password($password_length));
}
?>
diff --git a/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password_keep.php.inc b/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password_keep.php.inc
index cb71459d..da7e0faf 100644
--- a/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password_keep.php.inc
+++ b/tests/src/Rector/Deprecation/DeprecationHelperRemoveRector/fixture/user_password_keep.php.inc
@@ -4,10 +4,10 @@ use Drupal\Component\Utility\DeprecationHelper;
function simple_example()
{
- $password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => user_password(), fn() => \Drupal::service('password_generator')->generate());
- $other_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => user_password(8), fn() => \Drupal::service('password_generator')->generate(8));
+ $password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => \Drupal::service('password_generator')->generate(), fn() => user_password());
+ $other_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => \Drupal::service('password_generator')->generate(8), fn() => user_password(8));
$password_length = 12;
- $last_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => user_password($password_length), fn() => \Drupal::service('password_generator')->generate($password_length));
+ $last_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => \Drupal::service('password_generator')->generate($password_length), fn() => user_password($password_length));
}
?>
@@ -18,10 +18,10 @@ use Drupal\Component\Utility\DeprecationHelper;
function simple_example()
{
- $password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => user_password(), fn() => \Drupal::service('password_generator')->generate());
- $other_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => user_password(8), fn() => \Drupal::service('password_generator')->generate(8));
+ $password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => \Drupal::service('password_generator')->generate(), fn() => user_password());
+ $other_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => \Drupal::service('password_generator')->generate(8), fn() => user_password(8));
$password_length = 12;
- $last_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => user_password($password_length), fn() => \Drupal::service('password_generator')->generate($password_length));
+ $last_password = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.5.0', fn() => \Drupal::service('password_generator')->generate($password_length), fn() => user_password($password_length));
}
?>
diff --git a/tests/src/Rector/Deprecation/FunctionToStaticRector/config/configured_rule.php b/tests/src/Rector/Deprecation/FunctionToStaticRector/config/configured_rule.php
index 0013a28f..eba3a534 100644
--- a/tests/src/Rector/Deprecation/FunctionToStaticRector/config/configured_rule.php
+++ b/tests/src/Rector/Deprecation/FunctionToStaticRector/config/configured_rule.php
@@ -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'),
]);
};
diff --git a/tests/src/Rector/Deprecation/FunctionToStaticRector/fixture/function_to_static_call.php.inc b/tests/src/Rector/Deprecation/FunctionToStaticRector/fixture/function_to_static_call.php.inc
index d51f9f41..2f2d5767 100644
--- a/tests/src/Rector/Deprecation/FunctionToStaticRector/fixture/function_to_static_call.php.inc
+++ b/tests/src/Rector/Deprecation/FunctionToStaticRector/fixture/function_to_static_call.php.inc
@@ -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);
+}
?>
-----
drupal_rewrite_settings($settings, $filename), fn() => \Drupal\Core\Site\SettingsEditor::rewrite($filename, $settings));
+ \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Site\SettingsEditor::rewrite($filename, $settings), fn() => drupal_rewrite_settings($settings, $filename));
}
/**
@@ -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() => \\Drupal\Core\StringTranslation\ByteSizeMarkup::create(81862076662), fn() => format_size(81862076662));
+}
?>