- Issue created by @jlbellido
- 🇪🇸Spain jlbellido
I'm attaching the initial report with all the issues detected before fixing anything:
- Merge request !32#3417527: Fix most PHPStan reported issues. Provide initial phpstan.neon file. → (Open) created by jlbellido
- 🇪🇸Spain jlbellido
Hello,
I've created an initial MR fixing most of the errors reported. It still pending the following one:
------ --------------------------------------------------------------------- Line modules/file_example/src/FileExampleSubmitHandlerHelper.php ------ --------------------------------------------------------------------- 460 Class Drupal\devel\DevelDumperInterface not found. 💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
I don't really know if by using Stub files we can fix it since it is a conditional class not always present (depending is Devel is required or not).
- Status changed to Needs review
about 1 year ago 1:47pm 28 January 2024 - 🇪🇸Spain jlbellido
I've checked in deep the error from #5 but I think Stub files is not the right way because they are meant for other kind of scenarios according to (https://phpstan.org/user-guide/stub-files). Therefore I don't see other way to get rid of it than ignoring it via php-baseline.neon
I've added a new commit with this approach.
Now we are passing the PHPStan checks for Level 1:
$ php ../vendor/bin/phpstan analyze --configuration modules/contrib/examples/phpstan.neon modules/contrib/examples 242/242 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% [OK] No errors
I think this is now ready to be reviewed.
- last update
about 1 year ago 186 pass, 13 fail - last update
about 1 year ago 186 pass, 13 fail - last update
about 1 year ago 186 pass, 13 fail - 🇪🇸Spain jlbellido
After [#] has been merged, now we can see we are passing the PHPStan check within !32 if we compare it with the last run on the main project (https://git.drupalcode.org/project/examples/-/pipelines/85372)
Therefore I'd say this is fully ready to be reviewed by someone else.
Thanks!
- Status changed to Needs work
8 months ago 9:26pm 28 June 2024 - 🇮🇹Italy apaderno Brescia, 🇮🇹
The errors reported by PHPStan are the following ones.
------ ----------------------------------------------------------------------- Line modules/config_entity_example/src/Form/RobotFormBase.php ------ ----------------------------------------------------------------------- 218 Method Drupal\config_entity_example\Form\RobotFormBase::save() should return int but return statement is missing. ------ ----------------------------------------------------------------------- ------ ---------------------------------------------------------------------- Line modules/content_entity_example/src/Form/ContactForm.php ------ ---------------------------------------------------------------------- 39 Method Drupal\content_entity_example\Form\ContactForm::save() should return int but return statement is missing. ------ ---------------------------------------------------------------------- ------ ---------------------------------------------------------------- Line modules/file_example/tests/src/Functional/FileExampleTest.php ------ ---------------------------------------------------------------- 28 Property Drupal\Tests\file_example\Functional\FileExampleTest::$modules property must be protected. 💡 Change record: https://www.drupal.org/node/2909426 ------ ---------------------------------------------------------------- ------ ---------------------------------------------------------------------- Line modules/form_api_example/src/Form/InputDemo.php ------ ---------------------------------------------------------------------- 263 \Drupal calls should be avoided in classes, use dependency injection instead ------ ---------------------------------------------------------------------- ------ ----------------------------------------------------------------------- Line modules/rest_example/src/RestExampleClientCalls.php ------ ----------------------------------------------------------------------- 155 Method Drupal\rest_example\RestExampleClientCalls::create() should return Symfony\Component\HttpFoundation\Response but return statement is missing. 197 Method Drupal\rest_example\RestExampleClientCalls::update() should return Symfony\Component\HttpFoundation\Response but return statement is missing. 231 Method Drupal\rest_example\RestExampleClientCalls::delete() should return Symfony\Component\HttpFoundation\Response but return statement is missing. ------ ----------------------------------------------------------------------- ------ ---------------------------------------------------------------------- Line modules/testing_example/src/Controller/TestingExampleController.php ------ ---------------------------------------------------------------------- 33 \Drupal calls should be avoided in classes, use dependency injection instead ------ ----------------------------------------------------------------------
Part of them has been fixed in 📌 Require at least Drupal 10.3 and remove any usage of deprecated classes, methods, constants, or functions Fixed . - Status changed to Needs review
8 months ago 9:01pm 5 July 2024 - 🇮🇹Italy apaderno Brescia, 🇮🇹
apaderno → changed the visibility of the branch 3417527-fix-phpstan-detected to hidden.
-
apaderno →
committed 4b79aeaf on 4.0.x
Issue #3417527: Fix PHPStan detected errors
-
apaderno →
committed 4b79aeaf on 4.0.x
- Status changed to Fixed
8 months ago 9:19pm 5 July 2024 Automatically closed - issue fixed for 2 weeks with no activity.