Fix PHPStan missingType.generics for \ArrayObject not specifying its types [#3563533] | Drupal.org
Skip to search
Can we use first and third party cookies and web beacons to
understand our audience, and to tailor promotions you see
Fix PHPStan missingType.generics for \ArrayObject not specifying its types
Fixed
Project:
Drupal core
Version:
11.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
mondrake
Created:
16 Dec 2025 at 21:14 UTC
Updated:
17 Apr 2026 at 13:52 UTC
Jump to comment:
Most recent
Most recent file
Problem/Motivation
Fix
$ignoreErrors[] = [
'message' => '#^Method Drupal\\\\jsonapi\\\\Normalizer\\\\DataNormalizer\\:\\:normalize\\(\\) return type with generic class ArrayObject does not specify its types\\: TKey, TValue$#',
'identifier' => 'missingType.generics',
'count' => 1,
'path' => __DIR__ . '/modules/jsonapi/src/Normalizer/DataNormalizer.php',
];
and similar.
Proposed resolution
Add PHPDoc to document \ArrayDoc, and narrow types where possible.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Comment
File
Size
Author
#8
3563533-nr-bot_akt9_fe8.txt
547 bytes
needs-review-queue-bot
Issue fork
drupal-3563533
Show commands
Start within a Git clone of the project using the
version control instructions
Add & fetch this issue fork’s repository
Or,
if you do not have
SSH keys set up on git.drupalcode.org
Add & fetch this issue fork’s repository
2 hidden branches
3563533-11.x
plain diff
MR
!15486
Check out this branch for the first time
Check out existing branch, if you already have it locally
3563533-fix-phpstan-missingtype.generics
plain diff
MR
!14118
Check out this branch for the first time
Check out existing branch, if you already have it locally
About issue forks
Comments
Comment
#1
16 December 2025 at 21:14
mondrake
created an issue. See
original summary
or
to post comments
Comment
#2
16 December 2025 at 21:18
mondrake
opened
merge request !14118
or
to post comments
Comment
#3
mondrake
🇮🇹
commented
17 December 2025 at 07:46
Issue summary:
View changes
Status:
Active
» Needs review
or
to post comments
Comment
#4
smustgrave
commented
26 December 2025 at 22:49
should instances like
@return array|string|int|float|bool|\ArrayObject|null
* \ArrayObject is used to make sure an empty object is encoded as an
* object not an array.
Be updated now that the comments are being taken over by core? I mean should the return for each instance only show what it can actually return with a comment that reflects that.
or
to post comments
Comment
#5
mondrake
🇮🇹
commented
30 December 2025 at 13:11
Re. #4: these are all normalization methods that more or less inherit from upstream
"more or less" because not all of them inherit directly, some are just related and the inheritdoc does not really pick from the class hierarchy. That's why I added explicit comments.
That said, the interface definition is
public function normalize(mixed $data, ?string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null;
I already narrowed the return type when I was certain of the returned value, and left the original interface return type in the rest of the instances. Please note that type narrowing may have BC concerns.
or
to post comments
Comment
#6
mondrake
🇮🇹
commented
19 January 2026 at 14:32
Version:
11.x-dev
» main
or
to post comments
Comment
#7
smustgrave
commented
16 March 2026 at 14:21
Status:
Needs review
» Reviewed & tested by the community
Based on #5 believe this is probably good. Don't want to get into the weeds.
or
to post comments
Comment
#8
needs-review-queue-bot
commented
14 April 2026 at 05:38
Status:
Reviewed & tested by the community
» Needs work
Status
File
Size
new
3563533-nr-bot_akt9_fe8.txt
547 bytes
The
Needs Review Queue Bot
tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the
Drupal Contributor Guide
to find step-by-step guides for working with issues.
or
to post comments
Comment
#9
nod_
French
Lille
commented
14 April 2026 at 08:17
Status:
Needs work
» Reviewed & tested by the community
local blip
or
to post comments
Comment
#10
17 April 2026 at 10:34
amateescu
committed
3659d1b9
on
main
task: #3563533 Fix PHPStan missingType.generics for \ArrayObject not...
or
to post comments
Comment
#11
amateescu
commented
17 April 2026 at 10:35
Status:
Reviewed & tested by the community
» Patch (to be ported)
Committed
3659d1b
and pushed to main. Thanks!
We'll need a 11.x MR for backporting.
or
to post comments
Comment
#12
17 April 2026 at 10:35
amateescu
closed
merge request !14118
or
to post comments
Comment
#13
mondrake
🇮🇹
commented
17 April 2026 at 11:20
Version:
main
» 11.x-dev
or
to post comments
Comment
#14
17 April 2026 at 11:28
mondrake
opened
merge request !15486
or
to post comments
Comment
#15
mondrake
🇮🇹
commented
17 April 2026 at 11:32
Status:
Patch (to be ported)
» Needs review
11.x port
or
to post comments
Comment
#16
amateescu
commented
17 April 2026 at 12:29
Status:
Needs review
» Fixed
Committed
ca9f9be
and pushed to 11.x. Thanks!
or
to post comments
Comment
#17
17 April 2026 at 12:29
Now that this issue is closed,
review the
contribution record
As a contributor, attribute any organization that helped you, or if you volunteered your own time.
Maintainers, credit people who helped resolve this issue.
or
to post comments
Comment
#18
17 April 2026 at 12:29
amateescu
closed
merge request !15486
or
to post comments
Comment
#19
17 April 2026 at 12:30
amateescu
committed
ca9f9beb
on
11.x
task: #3563533 Fix PHPStan missingType.generics for \ArrayObject not...
or
to post comments
Comment
#20
idebr
commented
17 April 2026 at 13:52
This broke HAL's \Drupal\hal\Normalizer\FieldNormalizer and subsequently webform tests:
or
to post comments
Contribution record
Parent issue
Child issues
#3569674: Fix remaining PHPStan missingType.generics errors (level 1)
Add child issue
clone issue
Referenced by
#3585446: PHP Fatal error: FieldNormalizer::normalize must be compatible with ListNormalizer::normalize
Infrastructure management for Drupal.org provided by
Need a Drupal 7 extended support partner? Consider Tag1.
News items
News
Planet Drupal
Social media
Sign up for Drupal news
Security advisories
Jobs
Our community
Community
Services
Training
Hosting
Contributor guide
Groups & meetups
DrupalCon
Code of conduct
Documentation
Documentation
Drupal Guide
Drupal User Guide
Developer docs
API.Drupal.org
Drupal code base
Download & Extend
Drupal core
Modules
Themes
Distributions
Governance of community
About
Web accessibility
Drupal Association
About Drupal.org
Drupal is a
registered trademark
of
Dries Buytaert