Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking links #131

Closed
MartinMystikJonas opened this issue Aug 7, 2023 · 6 comments
Closed

Checking links #131

MartinMystikJonas opened this issue Aug 7, 2023 · 6 comments

Comments

@MartinMystikJonas
Copy link
Contributor

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?

@ondrejmirtes
Copy link
Member

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).

@MartinMystikJonas
Copy link
Contributor Author

Ok I will draft some solution

@MartinMystikJonas
Copy link
Contributor Author

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?

@MartinMystikJonas
Copy link
Contributor Author

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

@MartinMystikJonas
Copy link
Contributor Author

Implemented in #132

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants