Skip to content

Feature/digest rectors#2

Open
bbrala wants to merge 106 commits intomainfrom
feature/digest-rectors
Open

Feature/digest rectors#2
bbrala wants to merge 106 commits intomainfrom
feature/digest-rectors

Conversation

@bbrala
Copy link
Copy Markdown
Owner

@bbrala bbrala commented Apr 30, 2026

An experiement rewriting rector rules from a digest to drupal-rector. Using confgiurable rectors where possible.

bbrala added 30 commits April 30, 2026 12:53
Creates src/Drupal11/Rector/Deprecation/ and tests/src/Drupal11/Rector/Deprecation/
directory structure for incoming Drupal 11 deprecation rules. Adds stub
Drupal11SetList.php following the established Drupal10SetList pattern.
Captures the structural differences between drupal-digests AI-generated rules
and drupal-rector conventions: namespace, base class selection, BC wrapping
decision tree, fixture format, test config patterns, and multi-node-type handling.
Reusable 14-step AI prompt that converts any drupal-digests rector rule into a
fully drupal-rector-compliant implementation: namespaced rule class, test class,
fixture file, and test config. Includes BC decision tree, class templates for both
AbstractRector and AbstractDrupalCoreRector patterns, and a verification checklist.
…ecationsRector

Validates the conversion workflow on two real drupal-digests rules:
- FormLocationRector (issue #3550054): ClassConstFetch replacement, no BC wrapping,
  replaces deprecated CommentItemInterface constants with FormLocation enum cases.
- LanguageModuleFunctionDeprecationsRector (issue #3574727): FuncCall → StaticCall/MethodCall,
  BC-wrapped via AbstractDrupalCoreRector, replaces deprecated language.module functions
  with OOP equivalents.

Updates Drupal stub VERSION from 10.99.x-dev to 11.99.x-dev so Drupal11 rules fire in
tests. All 95 tests pass (93 existing + 2 new).
Implements Drupal 11.4.0 deprecation fixes using existing data-driven rectors
rather than custom classes, following the pattern established by Drupal 8/9/10:

- CommentItemInterface::FORM_BELOW/FORM_SEPARATE_PAGE → Drupal\comment\FormLocation
  (ClassConstantToClassConstantRector, no BC wrap — ClassConstFetch is not CallLike)
- language_configuration_element_submit → LanguageConfiguration::submit
  (FunctionToStaticRector, BC-wrapped for 11.4.0)
- language_process_language_select → \Drupal::service('…')->processLanguageSelect()
  (FunctionToServiceRector, BC-wrapped for 11.4.0)

Also scaffolds src/Drupal11/ and tests/src/Drupal11/ directories and adds
Drupal11SetList stub, plus digest-to-rector conversion prompt and mapping docs.
Bumps Drupal VERSION stub to 11.99.x-dev so Drupal11 rules fire in tests.
… for version-specific test scenarios

Replaces the broken namespaced-class Drupal hack in BackwardsCompatibilityActionAnnotationToAttributeRectorTest
with a proper setUp/tearDown pattern. Updates docs to describe the new mechanism.
…Rector

Previously backwardsCompatibleCall wrapping only applied when both the
old and new nodes were CallLike (FuncCall, MethodCall, StaticCall, etc.).
The restriction was in AbstractDrupalCoreRector, not in DeprecationHelper
itself, which accepts any callable.

Broaden the guard to Node\Expr so that non-CallLike transformations such
as ClassConstFetch → ClassConstFetch and ClassConstFetch → PropertyFetch
also get BC-wrapped when the introduced version supports it.

Add a test stub rector (ClassConstFetchBCRector) and fixture to cover
the new Expr → Expr path.
…eplacements

FileSystemInterface::EXISTS_RENAME, EXISTS_REPLACE, and EXISTS_ERROR were
deprecated in drupal:10.3.0 and removed in drupal:12.0.0 (issue #3575575).
Replaced by the \Drupal\Core\File\FileExists backed enum.
- template_preprocess_{container,html,page,links,time,datetime_form,
  datetime_wrapper}() → ThemePreprocess/DatePreprocess service methods
  (issue #3501136)
- SystemManager::REQUIREMENT_{OK,WARNING,ERROR} → RequirementSeverity
  enum cases (issue #3575841)
node_mass_update() was deprecated in drupal:11.3.0 and removed in
drupal:13.0.0 (issue #3571623). Replaced by NodeBulkUpdate::process()
via the service container.
…rable rectors

FunctionToServiceRector (29 functions across 9 modules, issue numbers below):
- ckeditor5_filter_format_edit_form_submit, _update_ckeditor5_html_filter
  → Ckeditor5Hooks service (#3566792)
- _dblog_get_message_types, dblog_filters → DbLogFilters service (#3560398)
- contact_user_profile_form_submit, contact_form_user_admin_settings_submit
  → ContactFormHooks service (#3566888)
- 6× content_translation_* → content_translation.manager /
  ContentTranslationEnableTranslationPerBundle / ContentTranslationHooks (#3548571)
- locale_translation_batch_update_build, _batch_fetch_build → LocaleFetch (#3572339)
- 7× locale_translation_* → locale.project / LocaleSource (#3569328)
- 6× menu_ui_* → MenuUiUtility / MenuUiHooks (#3571400)
- text_summary → TextSummary::generate (#3568387)
- user_form_process_password_confirm → UserThemeHooks (#3582106)

FunctionToStaticRector (4 functions):
- views_ui_form_button_was_clicked → ViewsFormHelperTrait::formButtonWasClicked
- views_ui_add_limited_validation, _add_ajax_wrapper, _nojs_submit
  → ViewsFormAjaxHelperTrait (#3035340)

ClassConstantToClassConstantRector (6 constants):
- CommentItemInterface::HIDDEN/CLOSED/OPEN → CommentingStatus enum (#3574661)
- CommentInterface::ANONYMOUS_* → AnonymousContact enum (#3574661)
Replaces deprecated ModuleHandlerInterface::getName($module) calls with
\Drupal::service('extension.list.module')->getName($module), BC-wrapped
for sites running Drupal 10.3+.
…ist rename

Adds AliasManager::pathAliasWhitelistRebuild() -> pathAliasPrefixListRebuild()
rename (drupal:11.1.0, issue #3151086). Also registers DRUPAL_111/112/113
constants in Drupal11SetList.
…n rule

Replaces invalidateAll() with deleteAll() on CacheBackendInterface objects
(drupal:11.2.0, issue #3498947).
…r issue #3543035

Replaces CommentManagerInterface::getCountNewComments() with
\Drupal::service(\Drupal\history\HistoryManager::class)->getCountNewComments(),
BC-wrapped for drupal:11.3.0.
…6062

Replaces NodeStorage::revisionIds() and userRevisionIds() with equivalent
entity query chains (drupal:11.3.0, removed in drupal:13.0.0).
Replaces deprecated PluginBase::isConfigurable() calls with
instanceof \Drupal\Component\Plugin\ConfigurableInterface checks
(drupal:11.1.0, removed in drupal:12.0.0).
Replaces SessionManager::delete($uid) with
\Drupal::service(UserSessionRepositoryInterface::class)->deleteAll($uid),
BC-wrapped for drupal:11.4.0.
…sue #3490200

Renames fetchColumn() to fetchField() on database statements, skipping
PDO's native $this->clientStatement->fetchColumn() (drupal:11.2.0).
Replaces ModuleHandler::loadAllIncludes() with an explicit foreach loop
over getModuleList() + loadInclude() (drupal:11.3.0, removed in 13.0.0).
…Rector

- ReplaceRebuildThemeDataRector: replaces ThemeHandlerInterface::rebuildThemeData()
  with extension.list.theme service chain (drupal:10.3.0, issue #3571068)
- ViewsPluginHandlerManagerRector: replaces Views::pluginManager() and
  Views::handlerManager() with Drupal::service() equivalents (drupal:11.4.0, issue #3566424)
…all removal

Handles 11 deprecated Drupal functions across versions 11.2–11.4 that have been
removed with no direct replacement, using a configurable accumulation pattern
so multiple version config files can each add their function list.
…ting removal

$settings['state_cache'] deprecated in drupal:11.0.0 — state caching is permanently
enabled. Adds drupal-11.0-deprecations.php config file and DRUPAL_110 set list constant.
ModuleHandlerInterface::addModule() and addProfile() are no-ops since drupal:11.2.0
and removed in drupal:12.0.0. Uses isObjectType() type check to target only calls
on ModuleHandlerInterface implementors.
LinkWidget::validateTitleElement() deprecated in drupal:11.4.0, removed in drupal:12.0.0.
Validation is now handled by LinkTitleRequiredConstraint on the LinkItem field type.
\$form['#submit'][] = 'automated_cron_settings_submit' deprecated in drupal:11.4.0,
removed in drupal:13.0.0. Config saving is now handled automatically via
#config_target on the interval element.
- drupal-11.2: FunctionCallRemovalRector (template_preprocess, 5 update manager funcs),
  RemoveModuleHandlerAddModuleCallsRector
- drupal-11.3: FunctionCallRemovalRector (block_content_add_body_field)
- drupal-11.4: FunctionCallRemovalRector (views_ui contextual suppress funcs,
  automated_cron_settings_submit), RemoveLinkWidgetValidateTitleElementRector,
  RemoveAutomatedCronSubmitHandlerRector
REQUEST_TIME constant was deprecated in drupal:8.3.0 and removed in drupal:11.0.0.
Replaces all uses with \Drupal::time()->getRequestTime().
JSONAPI_FILTER_AMONG_* global constants deprecated in drupal:11.3.0, removed in
drupal:13.0.0. Replaced by \Drupal\jsonapi\JsonApiFilter::AMONG_* class constants.
bbrala added 30 commits May 1, 2026 12:30
…ass name which would probably break. Test confirmed that.
…alled variable is to make sure we don't break other code
…ually only change `Drupal\migrate\Plugin\migrate\id_map\Sql`
…t classes. Rather we miss stuff than we over-apply stuff
…oduleCallsRector, RemoveViewsRowCacheKeysRector to AT-RISK summary
17 rector rules only return Node|null but declared mixed, triggering
PHPStan return.unusedType errors. Narrow the native return type to ?Node
to match actual behaviour.
…DE|null

4 rector rules that only return NodeVisitor::REMOVE_NODE or null declared
mixed, triggering return.unusedType. Add phpdoc to narrow the declared
type (native union cannot express a class constant).
…r::refactor()

The method returns Node, NodeVisitor::REMOVE_NODE, or null but declared
mixed, triggering return.unusedType. Add phpdoc to narrow the declared
type (native union cannot express a class constant).
14 rector rules accessed node-subclass properties directly on Node,
triggering property.notFound and method.notFound errors. Adding assert()
as the first line of refactor() narrows the type to match getNodeTypes().

Also removes two now-provably-dead guards exposed by the type narrowing:
- RemoveViewsRowCacheKeysRector: ArrayItem instanceof check (always true)
- ReplaceFieldgroupToFieldsetRector: null check on item (always false)
…ample

Double-quoted string caused $editor to be interpreted as a PHP variable
interpolation. Changed to single-quoted string to fix PHPStan error
variable.undefined.
…rors

# Conflicts:
#	tests/src/Drupal10/Rector/Deprecation/ActionAnnotationToAttributeRector/BackwardsCompatibilityActionAnnotationToAttributeRectorTest.php
PHPUnit 12 dropped support for @dataProvider annotations. Replace with
#[\PHPUnit\Framework\Attributes\DataProvider('provideData')] attribute
across all 52 affected test files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant