-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Statical analysis for Latte [WIP] #297
base: master
Are you sure you want to change the base?
Conversation
816aa6d
to
f00d2bf
Compare
Very much looking forward to this. I did some initial testing and the main issue I encountered is, that it does not support "closure" variables, i.e. {define outer, Foo $foo}
{embed wrapper}
{block inner}{$foo->text}{/block}
{/embed}
{/define} |
eef7b89
to
c292484
Compare
@dg: I tried fist attempts to migrate my tests to your implementation. SO far I notived few things I would need to solve before I continue:
$comment = "/** @var $type $variable */\n";
if ($this->getCompiler()->isInHead()) {
$this->getCompiler()->paramsExtraction .= $comment;
return "";
} else {
return $writer->write($comment);
} |
@dg Example of global/local sope test I wrote in my implementation: $template = <<<'XX'
{varType string $a}
{$a}
{varType string $c}
{var $c = 10}
{include test}
{define test}
{varType int $b}
{var $b = 5}
{$a}{$b}
{/define}
XX;
Assert::matchFile(
__DIR__ . '/expected/varType.phtml',
$latte->compile($template)
); Expects vartype.phtml:
Notice that in blockTest there is no variable type comment for $c, which is local variable. |
@dg: Here you can find my first patch https://gist.github.com/MartinMystikJonas/05a11cbbb404184493b2353f4041a6bc It includes:
|
8d92896
to
1267554
Compare
ee646d6
to
b80c3a6
Compare
6c48587
to
bd46751
Compare
6baf2c5
to
4db7a55
Compare
The purpose of this PR is to enable statical analysis of resulting code by analysers like PHPStan, Psalm, etc.
Related #262, #275, #276
First commit propagates known types infomation from
{var type}
,{varType}
,{define}
,{templateType}
and{parameters}
into compiled PHP code in form of/** @var type $var */
annotations.The second commit propagates filter parameter in the form of
@property
annotations and stub class: