-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add templateType & varType to some Admin presenters #72
Conversation
Mainly lists https://phpstan.org/writing-php-code/phpdoc-types#lists Done with `composer bump phpstan/* spaze/phpstan*`
Are these Template classes really used by nette in presenters? Or $this->template is still DefaultTemplate? {varType} / {templateType} are not transfered to compiled template yet, but I can imagine we can analyse them if they will be used in presenter too. e.g. You call |
But there should be no need for it because all variables should be collected from presenter anyway, if you have some use case when they are not collected, please create issue, ideally with failing test case |
No, they're used by Latte, or more like my IDE. See https://phpfashion.com/phpstorm-a-napovidani-nad-this-template
Yes,
I've noticed, there's also an issue mentioned in #71 but these classes were not added (at least not primarily) for the PHPStan Latte extension, there's no difference if they're there, or not.
Yeah, don't worry, I'm filing bugs if I see one :-) |
Just checked (once again) why I still have /**
* @property-read DefaultTemplate $template
*/ in my presenters and not for example the class added here, like: /**
* @property-read MichalSpacekCz\Admin\Presenters\PresenterTemplates\Interviews\InterviewsDefault $template
*/ and that's because the |
Those templates are little bit tricky. They are not important for phpstan-latte yet, but we are discussing about them. This could be helpfull https://github.com/nette/application/blob/v3.1/src/Application/UI/Presenter.php#L577 Template class have to be in the same namespace as Presenter to be found automatically. And you can create template for each actions - InterviewPresenter could have InterviewDefaultTemplate, InterviewDetailTemplate etc. See code above. You can also create your template class in action / render (not both! because it would be reset - you will lost data assigned in action): |
Oh, nice! I'll check this but it seems this is what I was looking for, thanks! Would introduce quite some new files in the directory where presenters are now but I guess I can live with that. Just a minute ago I found out something similar but they mentioned
This may also be useful especially for cross-references and clicking in IDE, I'll see which one I'll go with. Thanks. |
Yeah, it's probably not documented. I know about it just because it was my PR :D |
🤣 Nice, thanks! I'll see if I can write the missing documentation, or at least mention it somewhere in the docs. (Just for my info, this is the PR nette/application#277) |
Fyi, seems like you can't do this because |
Hmm than maybe just use local variable? |
Yeah, there are some ways how to do that. One of them is to overwrite then |
No description provided.