Skip to content

Add array value types to form, plugin, widget and views stubs - #1097

Open
giuseppe-esposito-87 wants to merge 3 commits into
mglaman:mainfrom
giuseppe-esposito-87:feat/stub-array-value-types
Open

giuseppe-esposito-87 wants to merge 3 commits into
mglaman:mainfrom
giuseppe-esposito-87:feat/stub-array-value-types

Conversation

@giuseppe-esposito-87

@giuseppe-esposito-87 giuseppe-esposito-87 commented Nov 11, 2026 •

Copy link
Copy Markdown

🤖 This was written by an AI agent on behalf of @giuseppe-esposito-87 (claude-code/claude-opus-5-5).

Adds array value types to the stubs of common Drupal form, plugin, field and views APIs. Methods that implement them with {@inheritdoc} no longer report "no value type specified in iterable type array", so projects do not need to ignore missingType.iterableValue for them.

  • Forms: FormInterface, ConfigFormBaseTrait, PluginFormInterface, EntityForm and EntityFormInterface.
  • Plugins: create(), plugin constructors, ConfigurableInterface and DeriverInterface.
  • Fields: widgets, the formatter constructor, FieldItemInterface and PluginSettingsInterface.
  • Entities: list builders and the access control handler.
  • Other: typed data, main content renderers and views plugins.

Empty stubs are added for the core and Symfony classes these stubs reference, so the stub validation test passes.

Behavior note: validateConfigurationForm() and the views buildOptionsForm() are typed @return void, matching core. validateForm(), submitForm() and submitConfigurationForm() are not stubbed, because some core implementations return values from them.

PHPUnit, PHPCS and PHPStan pass with PHP 8.4 and Drupal 11.4. The new rule test fails without these stubs and passes with them.

Core baseline check: it fails only because core's baseline no longer matches. 271 entries are errors these stubs fix, and 14 are existing errors whose message now reads array<mixed> instead of array. A local run against core HEAD shows no other new errors.

Methods that inherit their PHPDoc with {@inheritdoc} from these core
classes and interfaces now get typed array parameters and return values,
so level 6+ no longer reports a missing iterable value type for them.

Covers forms, plugin forms, plugin create() and constructors, field
widgets and formatters, field items, entity list builders, entity forms,
access control handlers, derivers, typed data and views plugins. Empty
stubs are added for the classes these stubs reference so StubTest passes.

Assisted-by: claude-code/claude-opus-5-5
@giuseppe-esposito-87
giuseppe-esposito-87 marked this pull request as draft November 11, 2026 10:46
Core returns values from some validateForm(), submitForm() and
submitConfigurationForm() implementations, for example
ContentEntityForm::validateForm() returns the entity. A void return type in
the stubs reported those as errors, so the stubs no longer declare these
methods.

Assisted-by: claude-code/claude-opus-5-5
Core passes PluginDefinitionInterface objects to derivers of object-based
plugin types such as layouts, as DeriverInterface documents.

Assisted-by: claude-code/claude-opus-5-5
@giuseppe-esposito-87
giuseppe-esposito-87 marked this pull request as ready for review November 11, 2026 11:19
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