Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

AI Deprecation Detector

No security coverage Under active development

Part of the AI ecosystem · 345 projects

AI Deprecation Detector identifies deprecated Drupal, Symfony and PHP APIs used in your custom code and helps prepare your site for future major-version upgrades. It explains what needs to change, applies safe automatic fixes where possible, and uses an AI provider to suggest fixes for more complex cases. Every proposed change is presented for review before it is applied.

The module includes its own static analysis engine and does not require external development tools for basic scanning. It analyses your code against the deprecations applicable to the installed versions of Drupal core, contributed projects and libraries.

Features

Find deprecated code

  • Built-in static analysis: Scans code without requiring additional tools. Resolves namespaces and imports, tracks variable types through parameter and property declarations, object instantiation, @var annotations, service definitions and return types. Scanning 65 projects containing 3,000 files takes only a few seconds.
  • Comprehensive deprecation detection:
    • Classes, interfaces and traits that are imported, extended, implemented, instantiated, type-hinted or referenced as attributes.
    • Deprecated methods, including inherited methods, service calls, chained calls and overrides of deprecated methods.
    • Functions, class constants and global constants, such as REQUIREMENT_OK.
    • Deprecated services referenced in PHP code and *.services.yml files.
    • Hooks implemented procedurally or through #[Hook] attributes.
    • Asset libraries referenced in PHP, YAML and Twig templates.
    • Dependencies on deprecated or obsolete modules and themes.
    • Deprecated PHP syntax and features, including implicitly nullable parameter types and ${var} string interpolation, as well as the deprecated Twig spaceless filter.
    • .info.yml files that do not declare compatibility with the next major Drupal version.
  • Confidence-based reporting: Classifies findings as certain or possible. Possible findings are used when a deprecated method is called on an object whose type cannot be determined. Common method names are not reported solely because another method with the same name is deprecated.
  • Optional PHPStan integration: Run PHPStan with the deprecation rules and Drupal extensions from the same interface when the required packages are installed.
  • Optional runtime recording: Records deprecations triggered by custom code during site execution, helping identify dynamic calls that static analysis cannot resolve.

Understand the findings

  • Detailed explanations: View the deprecation notice, recommended replacement, version in which the API is removed, relevant change record and surrounding source code.
  • Reports and history: Review findings by project, filter results, export reports as CSV, track previous scans and view deprecation information on the Drupal status report.
  • AI-powered explanations: Integrate with the AI module to understand why an API is deprecated and how to update your code.

Fix deprecated code

  • Automatic fixes: Handles supported mechanical changes, including nullable parameter types, ${var} string interpolation, deprecated constants, renamed methods and functions, service and library IDs, the Twig spaceless filter, and core_version_requirement. Automatic fixes are limited to the relevant line of code.
  • AI-assisted fixes: For findings without an automatic fix, an AI provider can propose an updated function and add the required imports. If the generated code is invalid, the module makes one correction attempt before rejecting the fix.
  • Review before applying: Inspect every proposed change as a diff, including any warnings, before applying it.
  • Bulk fixes: Select individual findings or multiple findings to apply supported automatic fixes in one operation.
  • Safety controls:
    • Browser-based code changes are disabled by default and require explicit administrative configuration and a dedicated permission.
    • Changes are applied only if the target file has not changed since the fix was proposed and the resulting PHP or YAML is valid.
    • Applied fixes are logged and can be reverted.

Automate scans and fixes

  • Drush integration: Scan projects, apply fixes and request AI explanations from the command line, with JSON output available for automation.
  • Continuous integration: Use --fail-on=certain to fail a scan when certain deprecations are detected, helping prevent deprecated APIs from entering your codebase.

Requirements

  • Drupal 10.3 or later, or Drupal 11.
  • Optional AI integration: The AI module and a configured chat provider, such as OpenAI or Anthropic, for AI-powered explanations and fixes.
  • Optional PHPStan integration: phpstan/phpstan-deprecation-rules and mglaman/phpstan-drupal, available through the drupal/core-dev development dependencies.

Installation

Install the module using Composer and enable it with Drush, following the standard Drupal contributed module installation process. For additional information, see Installing Drupal Modules.

composer require drupal/ai_deprecation_detector
drush pm:enable ai_deprecation_detector

For the safest workflow, run the module on a development or staging environment where you can review findings, apply fixes and test the results before deploying changes to production.

Usage

  1. Run a scan: Navigate to Reports » Deprecated code » Scan. Custom projects are selected by default. Use Select all to change the selection, and include contributed projects when needed.
  2. Review findings: Open Reports » Deprecated code. Filter results by project, finding type or confidence level. Select Details to inspect the affected code, recommended replacement and relevant change record.
  3. Apply fixes: Choose an available automatic fix or request an AI-generated fix. Review the proposed diff before applying it. You can also select multiple findings and choose Apply automatic fixes.
  4. Ignore reviewed findings: Ignore findings that you have reviewed and intentionally accepted. They remain ignored in subsequent scans while the affected code remains unchanged.

Configuration

Configure the module at Configuration » Development » AI Deprecation Detector (/admin/config/development/ai-deprecation-detector).

Available settings include:

  • Whether to report possible matches and include test files in scans.
  • Excluded paths and the maximum file size to analyse.
  • PHPStan executable path, memory limit and execution time limit.
  • Runtime deprecation recording.
  • Browser-based code fixes, disabled by default.
  • AI explanations and fixes, including permission to send code excerpts to the configured AI provider and the number of surrounding lines to include.

Permissions

  • View deprecation reports: Allows users to view findings, including file paths and source code excerpts.
  • Administer AI Deprecation Detector: Allows users to manage settings, run scans, ignore findings and request AI explanations.
  • Apply fixes of deprecated code: Allows users to modify source files when browser-based fixes are enabled. Grant this permission only to trusted users, preferably on development environments.

Support

Report bugs, suggest improvements and request new features through the AI Deprecation Detector issue queue.

Drupal 10–11

Ask your assistant about AI Deprecation Detector

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Oct 2026
Latest release
15 hours ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Core PHP Release date
1.0.0 Stable 10–11 Oct 22, 2026