--level used: 5The Nova service provider has a route method that doesn't return anything. Yet I get errors regarding the method chain. It feels like in this instance the method chain should be ignored. Not sure how to work around this error.
------ ---------------------------------------------------------------------
Line app/Providers/NovaServiceProvider.php
------ ---------------------------------------------------------------------
29 Cannot call method withAuthenticationRoutes() on void.
29 Result of static method Laravel\Nova\Nova::routes() (void) is used.
------ ---------------------------------------------------------------------
[ERROR] Found 2 errors
# NovaServiceProvider.php
/**
* Register the Nova routes.
*
* @return void
*/
protected function routes()
{
Nova::routes()
->withAuthenticationRoutes()
->withPasswordResetRoutes()
->register();
}
Another missing magic!
Although it is not the framework.
@stephenhowells The method Nova::routes() should return an instance of something. Probably an issue on the method PHPDocs. @stephenhowells Can you check and make a pull request on the nova repository ?
I've just learned it is closed-source.
It seems PHPStan plans to account better for methods that don't return anything: https://github.com/phpstan/phpstan/issues/658#issuecomment-348719205
What would be the best way to ignore this for now? I've tried:
includes:
- ./vendor/nunomaduro/larastan/extension.neon
parameters:
level: 5
ignoreErrors:
- '#Cannot call method register() on void.#'
- '#Result of static method Laravel\\Nova\\Nova::routes() (void) is used.#'
But that does not seem to be working. I'd rather ignore the file itself, like this:
includes:
- ./vendor/nunomaduro/larastan/extension.neon
parameters:
level: 5
excludes_analyse:
- %rootDir%/app/Providers/NovaServiceProvider.php
But that also does not seem to work.
This seems to work, but it looks a bit nasty:
includes:
- ./vendor/nunomaduro/larastan/extension.neon
parameters:
level: 5
excludes_analyse:
- /*/*/NovaServiceProvider.php
Maybe
ignoreErrors:
- '#^Cannot call method register\(\) on void\.$#'
- '#^Result of static method Laravel\\Nova\\Nova::routes\(\) \(void\) is used\.$#'
Those ignore errors are regular expressions. You need to escape stuff such as parentheses, etc.
In the newer versions of Nova, routes method returns \Laravel\Nova\PendingRouteRegistration
Most helpful comment
Maybe