-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Propagate variable types to generated code to allow statical analysis
- Loading branch information
1 parent
2c7ddd9
commit bb498bc
Showing
9 changed files
with
161 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
default values | ||
|
||
|
||
a) Variables 1, 123, 10 | ||
|
||
|
||
b) Variables 1, 123, 10 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
%A% | ||
final class Template%a% extends Latte\Runtime\Template | ||
{ | ||
protected const BLOCKS = [ | ||
['test' => 'blockTest'], | ||
]; | ||
|
||
|
||
public function main(): array | ||
{ | ||
extract($this->params); | ||
echo 'default values | ||
'; | ||
if ($this->getParentName()) { | ||
return get_defined_vars(); | ||
} | ||
echo ' | ||
a) '; | ||
$this->renderBlock('test', [1] + [], 'html') /* line %d% */; | ||
echo ' | ||
b) '; | ||
$this->renderBlock('test', ['var1' => 1] + [], 'html') /* line %d% */; | ||
return get_defined_vars(); | ||
} | ||
|
||
|
||
/** {define test $var1 = 0, array $var2 = [1, 2, 3], int $var3 = 10} on line %d% */ | ||
public function blockTest(array $ʟ_args): void | ||
{ | ||
extract($this->params); | ||
$var1 = $ʟ_args[0] ?? $ʟ_args['var1'] ?? 0; | ||
/** @var array $var2 */ | ||
$var2 = $ʟ_args[1] ?? $ʟ_args['var2'] ?? [1, 2, 3]; | ||
/** @var int $var3 */ | ||
$var3 = $ʟ_args[2] ?? $ʟ_args['var3'] ?? 10; | ||
unset($ʟ_args); | ||
echo ' Variables '; | ||
echo LR\Filters::escapeHtmlText($var1) /* line %d% */; | ||
echo ', '; | ||
echo LR\Filters::escapeHtmlText(($this->filters->implode)($var2)) /* line %d% */; | ||
echo ', '; | ||
echo LR\Filters::escapeHtmlText($var3) /* line %d% */; | ||
echo "\n"; | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
%A% | ||
public function main(): array | ||
{ | ||
/** @var string $a */ | ||
extract($this->params); | ||
%A% | ||
public function blockTest(array $ʟ_args): void | ||
{ | ||
/** @var string $a */ | ||
extract($this->params); | ||
%A% | ||
/** @var int $b */ | ||
$b = 5%a%; | ||
%A% |