-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Propagate variable types to generated code to allow statical analysis #276
Conversation
bb498bc
to
9fe662e
Compare
Update: I added support for {templateType} |
I just encountered another bug that would be prevented by this. Any chance you would have time to review this PR? I know it is a bit lrge changeset so if you are busy a the moment another way that would allow me to use this feature would be to create PR with just changes to Compiler that would allow use of custom macros for this. Would it be better? |
a987f2f
to
7cbee05
Compare
3f8fbc4
to
596b28b
Compare
8be7593
to
11d9cbf
Compare
8a046d1
to
811a30a
Compare
This feature would be very nice to have. @dg Would it help if I port it to the latest branch or master? |
@zobo I plan to add this feature in Latte soon. |
@dg Let us know if we can help with that |
I put the first draft here #297 |
@dg Would you want me to add new tests based on tests in this PR? IT seems you test only very basic things but my tests covers few edge cases - like forgetting global variable types inside blocks. |
@MartinMystikJonas Yeah, that would be great. I'm finally ready to focus on it. |
@dg What woukd be best way to prepare it? PR against analysis branch of your (dg) fork? I noticed you did some force pushes there. |
I don't know how to allow you to push into that branch, but how about you take those two commits here and continue? |
Well maybe best way would be just send you patch with changes. My tests would probably require some tweaking to your implementation. I will look at it and then we will figure out how to put it into your branch. |
Replaced by #309 |
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 #262
(Previous PR targeted onto master here #275)