### Problem

`ShortcodeService` triggers PHP deprecation notices on PHP 8.4 because several `FilterInterface` parameters default to `NULL` without being explicitly nullable.

### Steps to Reproduce

1. Install Shortcode 2.0.3 on Drupal 11.
2. Run the site with PHP 8.4 or newer and deprecation notices enabled.
3. Process text through a text format/filter that uses Shortcode.

### Actual Result

The following deprecation notices are emitted:

Deprecated: Drupal\shortcode\ShortcodeService::getShortcodePlugins(): Implicitly marking parameter $filter as nullable is deprecated, the explicit nullable type must be used instead in modules/contrib/shortcode/src/ShortcodeService.php on line 89

Deprecated: Drupal\shortcode\ShortcodeService::process(): Implicitly marking parameter $filter as nullable is deprecated, the explicit nullable type must be used instead in modules/contrib/shortcode/src/ShortcodeService.php on line 215

Deprecated: Drupal\shortcode\ShortcodeService::postprocessText(): Implicitly marking parameter $filter as nullable is deprecated, the explicit nullable type must be used instead in modules/contrib/shortcode/src/ShortcodeService.php on line 360

### Expected Result

No PHP deprecation notices should be emitted on PHP 8.4.

### Proposed Fix

Change the affected method signatures to use explicit nullable types:

public function getShortcodePlugins(?FilterInterface $filter = NULL, bool $reset = FALSE): array
public function process($text, string $langcode = Language::LANGCODE_NOT_SPECIFIED, ?FilterInterface $filter = NULL): string
public function postprocessText($text, string $langcode, ?FilterInterface $filter = NULL): string

### Notes

This is a PHP 8.4 compatibility issue. The change is type-compatible with the existing default `NULL` behavior.

CommentFileSizeAuthor
#3 3605865-php-8.4-deprecations.patch1.44 KBmikell

Issue fork shortcode-3605865

Command icon Show commands

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

kaipipek created an issue. See original summary.

mikell made their first commit to this issue’s fork.

mikell’s picture

StatusFileSize
new1.44 KB

Pushed code to branch, ready for review. Added patch file.

mikell’s picture

Status: Active » Needs review