Skip to content

Modernize legacy code for PHP 8.1 and repo conventions - #1028

Draft
mglaman wants to merge 1 commit into
audit/2-api-conventionsfrom
audit/3-modernization
Draft

Modernize legacy code for PHP 8.1 and repo conventions#1028
mglaman wants to merge 1 commit into
audit/2-api-conventionsfrom
audit/3-modernization

Conversation

@mglaman

@mglaman mglaman commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Part 7 of 9 in the legacy-code audit stack (on top of #1027). Mechanical modernization with no behavior change.

What changed

  • declare(strict_types=1) in the remaining src/ files (the Reflection classes, RecursiveExtensionFilterIterator, DeprecatedHookImplementation).
  • The four bundled Drupal-core forks in src/Drupal/ are marked @internal — they are bootstrap implementation details, not extension points.
  • The six audited concrete rules are final, matching the newer rules.
  • Promoted readonly constructors and typed properties across the audited classes; the dead splFileInfo property is gone.
  • The per-node rebuilt arrays in DiscouragedFunctionsRule and GlobalDrupalDependencyInjectionRule are class constants now.
  • ::class over string FQCNs, str_contains/str_starts_with/str_ends_with over strpos/substr, and the @method isDir() docblock shim replaced with an explicit $this->current()->isDir().
  • Extension::parseInfo() validates that Yaml::parse() returned an array.
  • phpcs.xml raises php_version from 7.4 to 8.1 to match composer.json, so PHPCS actually checks against the supported platform.

Testing

Full suite, self-analysis, and phpcs (with the raised php_version) are green.

🤖 Generated with Claude Code

- declare(strict_types=1) in the remaining src/ files (Reflection
  classes, RecursiveExtensionFilterIterator, DeprecatedHookImplementation).
- Mark the four bundled Drupal-core forks in src/Drupal/ as @internal.
- final on the six audited concrete rules, matching newer rules.
- Promoted readonly constructors and typed properties in the audited
  rules, reflections, Extension, DrupalServiceDefinition, and
  DrupalAutoloader; drop the dead splFileInfo property.
- Class constants for the per-node rebuilt arrays in
  DiscouragedFunctionsRule and GlobalDrupalDependencyInjectionRule.
- ::class instead of string FQCNs where the class is imported.
- str_contains/str_starts_with/str_ends_with over strpos/substr.
- Replace the RecursiveFilterIterator __call shim (@method isDir) with
  an explicit $this->current()->isDir() call.
- Validate Yaml::parse() output in Extension::parseInfo().
- phpcs.xml: raise php_version from 7.4 to 8.1 so PHPCS checks against
  the actual composer platform requirement.
- Drop the self-namespace use in ExtensionDiscovery and fix the
  dcorating_service_id typo in ServiceMap.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mglaman
mglaman force-pushed the audit/3-modernization branch from 3bdc910 to 1035692 Compare August 5, 2026 19:33
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