PhpStan: RouteList does not accept Route

arron
Member | 464
+
+1
-

Hi,

I would like to ask if you ever come in touch with this error using PhpStan + PhpStan-Nette:
Nette\Application\Routers\RouteList does not accept Nette\Application\Routers\Route

Code producing this error:

$router = new RouteList('v1');
$router[] = new Route('/v1/status', 'Status:default');

Workaround for this situation is this:

$router = new RouteList('v1');
$router->offsetSet(null, new Route('/v1/status', 'Status:default'));

and it works fine, but it's strange and to be honest, I don't want to use it in this way just because PhpStan.

Have you ever saw this? What is a correct solution?

Thank you.

PHP: 7.3
Nette Application: 2.4.13
PhpStan: 0.12.52
PhpStan-Nette: 0.12.9

Last edited by arron (2020-10-30 11:09)

CZechBoY
Member | 3608
+
0
-

please report it in phpstan issues: https://github.com/…stan/issues/

arron
Member | 464
+
+2
-

Done that, it is problem of phpstan-nette v0.12.* not compatible with Nette 2.*. Solution is to ignore that particular error / upgrade Nette.