nette / latte

☕ Latte: the safest & truly intuitive templates for PHP. Engine for those who want the most secure PHP sites.
https://latte.nette.org
Other
1.13k stars 109 forks source link

Propagate variable types to generated code to allow statical analysis (master) #275

Closed MartinMystikJonas closed 3 years ago

MartinMystikJonas commented 3 years ago

With this change Latte will propagate known types infomation from {varType}, {define} and {parameters} into compiled PHP code in form of /** @var type $var */ annotations. This will allow statical anylysis of resulting code by static analysers like PHPStan, Psalm, etc.

See discussion about this feature here https://github.com/nette/latte/issues/262

MartinMystikJonas commented 3 years ago

@dg Can you please chek this if it is valid approach from your point of view? It it seems ok to you I will add some more tests for edge cases and support for extracting types from {templateType}

MartinMystikJonas commented 3 years ago

@dg Should I consider that like as approval of this approach? If so can you please approve to run workflows? Thanks.

dg commented 3 years ago

Hi, please give me some time, I'm busy this week.

Otherwise, it's best to do PR against the last released version, because I change and forcepush the master a lot.

MartinMystikJonas commented 3 years ago

@dg Understood. Take your time and look at it whenever you will have time to check it. Let me know if you have any questions or requests how to finish this PR.

I will rebase it onto last release.

MartinMystikJonas commented 3 years ago

New PR targeted onto v2.10 here #276