-
Notifications
You must be signed in to change notification settings - Fork 4
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
{include}
'd template ignores that {include}
params may be different
#391
Comments
We have to check this. Maybe @MartinMystikJonas will know more about it. |
I have few similar cases in our code too. It is one of limitations because we always analyse (included) template with given combination of passed parameters. If we would merge parameters from different calls/includes it would cause even more weird false-positives. Because it would check invalid combinations. Like some bool flag deciding if render given part of template but with null values for data rendered in that part. I solve it by ignoring these errors. |
Thanks, I could probably change that and move the variables to be set in presenters so there are no |
Yes it is kind of similar issue. Here you should somehow use ?DateTime type for variable $now. But I understand it could be a lot of rewrite |
Also I think some shared templates are large and contains more parts - each somehow conditionally displayed. So very often you have to use some flags (true/false) od null for nullable types. It would probably work neter (for phpstan latte) if you split those shared templates to multiple smaller templates and include only those you need. |
That's totally possible :-) Do you have an example which template you think it's way too huge? |
I didn't work with your app for a while so I don’t remember. I just had that feeling |
…ponent From 94 level 4 errors to 66 with just this change. This is probably how efabrica-team/phpstan-latte#391 should be solved, components suggested in #143 (comment) Docs https://doc.nette.org/cs/application/components https://doc.nette.org/en/application/creating-links#toc-links-in-component for {plink} The UiControl class is there mostly, I mean only to suppress PhpStorm's "Member has private visibility but can be accessed via '__get' magic method" which is thrown in child classes of Nette\Application\UI\Control even though it has the same `@property-read` tag.
…ponent From 94 level 4 errors to 66 with just this change. This is probably how efabrica-team/phpstan-latte#391 should be solved, components suggested in #143 (comment) Docs https://doc.nette.org/cs/application/components https://doc.nette.org/en/application/creating-links#toc-links-in-component for {plink} The UiControl class is there mostly, I mean only to suppress PhpStorm's "Member has private visibility but can be accessed via '__get' magic method" which is thrown in child classes of Nette\Application\UI\Control even though it has the same `@property-read` tag.
I have a template with
(source)
The template is included in some other templates.
For example like this:
(source)
or like this:
(source)
note the difference
now: null
vs.now: $now
(where$now
is created as$this->template->now = new DateTime();
)In the first case the error message says
and in the second
(
order: 'desc'
on line 40 is changed in some other{include}
line toorder: 'asc'
)In both cases the template is compiled to:
but in the first case the compiled source contains:
and in the second case:
which is correct only in the isolated case and not when the template is reused and the parameter may be different.
I don't know what to do with that, if it's a missing feature or a bug, or if I should refactor my code.
The text was updated successfully, but these errors were encountered: