Problem/Motivation

PHPStan is a tool that does static analysis on a codebase to find bugs. PHPStan is run in our CI pipeline. PHPStan groups its lints into rule levels.

Since #3586801: PHPStan level 1 we have been linting against PHPStan level 1.

But running ddev phpstan --level=5 locally shows only 13 things that need to be changed to get there, and they're all pretty trivial.

By observation, PHPStan level 5 is where it starts to provide really useful feedback (i.e.: find a lot of bugs), so this is great for maintainability.

Proposed resolution

Fix the 13 issues and update the rule level in phpstan.neon.

Remaining tasks

  1. Merge request - merge request !12 created by @mparker17 in #3
  2. Commit - merged by @mparker17 in #4
  3. Release

User interface changes

None.

API changes

None.

Data model changes

None.

Issue fork feedback-3586803

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

mparker17 created an issue. See original summary.

mparker17’s picture

For reference, the output from ddev phpstan --level=5 --error-format=raw shows the following lints...

  1. web/modules/custom/feedback/src/Entity/FeedbackMessage.php:115:Method Drupal\feedback\Entity\FeedbackMessage::getOwner() should return Drupal\user\UserInterface but returns Drupal\Core\Entity\EntityInterface|null.
  2. web/modules/custom/feedback/src/Entity/FeedbackMessage.php:122:Method Drupal\feedback\Entity\FeedbackMessage::getOwnerId() should return int|null but returns string.
  3. web/modules/custom/feedback/src/FeedbackLazyBuilders.php:85:Property Drupal\feedback\FeedbackLazyBuilders::$entityManager (Drupal\Core\Entity\EntityTypeManager) does not accept Drupal\Core\Entity\EntityTypeManagerInterface.
  4. web/modules/custom/feedback/src/FeedbackMessageHtmlRouteProvider.php:53:Method Drupal\feedback\FeedbackMessageHtmlRouteProvider::getCollectionRoute() should return Symfony\Component\Routing\Route|null but return statement is missing.
  5. web/modules/custom/feedback/src/FeedbackMessageHtmlRouteProvider.php:78:Method Drupal\feedback\FeedbackMessageHtmlRouteProvider::getAddFormRoute() should return Symfony\Component\Routing\Route|null but return statement is missing.
  6. web/modules/custom/feedback/src/FeedbackMessageHtmlRouteProvider.php:135:Method Drupal\feedback\FeedbackMessageHtmlRouteProvider::getSettingsFormRoute() should return Symfony\Component\Routing\Route|null but return statement is missing.
  7. web/modules/custom/feedback/src/FeedbackMessageTypeHtmlRouteProvider.php:46:Method Drupal\feedback\FeedbackMessageTypeHtmlRouteProvider::getCollectionRoute() should return Symfony\Component\Routing\Route|null but return statement is missing.
  8. web/modules/custom/feedback/src/FeedbackMessageTypeHtmlRouteProvider.php:73:Method Drupal\feedback\FeedbackMessageTypeHtmlRouteProvider::getAddFormRoute() should return Symfony\Component\Routing\Route|null but return statement is missing.
  9. web/modules/custom/feedback/src/Form/FeedbackMessageForm.php:53:PHPDoc tag @var for variable $message_type contains unknown class Drupal\feedback\Form\FeedbackMessageType.
  10. web/modules/custom/feedback/src/Form/FeedbackMessageForm.php:54:Call to method getSuccessMessage() on an unknown class Drupal\feedback\Form\FeedbackMessageType.
  11. web/modules/custom/feedback/tests/src/Functional/BasicFunctionalityTest.php:112:Call to method PHPUnit\Framework\Assert::assertIsArray() with array will always evaluate to true.
  12. web/modules/custom/feedback/tests/src/Functional/CreateReadUpdateDeleteMessageTest.php:128:Call to method PHPUnit\Framework\Assert::assertIsArray() with array will always evaluate to true.
  13. web/modules/custom/feedback/tests/src/Functional/CreateReadUpdateDeleteMessageTypeTest.php:49:PHPDoc tag @var for property Drupal\Tests\feedback\Functional\CreateReadUpdateDeleteMessageTypeTest::$testTypeSuccessMessage with type Drupal\feedback\Entity\FeedbackMessageType is incompatible with native type string.

mparker17’s picture

Issue summary: View changes
Status: Active » Fixed

Merged! I will update this issue when the code is released.

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.