Slamdunk / phpstan-laminas-framework

Laminas Framework 3 extensions for PHPStan
MIT License
16 stars 10 forks source link

Controller plugins seem not to be recognized #5

Closed parktrip closed 4 years ago

parktrip commented 4 years ago

first, thank you for this nice module for Laminas

I have an issue but I am afraid it is more configuration problem at my level.

when I run phpstan, controller plugins are not recognized and appears as errors. Can be the ones from Laminas like identity() or flashMessenger() or the ones I have defined in my application.

Application is working and I have checked if modules like 'Laminas\Mvc\Plugin\Identity' and 'Laminas\Mvc\Plugin\FlashMessenger' are in the modules list in the config/application.config.php file.

here is my neon file: `includes:

here is the command I run as the root level of my app:

vendor\bin\phpstan analyse vendor\MyVendor\MyModule\src --memory-limit 512M

here is part of the output `Note: Using configuration file D:\www\melliol\ern\phpstan.neon. 85/85 [============================] 100%


Line Controller\CollectionController.php


179 Call to an undefined method MyModule\Controller\CollectionController::translate(). 185 Call to an undefined method MyModule\Controller\CollectionController::translate(). 188 Call to an undefined method MyModule\Controller\CollectionController::identity().` (....)


Line Controller\DirectoryController.php


151 Call to an undefined method MyModule\Controller\DirectoryController::acl(). 169 Call to an undefined method MyModule\Controller\DirectoryController::acl(). 197 Call to an undefined method MyModule\Controller\DirectoryController::displayFormErrorMessages(). (....)`

can you tell me what am i doing wrong ?

thank you in advance

Slamdunk commented 4 years ago

Have you provided your custom service manager as described in the readme https://github.com/Slamdunk/phpstan-laminas-framework#configuration ?

parktrip commented 4 years ago

No I didn't as this sentence in your doc:

This library already recognize built-in services and plugins.

makes me think I didn't need to do this.

by doing this, it is working like a charm, thank you for your very quick support.

have a nice day,

Slamdunk commented 4 years ago

On higher PHPStan level, you'll also need some ignores like:

  1. '#Method .+Controller::(indexAction|notFoundAction)\(\) should return Laminas\\View\\Model\\ViewModel but returns .+#' see https://github.com/laminas/laminas-mvc/issues/5
  2. '#Method .+Controller::.+Action\(\) has no return typehint specified#' on level 6 if you don't want to bother with return types of controller actions

I have to document these somewhere...