phpstan/phpstan-nette

Checking links

Closed this issue · 6 comments

I am planning to write rules to check validity of links (link, redirect, ...) creation.

  • validate that presenter/action used in target exists (based on configured mapping or using PresenterFactory)
  • validate that mandatory parameters (based on action/render method signature) are passed
  • validate types of parameters

We already do this in our phpstan-latte extension (in hacky way) but I would like to write universal solution.

Should I make it as PR to this package or would you preffer it as separate package?

Yeah, sure, it'd be nice to have some kind of nette.containerLoader setting like we do in phpstan-symfony and phpstan-doctrine. Then we could obtain the real router and the job you're describing.

We could also use it to verify that services asked from the DIC exist, and provide the correct type for named services from ->getService($name).

Ok I will draft some solution

I have working proof of concept implementation. I just have one question: is it ok if I use internal Nette methods during static analysis? I tried to minimize dependencies on Nette. But there is lot of complex logic and I would like to use it as it is in Nette but it is marked as @internal. For example method Presenter::argsToParams (https://github.com/nette/application/blob/aa503fe11fc52c502ceefc4efa2c84b35f2194b4/src/Application/UI/Presenter.php#L1010) to preprocess link parameters?

Never mind it iseems I would have to reimplement it a bit differently anyway

Implemented in #132

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.