Increase PHPstan level to 2

Created on 9 March 2024, 10 months ago
Updated 31 March 2024, 9 months ago

Problem/Motivation

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Version

8.0

Component

Code

Created by

🇫🇮Finland sokru

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

Merge Requests

Comments & Activities

  • Issue created by @sokru
  • Status changed to Active 9 months ago
  • First commit to issue fork.
  • Merge request !41Issue #3426825: Increase PHPstan level to 2 → (Merged) created by BramDriesen
  • Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Status changed to Needs review 9 months ago
  • 🇧🇪Belgium BramDriesen Belgium 🇧🇪
  • Pipeline finished with Success
    9 months ago
    Total: 149s
    #117212
  • Status changed to Needs work 9 months ago
  • 🇫🇮Finland sokru

    Increasing the PHPStan level creates 48 new errors (see https://git.drupalcode.org/issue/elasticsearch_connector-3426825/-/jobs/...), we should fix them in this issue.

  • Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Pipeline finished with Success
    9 months ago
    Total: 205s
    #117726
  • 🇧🇪Belgium BramDriesen Belgium 🇧🇪

    3 errors remaining. Not sure what the easiest way to fix those is.

  • First commit to issue fork.
  • Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • 🇨🇦Canada mparker17 UTC-4

    @BramDriesen, thank you very much for your hard work!

    The remaining issues in src/Plugin/search_api/backend/ElasticSearchBackend.php...

    1. Line 216: Call to an undefined method Drupal\Core\Plugin\PluginFormInterface::getLabel().
    2. Line 217: Call to an undefined method Drupal\Core\Plugin\PluginFormInterface::getDescription().

    ... are because we were checking if $connector instanceof PluginFormInterface; and PluginFormInterface which doesn't define getLabel() nor getDescription() methods (and it doesn't inherit from any interfaces that define these methods either).

    However, if we instead check whether $connector instanceof ElasticSearchConnectorInterface, the PHPStan lints will go away, because ElasticSearchConnectorInterface extends PluginFormInterface AND defines both a getLabel() method and a getDescription() method.

    There is one more lint in src/SearchAPI/Query/FilterBuilder.php, "Call to an undefined method Drupal\search_api\Query\ConditionGroupInterface::__toString()." - I will check this out in a bit.

  • Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • 🇨🇦Canada mparker17 UTC-4

    Regarding the Call to an undefined method Drupal\search_api\Query\ConditionGroupInterface::__toString(). lint in src/SearchAPI/Query/FilterBuilder.php, seems like Search API's API could use an improvement, so I've filed Declare that ConditionGroupInterface or ConditionGroup implements \Stringable Needs review , and we can add this lint to the baseline for now.

  • Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Status changed to Needs review 9 months ago
  • 🇨🇦Canada mparker17 UTC-4

    Alright! PHPStan is passing. Moving to Needs Review.

    @sokru, did you also want to address some of the existing items in phpstan-baseline.neon?

  • Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Status changed to RTBC 9 months ago
  • 🇨🇦Canada mparker17 UTC-4

    I was able to fix a deprecated function call, but the other lints in phpstan-baseline.neon are hard to figure out how to change safely, so I'm leaving them here. We should collaborate with the search_api_opensearch maintainers to figure out whether we can delete the code causing those errors.

    For now, though, this is RTBC from me, and I'd like another maintainer to review (and ask questions), instead of me merging directly.

  • Pipeline finished with Skipped
    9 months ago
    #121337
  • Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
  • Status changed to Fixed 9 months ago
  • 🇫🇮Finland sokru

    Thanks! I agree with decision to leave existing lints to phpstan-baseline.neon, we could research it on separate issue and collaborate with search_api_opensearch module maintainers, and maybe doing it before increasing the level further. It seems we get related errors when reaching level 5.

    Also thanks for creating Declare that ConditionGroupInterface or ConditionGroup implements \Stringable Needs review , maybe we should ask feedback from #search or #contribute on Drupal.org's Slack if we don't get any replies in few weeks.

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

Production build 0.71.5 2024