Problem/Motivation

PHPStan is currently ignoring #^Cannot unset offset# errors.

Proposed resolution

Fix the issues and remove the ignore.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3259109

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

mondrake created an issue. See original summary.

mondrake’s picture

Status: Active » Needs review
mglaman’s picture

This looks good to me! I opened an issue for phpstan-drupal to fix the return type for config entities, which is why it had to be set in this MR. Not sure if we want to add a `@todo` next to that statement that it should be able to be removed once phpstan-drupal has a release with the fix.

neclimdul’s picture

+1 to the extend array syntax used here but this seems to be the first use of it in core. Putting this on people's radar for future adoption. #3259019: Errors when using newish array syntax for docs

mglaman’s picture

daffie’s picture

Status: Needs review » Postponed

Postponing this issue on phpstan-drupal fixing: https://github.com/mglaman/phpstan-drupal/issues/308

mondrake’s picture

Status: Postponed » Needs work
Issue tags: +Needs reroll

I think we can proceed now; after #3260928: Move more PHPStan global ignore patterns to baseline this can also be partial if some things can’t be solved yet.

mondrake’s picture

Status: Needs work » Postponed
Issue tags: -Needs reroll
Related issues: +#3259355: Always do a full phpstan analysis on DrupalCI

Ah no it's useless to do this without #3259355: Always do a full phpstan analysis on DrupalCI.

mondrake’s picture

Status: Postponed » Needs review

Actually no need to postpone if we change the baseline directly.

mondrake’s picture

rerolled

daffie’s picture

Status: Needs review » Reviewed & tested by the community

All the changes look good to me.

mondrake’s picture

rerolled

mondrake’s picture

rebased

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

longwave’s picture

Status: Reviewed & tested by the community » Needs work

Merged in HEAD, but I think a few of the cases need revisiting, many of the tests are hardcoded so there is no point asserting something is missing when we explicitly set that already a few lines above.

andregp’s picture

I'll see what I can do to address the above points from @longwave.

andregp’s picture

Status: Needs work » Needs review

I hope this helps.

longwave’s picture

Status: Needs review » Needs work

Thank you @andregp!

The NewDefaultThemeBlocksTest change can be reverted as well, as it is fixed in newer versions of mglaman/phpstan-drupal.

andregp’s picture

Status: Needs work » Needs review

@longwave, done. :)

longwave’s picture

Status: Needs review » Needs work

Thanks again - just spotted another three cases I think we can fix instead of ignoring.

andregp’s picture

Status: Needs work » Needs review

@longwave, sorry for the late response.
I removed the phpstan-ignore lines and cast $random to string as suggested.

mondrake’s picture

iirc, $GLOBALS does not really play nice with PHPStan, so I went for ignoring the lines altogether

mondrake’s picture

Status: Needs review » Needs work
longwave’s picture

Status: Needs work » Needs review

For some reason PHPStan treats numeric-string and string differently here, but forcing the random key to be a full string works for me locally.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

All code changes look good to me.
Back to RTBC.

mondrake’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Needs rebasing

longwave’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll

Merged 10.0.x, back to RTBC.

mondrake’s picture

Status: Reviewed & tested by the community » Needs work
longwave’s picture

Status: Needs work » Needs review

Unrelated fail in HEAD, now fixed.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Rebased, back to RTBC

mondrake’s picture

rebased

mondrake’s picture

rebased

mondrake’s picture

rebased

mondrake’s picture

rerolled

mondrake’s picture

rebased

mondrake’s picture

rebased

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Did a review in gitlab. I think the MR needs some changes before we can merge.

mondrake’s picture

Status: Needs work » Needs review

Rebased and addressed the feedback on the MR

daffie’s picture

Status: Needs review » Reviewed & tested by the community

All the code changes look good to me.
The file core/phpstan-baseline.neon has the exceptions removed.
For me it is RTBC.

mondrake’s picture

Status: Reviewed & tested by the community » Needs review

Sorry, I realized there were more unsets to remove in ActiveLinkResponseFilterTest, needs to RTBCed again.

daffie’s picture

Your last change does not remove any exceptions from core/phpstan-baseline.neon.

mondrake’s picture

Was addressing this comment from @neclimdul

Honestly, these giant blocks of code would be a lot easier to understand if the array merge(addition) order was reversed and the unsets removed.

In other words, this is to keep consistency across the test code, not to remove baseline entries.

daffie’s picture

Status: Needs review » Needs work

The testbot is not happy with the change to core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php

mondrake’s picture

Status: Needs work » Needs review

Should be fixed now.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

All the code changes look good to me.
Back to RTBC.

alexpott’s picture

Version: 10.0.x-dev » 9.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 74b0acb and pushed to 10.1.x. Thanks!
Committed ab04257 and pushed to 10.0.x. Thanks!
Committed and pushed 0bab40ee30 to 9.5.x and 59f14c20d0 to 9.4.x. Thanks!

Backported to 9.4.x and 9.5.x without the PHPStan changes to keep the codebase aligned. The only non test change is a harmless one to core/modules/views/src/Plugin/views/display/DisplayPluginBase.php

  • alexpott committed 74b0acb on 10.1.x
    Issue #3259109 by mondrake, longwave, andregp, daffie, mglaman,...

  • alexpott committed ab04257 on 10.0.x
    Issue #3259109 by mondrake, longwave, andregp, daffie, mglaman,...

  • alexpott committed 0bab40e on 9.5.x
    Issue #3259109 by mondrake, longwave, andregp, daffie, mglaman,...

  • alexpott committed 59f14c2 on 9.4.x
    Issue #3259109 by mondrake, longwave, andregp, daffie, mglaman,...

mondrake’s picture

Status: Fixed » Closed (fixed)

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