Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ public function getRuleDefinition(): RuleDefinition
* )
*/
class PublishAction extends EntityActionBase {
CODE_SAMPLE
, <<<'CODE_SAMPLE'
CODE_SAMPLE, <<<'CODE_SAMPLE'

namespace Drupal\Core\Action\Plugin\Action;

Expand All @@ -115,8 +114,7 @@ class PublishAction extends EntityActionBase {
deriver: EntityPublishedActionDeriver::class
)]
class PublishAction extends EntityActionBase {
CODE_SAMPLE
,
CODE_SAMPLE,
[
new AnnotationToAttributeConfiguration('10.2.0', '12.0.0', 'Action', 'Drupal\Core\Action\Attribute\Action'),
])]);
Expand Down
6 changes: 2 additions & 4 deletions src/Drupal10/Rector/Deprecation/SystemTimeZonesRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,13 @@ public function getRuleDefinition(): RuleDefinition
system_time_zones(FALSE, TRUE);
system_time_zones(NULL, FALSE);
system_time_zones(TRUE, FALSE);
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
\Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList();
\Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsListByRegion();
\Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(NULL);
\Drupal\Core\Datetime\TimeZoneFormHelper::getOptionsList(TRUE);
CODE_AFTER
,
CODE_AFTER,
[
new DrupalIntroducedVersionConfiguration('10.1.0'),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@ public function getRuleDefinition(): RuleDefinition
new ConfiguredCodeSample(
<<<'CODE_BEFORE'
_drupal_flush_css_js();
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
\Drupal::service('asset.query_string')->reset();
CODE_AFTER
,
CODE_AFTER,
[
new VersionedFunctionToServiceConfiguration('10.2.0', '_drupal_flush_css_js', 'asset.query_string', 'reset'),
]
Expand Down
6 changes: 2 additions & 4 deletions src/Drupal10/Rector/Deprecation/WatchdogExceptionRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,12 @@ public function getRuleDefinition(): RuleDefinition
new ConfiguredCodeSample(
<<<'CODE_BEFORE'
watchdog_exception('update', $exception);
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
use \Drupal\Core\Utility\Error;
$logger = \Drupal::logger('update');
Error::logException($logger, $exception);
CODE_AFTER
,
CODE_AFTER,
[
new DrupalIntroducedVersionConfiguration('10.1.0'),
]
Expand Down
30 changes: 10 additions & 20 deletions src/Drupal8/Rector/Deprecation/DBRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,64 +244,54 @@ public function getRuleDefinition(): RuleDefinition
new ConfiguredCodeSample(
<<<'CODE_BEFORE'
db_delete($table, $options);
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
\Drupal::database()->delete($table, $options);
CODE_AFTER
,
CODE_AFTER,
[
new DBConfiguration('db_delete', 2),
]
),
new ConfiguredCodeSample(
<<<'CODE_BEFORE'
db_insert($table, $options);
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
\Drupal::database()->insert($table, $options);
CODE_AFTER
,
CODE_AFTER,
[
new DBConfiguration('db_insert', 2),
]
),
new ConfiguredCodeSample(
<<<'CODE_BEFORE'
db_query($query, $args, $options);
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
\Drupal::database()->query($query, $args, $options);
CODE_AFTER
,
CODE_AFTER,
[
new DBConfiguration('db_query', 3),
]
),
new ConfiguredCodeSample(
<<<'CODE_BEFORE'
db_select($table, $alias, $options);
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
\Drupal::database()->select($table, $alias, $options);
CODE_AFTER
,
CODE_AFTER,
[
new DBConfiguration('db_select', 3),
]
),
new ConfiguredCodeSample(
<<<'CODE_BEFORE'
db_update($table, $options);
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
\Drupal::database()->update($table, $options);
CODE_AFTER
,
CODE_AFTER,
[
new DBConfiguration('db_update', 2),
]
Expand Down
3 changes: 1 addition & 2 deletions src/Drupal8/Rector/Deprecation/DrupalLRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public function getRuleDefinition(): RuleDefinition
new CodeSample(
<<<'CODE_BEFORE'
\Drupal::l('User Login', \Drupal\Core\Url::fromRoute('user.login'));
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
\Drupal\Core\Link::fromTextAndUrl('User Login', \Drupal\Core\Url::fromRoute('user.login'));
CODE_AFTER
Expand Down
6 changes: 2 additions & 4 deletions src/Drupal8/Rector/Deprecation/DrupalServiceRenameRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ public function getRuleDefinition(): RuleDefinition
new ConfiguredCodeSample(
<<<'CODE_BEFORE'
\Drupal::service('old')->foo();
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
\Drupal::service('bar')->foo();
CODE_AFTER
,
CODE_AFTER,
[
new DrupalServiceRenameConfiguration(
'old',
Expand Down
3 changes: 1 addition & 2 deletions src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public function getRuleDefinition(): RuleDefinition
new CodeSample(
<<<'CODE_BEFORE'
drupal_set_message('example status', 'status');
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
\Drupal::messenger()->addStatus('example status');
CODE_AFTER
Expand Down
3 changes: 1 addition & 2 deletions src/Drupal8/Rector/Deprecation/DrupalURLRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public function getRuleDefinition(): RuleDefinition
new CodeSample(
<<<'CODE_BEFORE'
\Drupal::url('user.login');
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
\Drupal\Core\Url::fromRoute('user.login')->toString();
CODE_AFTER
Expand Down
3 changes: 1 addition & 2 deletions src/Drupal8/Rector/Deprecation/EntityCreateRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public function getRuleDefinition(): RuleDefinition
new CodeSample(
<<<'CODE_BEFORE'
entity_create('node', ['bundle' => 'page', 'title' => 'Hello world']);
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
\Drupal::service('entity_type.manager)->getStorage('node')->create(['bundle' => 'page', 'title' => 'Hello world']);
CODE_AFTER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public function getRuleDefinition(): RuleDefinition
new CodeSample(
<<<'CODE_BEFORE'
entity_delete_multiple('node', [1, 2, 42]);
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
\Drupal::service('entity_type.manager')->getStorage('node')->delete(\Drupal::service('entity_type.manager')->getStorage('node')->loadMultiple(1, 2, 42));
CODE_AFTER
Expand Down
3 changes: 1 addition & 2 deletions src/Drupal8/Rector/Deprecation/EntityInterfaceLinkRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public function getRuleDefinition(): RuleDefinition
new CodeSample(
<<<'CODE_BEFORE'
$url = $entity->link();
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
$url = $entity->toLink()->toString();
CODE_AFTER
Expand Down
6 changes: 2 additions & 4 deletions src/Drupal8/Rector/Deprecation/EntityLoadRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ public function getRuleDefinition(): RuleDefinition
<<<'CODE_BEFORE'
$entity = ENTITY_TYPE_load(123);
$node = entity_load('node', 123);
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
$entity = \Drupal::entityManager()->getStorage('ENTITY_TYPE')->load(123);
$node = \Drupal::entityManager()->getStorage('node')->load(123);
CODE_AFTER
,
CODE_AFTER,
[
new EntityLoadConfiguration('entity'),
new EntityLoadConfiguration('file'),
Expand Down
7 changes: 3 additions & 4 deletions src/Drupal8/Rector/Deprecation/EntityManagerRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ public function getRuleDefinition(): RuleDefinition
new CodeSample(
<<<'CODE_BEFORE'
$entity_manager = \Drupal::entityManager();
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
$entity_manager = \Drupal::entityTypeManager();
CODE_AFTER
Expand Down Expand Up @@ -134,12 +133,12 @@ public function refactor(Node $node): ?Node
*
* @see DrupalRector\Rector\Deprecation\Base\DBBase
*
* @phpstan-param class-string<Node> $class
*
* @param Node\Expr\Assign $assign
* @param string $class
* @param string $name
*
* @phpstan-param class-string<Node> $class
*
* @return Node|null
*/
public function findInstanceByNameInAssign(Node\Expr\Assign $assign, string $class, string $name): ?Node
Expand Down
3 changes: 1 addition & 2 deletions src/Drupal8/Rector/Deprecation/EntityViewRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public function getRuleDefinition(): RuleDefinition
new CodeSample(
<<<'CODE_BEFORE'
$rendered = entity_view($entity, 'default');
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
$rendered = \Drupal::entityTypeManager()->getViewBuilder($entity
->getEntityTypeId())->view($entity, 'default');
Expand Down
3 changes: 1 addition & 2 deletions src/Drupal8/Rector/Deprecation/FileDefaultSchemeRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public function getRuleDefinition(): RuleDefinition
new CodeSample(
<<<'CODE_BEFORE'
$file_default_scheme = file_default_scheme();
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
$file_default_scheme = \Drupal::config('system.file')->get('default_scheme');
CODE_AFTER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@
<<<'CODE_SAMPLE'
class SomeClassTest {
}
CODE_SAMPLE

,
CODE_SAMPLE,
<<<'CODE_SAMPLE'
class SomeClassTest {
protected $defaultTheme = 'stark'
Expand Down Expand Up @@ -105,7 +103,7 @@
} else {
$scope = $node->getAttribute('scope');
}
$defaultThemeProperty = $classReflection->getProperty('defaultTheme', $scope);

Check failure on line 106 in src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php

View workflow job for this annotation

GitHub Actions / Static analysis with PHPStan (8.2, ^2, phpstan.neon)

Call to deprecated method getProperty() of class PHPStan\Reflection\ClassReflection: Use getInstanceProperty or getStaticProperty
assert($defaultThemeProperty instanceof \PHPStan\Reflection\Php\PhpPropertyReflection);

$reflectionProperty = $defaultThemeProperty->getNativeReflection();
Expand Down
6 changes: 2 additions & 4 deletions src/Drupal8/Rector/Deprecation/GetMockRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,10 @@ public function getRuleDefinition(): RuleDefinition
new ConfiguredCodeSample(
<<<'CODE_BEFORE'
$this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
CODE_AFTER
,
CODE_AFTER,
[
new GetMockConfiguration('Drupal\Tests\BrowserTestBase'),
new GetMockConfiguration('Drupal\KernelTests\KernelTestBase'),
Expand Down
3 changes: 1 addition & 2 deletions src/Drupal8/Rector/Deprecation/LinkGeneratorTraitLRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public function getRuleDefinition(): RuleDefinition
new CodeSample(
<<<'CODE_BEFORE'
$this->l($text, $url);
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
\Drupal\Core\Link::fromTextAndUrl($text, $url);
CODE_AFTER
Expand Down
3 changes: 1 addition & 2 deletions src/Drupal8/Rector/Deprecation/RequestTimeConstRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public function getRuleDefinition(): RuleDefinition
new CodeSample(
<<<'CODE_BEFORE'
$request_time = REQUEST_TIME;
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
$request_time = \Drupal::time()->getRequestTime();
CODE_AFTER
Expand Down
3 changes: 1 addition & 2 deletions src/Drupal8/Rector/Deprecation/SafeMarkupFormatRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public function getRuleDefinition(): RuleDefinition
new CodeSample(
<<<'CODE_BEFORE'
$safe_string_markup_object = \Drupal\Component\Utility\SafeMarkup::format('hello world');
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
$safe_string_markup_object = new \Drupal\Component\Render\FormattableMarkup('hello world');
CODE_AFTER
Expand Down
18 changes: 6 additions & 12 deletions src/Drupal8/Rector/Deprecation/StaticToFunctionRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,38 +68,32 @@ public function getRuleDefinition(): RuleDefinition
new ConfiguredCodeSample(
<<<'CODE_BEFORE'
$length = \Drupal\Component\Utility\Unicode::strlen('example');
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
$length = mb_strlen('example');
CODE_AFTER
,
CODE_AFTER,
[
new StaticToFunctionConfiguration('Drupal\Component\Utility\Unicode', 'strlen', 'mb_strlen'),
]
),
new ConfiguredCodeSample(
<<<'CODE_BEFORE'
$string = \Drupal\Component\Utility\Unicode::strtolower('example');
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
$string = mb_strtolower('example');
CODE_AFTER
,
CODE_AFTER,
[
new StaticToFunctionConfiguration('Drupal\Component\Utility\Unicode', 'strtolower', 'mb_strtolower'),
]
),
new ConfiguredCodeSample(
<<<'CODE_BEFORE'
$string = \Drupal\Component\Utility\Unicode::substr('example', 0, 2);
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
$string = mb_substr('example', 0, 2);
CODE_AFTER
,
CODE_AFTER,
[
new StaticToFunctionConfiguration('Drupal\Component\Utility\Unicode', 'substr', 'mb_substr'),
]
Expand Down
3 changes: 1 addition & 2 deletions src/Drupal9/Rector/Deprecation/AssertFieldByIdRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public function getRuleDefinition(): RuleDefinition
$this->assertFieldById('edit-name', 'Test name');
$this->assertFieldById('edit-description', NULL);
$this->assertFieldById('edit-description');
CODE_BEFORE
,
CODE_BEFORE,
<<<'CODE_AFTER'
$this->assertSession()->fieldExists('edit-name');
$this->assertSession()->fieldValueEquals('edit-name', 'Test name');
Expand Down
Loading
Loading