Closed (won't fix)
Project:
Shortcode
Version:
3.0.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
3 Sep 2026 at 09:07 UTC
Updated:
7 Sep 2026 at 14:21 UTC
Jump to comment: Most recent
The 2.x codebase does not meet current Drupal coding standards / best practices, and has
accumulated several inconsistencies:
Shortcode plugin type (@Shortcode(...), discovered viaDrupal\shortcode\Annotation\Shortcode) and its two Filter plugins@Filter(...)) still use docblock annotations instead of PHP attributes.create() boilerplate everywhere. EveryContainerFactoryPluginInterface plugin (Shortcode,ShortcodeCorrector, ShortcodeBase, BlockShortcode,ImageShortcode) hand-writes a create() method, even thoughDrupal\Core\Plugin\PluginBase::create() (parent of both FilterBase andShortcodeBase) already autowires constructor arguments via reflection.ShortcodeBase::getMediaFileUrl() / getImageProperties() callMedia::load() statically instead of injecting entity_type.manager, andDrupal\Core\Language\Language class instead ofDrupal\Core\Language\LanguageInterface.ShortcodeService uses drupal_static() three times for memoizationcore_version_requirement. All three.info.yml files (shortcode, shortcode_basic_tags,shortcode_example) declare ^9.3 || ^10 || ^11, but the code already#[Hook] attributes, which require Drupal 11.1+ — the stated floor is alreadyshortcode.module andshortcode_basic_tags.module each contain a thin #[LegacyHook]-wrapped#[Hook] method via\Drupal::service(...) — unnecessary, since Drupal's hook-attribute discovery findsShortcodeService::isBool() isshortcode.module /shortcode_basic_tags.module each had a duplicate/misplaced @filedeclare(strict_types=1); and full param/return type hints onprocess()/tips()/settingsForm() overrides.Not applicable — this is a code-quality/modernization task, not a bug. For evidence, see:
src/Plugin/Filter/Shortcode.php, src/Plugin/Filter/ShortcodeCorrector.php — annotations + manual create().src/Plugin/ShortcodeBase.php — static Media::load(), manual create().src/ShortcodeService.php — drupal_static() usage, unused isBool().shortcode_basic_tags/src/Plugin/Shortcode/*.php — deprecated Language class usage.shortcode.info.yml, shortcode_basic_tags/shortcode_basic_tags.info.yml, shortcode_example/shortcode_example.info.yml — core_version_requirement.Drupal\shortcode\Attribute\Shortcode PHP attribute (mirroring today's annotation fields). ShortcodePluginManager discovers both the new attribute and the legacy @Shortcode annotation simultaneously, so third-party modules with un-migrated Shortcode plugins keep working. This module's own plugins (shortcode_basic_tags, shortcode_example) and its two Filter plugins are converted to attributes (#[Filter(...)] / #[Shortcode(...)]) now.create() methods; rely on PluginBase::create()'s built-in autowiring. Add two FQCN service aliases to shortcode.services.yml (Drupal\shortcode\ShortcodeService: '@shortcode', Drupal\shortcode\ShortcodePluginManager: '@plugin.manager.shortcode'), the same pattern core uses for its own services, so plain type-hinted constructors resolve without needing #[Autowire] attributes. Convert all plugin constructors to promoted, typed properties.MediaUrlResolverInterface/MediaUrlResolver service (injecting entity_type.manager, no static calls), injected into ShortcodeBase; ImageShortcode drops its redundant separate entity-type-manager injection.Language → LanguageInterface everywhere; replace drupal_static() with instance properties; remove isBool() and stray debug comments.declare(strict_types=1); and full param/return types across all plugin classes; fix the duplicate/misplaced @file docblocks.#[LegacyHook] wrappers; keep only the OOP #[Hook] methods.core_version_requirement to ^11.1 || ^12 on all three .info.yml files.ShortcodeService::process() (nesting, self-closing tags, escaping, unknown/disabled tags) as a safety net, then decompose the method into smaller named private steps with no behavior change.No change to shortcode syntax, rendered markup, or the settings-form UI is intended. The existing Functional test suite (ShortcodeTest) is the regression baseline throughout.
Shortcode PHP attribute class; wire dual attribute/annotation discovery in ShortcodePluginManager.Filter/ShortcodeCorrector to #[Filter(...)]; convert all shortcode_basic_tags and shortcode_example plugins to #[Shortcode(...)].create() methods module-wide; promote/type constructors.MediaUrlResolver service; update ShortcodeBase and ImageShortcode.Language class usage with LanguageInterface.drupal_static() with instance properties in ShortcodeService; remove dead code.declare(strict_types=1); and full type hints module-wide; fix duplicate/misplaced @file docblocks.core_version_requirement in all three .info.yml files.ShortcodeService::process(); decompose the method.ShortcodeTest must keep passing unchanged.None.
Drupal\shortcode\Attribute\Shortcode PHP attribute for declaring Shortcode plugins (existing @Shortcode annotation continues to work — no break for third-party Shortcode plugins).MediaUrlResolverInterface/MediaUrlResolver service.ShortcodeBase's constructor signature changes (adds the injected MediaUrlResolverInterface; drops manual create()) — a break only for third-party code that extends ShortcodeBase and overrides create()/__construct() directly; plugins that only override process()/tips() are unaffected.core_version_requirement raised to ^11.1 || ^12 (drops previously-inaccurate claimed support for ^9.3/^10).None.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
denes.szabo commentedComment #5
denes.szabo commentedClosed, wrong base branch.