Closed arron0 closed 3 years ago
Hi, offsetSet
of RouteList
looks like this:
/**
* @param mixed $index
* @param Nette\Routing\Router $router
*/
public function offsetSet($index, $router): void
I guess the PHPDoc should be fixed. Send a PR to nette/application, thanks.
If that PR isn't accepted, you can still fix that for PHPStan by using a custom stub file: https://phpstan.org/user-guide/stub-files
What I see in Application/Routers/RouteList.php is this:
/**
* Adds the router.
* @param mixed
* @param Nette\Application\IRouter
* @return void
*/
public function offsetSet($index, $route)
{
if (!$route instanceof Nette\Application\IRouter) {
throw new Nette\InvalidArgumentException('Argument must be IRouter descendant.');
}
parent::offsetSet($index, $route);
}
Well that doesn't reflect how PHPStan behaves.
1) You should upgrade to Nette 3.0 as the 2.x is no longer supported and maintained. 2) Feel free to create a small reproducing repository that shows this problem.
Well that doesn't reflect how PHPStan behaves.
What I mean is that PHPStan reads the version I showed in https://github.com/phpstan/phpstan/issues/4025#issuecomment-719469033 so there's some mess in your vendor dependencies probably... But you can try to reproduce it with Nette 2.4.
Oh I get it, it comes from here: https://github.com/phpstan/phpstan-nette/blob/master/stubs/Application/Routers/RouteList.stub
I think this comes from differences between Nette 2.4 and 3.0. This package no longer supports Nette 2.4 so you need to upgrade, or ignore this error.
Solution was to downgrade after all and ignore some errors because version 0.11. doesn't support bootstrap files (that was the reason to update in the first place). It may help if 0.12. is locked to not to install with nette v2.*
Well the solution definitely isn't to downgrade PHPStan, you'll get a much worse experience that way. The correct way is to stay on 0.12 and ignore this specific error.
The best longterm solution is of course to upgrade your app to Nette 3.0 ;)
There were more problems that was solved by downgrade...
-- ---------------------------------------------------------------------------
Error
-- ---------------------------------------------------------------------------
Child process error (exit code 255): PHP Fatal error: Allowed memory
size of 268435456 bytes exhausted (tried to allocate 8192 bytes) in
phar:///var/www/html/vendor/phpstan/phpstan/phpstan/src/Type/TypeCombinat
or.php on line 307
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to
allocate 8192 bytes) in
phar:///var/www/html/vendor/phpstan/phpstan/phpstan/src/Type/TypeCombinat
or.php on line 307
-- ---------------------------------------------------------------------------
But it is for another issue...just don't know how to reproduce it with some small piece of code.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Hi,
I have a problem with PhpStan + PhpStan-Nette:
Nette\Application\Routers\RouteList does not accept Nette\Application\Routers\Route
Code producing this error:
Workaround for this situation is this:
and it works fine, on one project but on the next one there si different error message:
Nette\Application\Routers\RouteList::offsetSet() expects Nette\Routing\Router, Nette\Application\Routers\Route given.
Not sure if it is bug or there is something what I'm doing wrong.
Thank you.
PHP: 7.3 Nette Application: 2.4.13 PhpStan: 0.12.52 Phpstan-Nette: 0.12.9