Skip to content
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

Closed

Conversation

MartinMystikJonas
Copy link

  • new feature
  • BC break? no

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)

@MartinMystikJonas
Copy link
Author

Update: I added support for {templateType}

@MartinMystikJonas
Copy link
Author

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?

@dg dg force-pushed the v2.10 branch 2 times, most recently from a987f2f to 7cbee05 Compare December 20, 2021 12:25
@dg dg force-pushed the v2.10 branch 2 times, most recently from 3f8fbc4 to 596b28b Compare January 4, 2022 14:14
@dg dg force-pushed the v2.10 branch 4 times, most recently from 8be7593 to 11d9cbf Compare February 10, 2022 00:26
@dg dg force-pushed the v2.10 branch 2 times, most recently from 8a046d1 to 811a30a Compare February 18, 2022 22:30
@zobo
Copy link

zobo commented May 16, 2022

This feature would be very nice to have. @dg Would it help if I port it to the latest branch or master?

@dg
Copy link
Member

dg commented May 17, 2022

@zobo I plan to add this feature in Latte soon.

@MartinMystikJonas
Copy link
Author

@dg Let us know if we can help with that

@dg
Copy link
Member

dg commented May 18, 2022

I put the first draft here #297

@MartinMystikJonas
Copy link
Author

@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.

@dg
Copy link
Member

dg commented Jun 15, 2022

@MartinMystikJonas Yeah, that would be great. I'm finally ready to focus on it.

@MartinMystikJonas
Copy link
Author

@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.

@dg
Copy link
Member

dg commented Jun 16, 2022

I don't know how to allow you to push into that branch, but how about you take those two commits here and continue?

@MartinMystikJonas
Copy link
Author

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.

@MartinMystikJonas
Copy link
Author

Replaced by #309

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants