Fix PHPStan missingType.generics for FieldItemListInterface not specifying its type

Created on 29 December 2024, 3 months ago

Problem/Motivation

Fix

i$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\ContentEntityBase\\:\\:getTranslatedField\\(\\) return type with generic interface Drupal\\\\Core\\\\Field\\\\FieldItemListInterface does not specify its types\\: T$#',
	'identifier' => 'missingType.generics',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Entity/ContentEntityBase.php',
];

and similar.

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component

base system

Created by

๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @mondrake
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • Merge request !10730Closes #3496417 โ†’ (Open) created by mondrake
  • Pipeline finished with Failed
    3 months ago
    Total: 114s
    #381042
  • Pipeline finished with Failed
    3 months ago
    Total: 122s
    #381066
  • Pipeline finished with Failed
    3 months ago
    Total: 115s
    #381067
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    phpstan-drupal has a stub that defines FieldItemListInterface as a generic, so we need to pass the type in the PHPDocs here.

    See https://github.com/mglaman/phpstan-drupal/blob/main/stubs/Drupal/Core/Fi...

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    TBH I think itโ€™s nonsense to have core lacking appropriate PHPDoc, for drupal-phpstan to write a stub gapfill, and then that gapfill to force back core implementationsโ€™ PHPDocs to be adjustedโ€ฆ

    I would suggest to move the definitions in the stub from drupal-php to core as part of this issue.

  • Pipeline finished with Success
    3 months ago
    Total: 10281s
    #381241
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

    phpstan-drupal uses a stub provider, so we can fix here and back port anything to phpstan-drupal and use a version check on Drupal to decide if the phpstan-drupal stub should be loaded or not

  • Pipeline finished with Failed
    3 months ago
    Total: 463s
    #381314
  • Pipeline finished with Failed
    3 months ago
    Total: 424s
    #381323
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Done #7 for the Drupal core part (I think).

  • Pipeline finished with Success
    3 months ago
    Total: 628s
    #381340
  • Pipeline finished with Success
    3 months ago
    Total: 819s
    #381799
  • Pipeline finished with Failed
    3 months ago
    Total: 498s
    #381820
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Left a comment on the MR but leaving in review for someone more familiar

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Thanks for the response @mglaman. Moving to NW for rebase.

    If you are another contributor eager to jump in, please allow the original poster @mglaman or @mondrake at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Rebased, only merge conflicts resolved.

  • Pipeline finished with Success
    3 months ago
    Total: 893s
    #388905
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Rebase seems good.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance nod_ Lille

    merge conflict

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    merged with 11.x, no conflicts. Dunno why GitLab still reports a merge error.

  • Pipeline finished with Success
    2 months ago
    Total: 785s
    #411063
  • Pipeline finished with Failed
    about 2 months ago
    Total: 607s
    #412771
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    I'm really not sure about using templates like this. I realise I'm in the minority using vim (and without whatever vim support would take advantage of this, there's probably something somewhere), but don't think I'm the only one. There's also reading docs on api.drupal.org or gitlab which people sometimes do.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    appears to need a rebase

    If you are another contributor eager to jump in, please allow the previous poster at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    The weirdness here is that this MR is practically just a c/p of (some of) the stubs that are defined in mglaman/phpstan-drupal. The difference is the use of FQCN as per Drupal code standards vs class names and use imports.

    If we don't do this, Drupal core is not compatible with its own PHPStan tooling. Therefore we should remove the stubs from mglaman/phpstan-drupal if we aim at clearing the baseline... fun.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Success
    about 1 month ago
    Total: 1193s
    #434840
  • Status changed to Needs work 30 days ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Appears some feedback was added to the MR.

Production build 0.71.5 2024