Skip to content

Feature/digest rectors#2

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

Feature/digest rectors#2
bbrala wants to merge 162 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 8, 2026 13:42
…11.4 deprecations

Includes rule to replace _filter_autop(), _filter_html_escape(), and _filter_html_image_secure_process() with plugin.manager.filter createInstance() chains, addressing issue #3226806.
…` for type-guard checklist

Removed the deprecated `rector-type-check-review` skill and consolidated its type-guard audit patterns into the updated `rector-qa` skill. Enhanced `rector-qa` with bulk mode (`all`), checklist integration for `AT-RISK` patterns, and detailed fix patterns for better consistency.
…Rector, and VersionedFunctionToServiceRector to generic namespace

Move DrupalServiceRenameRector, FunctionToFirstArgMethodRector, and their
ValueObject configuration classes to src/Rector/ so they are available as
generic, version-agnostic rectors alongside the existing FunctionToServiceRector
and FunctionToStaticRector.

The Drupal8, Drupal9, and Drupal10 originals are kept as thin BC wrappers that
extend the generic classes and preserve their original configure() type
validation. VersionedFunctionToServiceConfiguration now extends
FunctionToServiceConfiguration (the two were field-for-field identical).
…or to skill docs

Update the generic rector decision table and configuration syntax examples in
digest-to-rector-prompt.md, and the phase reference table in rector-discover,
to include the two newly promoted generic rectors.
…eRector and FunctionToFirstArgMethodRector

Both generic rectors now extend AbstractDrupalCoreRector and their configuration
classes implement VersionedConfigurationInterface. Passing an introducedVersion
triggers the standard DeprecationHelper::backwardsCompatibleCall() wrapping just
like FunctionToServiceRector.

The D8/D9 BC wrapper configs override __construct to keep the old two-arg
signature and pass an empty version string to the parent, which causes
AbstractDrupalCoreRector to apply the rule unconditionally with no BC wrapping —
preserving the existing behaviour for D8/D9 entries.
…adersRector with FunctionToFirstArgMethodRector

Both custom rectors were identical in shape to FunctionToFirstArgMethodRector
(single-argument function → method call on that argument with BC wrapping).
Replaced both with config entries on the generic rector and deleted the now-
redundant custom classes and their tests. Generic tests migrated to
tests/src/Rector/Deprecation/FunctionToFirstArgMethodRector/.
…s ≥10

Updated `generate-rector-index.php` to dynamically scan deprecation directories for Drupal versions ≥10 in descending order. Adjusted `scanImplementedClasses` to handle relative paths for source and test files. Enhanced SKILL.md with new transformation patterns.
Each rector now has two @see lines — the Drupal.org issue and the change
record — so the class is findable regardless of which reference appears
in a digest file or deprecation notice.
…tion entries

Config-only rector entries now carry two comment lines — the Drupal.org
issue and the change record — matching the docblock convention used in
custom rector classes.
…tor-implement

rector-qa Pass 4: explicit three-source lookup (issue markdown → Drupal.org
fetch → drupal-core grep) for finding the change record number; requires
BOTH issue and CR @see lines in every rector docblock.

rector-implement: automatically runs rector-qa after each implementation
and adds it to the pre-flight checklist.

digest-to-rector-prompt: Step 6 templates now include the two-@see pattern.
…rector-prompt

Step 2 now explicitly extracts the change record number from the issue
markdown alongside introduced version, removal version, FQCN, and
description. Step 3 also triggers when the CR number is missing, and
instructs fetching the Drupal.org issue page to find it via the
"Change records for this issue" block.

This ensures the [change-record-number] placeholder in the Step 6
templates is always populated before writing the rector class.
Split into two parts:
- FunctionToStaticRector config entry for the direct FuncCall form (BC-wrapped, 11.3.0)
- Custom FileManagedFileSubmitRector for the string callback form (String_ → Array_ callable)
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