Conversation
816aa6d to
f00d2bf
Compare
Contributor
|
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:
|
2287726 to
b6e3ad2
Compare
64d945d to
5734433
Compare
9bf91ab to
67ede95
Compare
d1e7c2d to
f525ac8
Compare
5a08a69 to
85d6f69
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
@propertyannotations and stub class: