Problem/Motivation

Amongst the "new" errors found when running PHPStan on level 2 is: Property Foo::$bar has unknown class Baz as its type.

This child-issue exists to fix all of those.

Steps to reproduce

- Run PHPStan on level 2 and see the above error amongst all others.

Proposed resolution

- Solve all of the the above mentioned reported errors.
- Run PHPStan on level 2 and don't see the above mentioned error any more.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3324801

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

Spokje created an issue. See original summary.

spokje’s picture

StatusFileSize
new2.18 MB
new2.12 MB

Attached out of vendor/bin/phpstan analyze --configuration=core/phpstan.neon.dist --xdebug --no-ansi with lvl 2 before and after applying the MR.

spokje’s picture

StatusFileSize
new2.12 MB

Let's not mess with copied Doctrine code for now.

spokje’s picture

Assigned: spokje » Unassigned
Status: Active » Needs review

Hmm, that looks like a known random JS test failure.
Putting this on NR and ordering retest.

mondrake’s picture

Status: Needs review » Needs work

Nice cleanup. Just one quirk, then it's RTBC for me.

mondrake’s picture

Status: Needs work » Reviewed & tested by the community

Usual random javascrpti test failure? Retesting and RTBCing. Only PHPDoc changes.

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

longwave’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 10.1.x and backported to 10.0.x and 9.5.x to keep API docs in sync.

Committed and pushed 85eeb1bde1 to 10.1.x and 18e211cc79 to 10.0.x and d2cc35b992 to 9.5.x. Thanks!

  • longwave committed 18e211c on 10.0.x
    Issue #3324801 by Spokje, mondrake: Fix PHPStan L2 error "Property Foo...
  • longwave committed 85eeb1b on 10.1.x
    Issue #3324801 by Spokje, mondrake: Fix PHPStan L2 error "Property Foo...
  • longwave committed d2cc35b on 9.5.x
    Issue #3324801 by Spokje, mondrake: Fix PHPStan L2 error "Property Foo...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

tr’s picture

At least one of the changes in this patch is wrong:

diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php
index 9f74c4f4592..98a429fbbfc 100644
--- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php
+++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php
@@ -27,7 +27,7 @@ class Language extends TypedData {
   protected $id;
 
   /**
-   * @var \Drupal\Core\Language
+   * @var \Drupal\Core\Language\Language

This should be LanguageInterface|null and not just Language.
I opened an issue for this problem with the "language" datatype definition a year ago in #3264592: Core 'language' datatype has wrong @var types.

I would appreciate some eyes on that because the commit here did not fix the problem and just made more work for me.