-
-
Notifications
You must be signed in to change notification settings - Fork 112
Description
I just finished first draft of script that uses PHPStan to satic analysis of compiled Latte templates in our projects.
One think I noticed is that {varType} or {templateType} macros does not propagate any type related information to compiled Latte templates so PHPStan cannot check it.
Is there any plan to address this?
I could try to prepare PR which will address this but I would like to disccuss what approach to take here.
One option would be to simply add relevant /** @var type $variable */ annotations after each extract of parameters.
So insted of:
extract($this->params);
$a->call(); // PHPStan: OKit would be:
extract($this->params);
/** @var string $a */
$a->call(); // PHPStan error: Cannot call method call() on string.
Another IMHO better approach would be to generate known params as template properties and instead of addressign them as $variable use $this->variable if variable is known but I am not sure how difficult that change would be.
And for {templateType} another option woudl be to add property $template of given type, populate it with passed values and address variables from templateType as $this->template->variable.