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

Statical analysis for Latte [WIP] by MartinMystikJonas #309

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

MartinMystikJonas
Copy link

Continue of work started by @dg in #297

@MartinMystikJonas
Copy link
Author

MartinMystikJonas commented Jul 11, 2022

@dg: I just discovered unexpected behaviour of {parameters} tag. It limit what variables are available in template. But only at top level (inmain()) but in blocks parameters are always extracted from $this->params therefore unfiltered nad any passed param is available in block no matter what {parameters} defines.

It is bug right? Of is it for some reason expected?

@MartinMystikJonas
Copy link
Author

Ok I think I have functional version that passes all tests I used in my previous PR.

I also changed behaviour of {parameters} tag so it also applies inside blocks. Instead of extracting $this->params it now extracts $this->prepare() and adds definition of types used in paramsExtraction (see tags/excpeted/parameters.inc8.phtml)

@MartinMystikJonas
Copy link
Author

@dg LEt me know if you want to solve something differently

@MartinMystikJonas
Copy link
Author

@dg One think I am not sure of is double meaning of varType. When used in template head it is interpreted as definition of type of parameter (so this type information is propagated inside blocks) and when used outside of head it is interpreted as definition of type of local variable.

I am not sure if this double meaning is ok. Maybe we should make {varType} just about local variables types and add something like {parameterType} to define types of template paramater. What do you think?

@MartinMystikJonas
Copy link
Author

@dg @lulco @jakubvojacek @JanTvrdik @mabar Guys, could you check this version and let me know what do you think? I would like to finish this basic version.

@lulco
Copy link

lulco commented Jul 23, 2022

Like I wrote somewhere, I'm using https://github.com/revealphp/reveal-src (previously in symplify) for some months maybe year already and it works like a charm for my projects.

@MartinMystikJonas
Copy link
Author

@dg Hi. I would like to finish this feature. Is there anything I can do (aside from resolving that new conflict) to have this merged? I do not want to hurry you I just want to know if there is anything I can do.

@dg dg force-pushed the master branch 4 times, most recently from 466080e to 13436ee Compare September 12, 2022 22:36
@dg dg force-pushed the master branch 8 times, most recently from 0ef5757 to bdd2655 Compare October 19, 2022 16:06
@dg dg force-pushed the master branch 2 times, most recently from 04c3089 to e3a5b8c Compare October 23, 2022 16:26
@survilla
Copy link

We have our own PHPStan rule to check link() is valid destination, parameters and parameter types. It is working very nice for PHP code. In latte code we need to be able to recognize the variable type... (The PHPStan rule could be open sourced if anyone interested.

Anyway we would very appreciate to move this PR forward.

@MartinMystikJonas
Copy link
Author

@janzimmermannnetrex I would like to see that rule.

@survilla
Copy link

@MartinMystikJonas see https://drive.google.com/file/d/1YiJIllqQH3Iyb0rns-rYl2vLX_ro05IN/view?usp=sharing for inspiration. It is definitely not ready to use it as is in another project yet.

  • We are trying to create a presenter instance during the static analyses (you need to include nette bootstrap in phpstan)
  • We try to call the link() on presenter instance. It throws an exception once the link is not valid.
  • It is similar for Latte as well.
    Sure I'd appreciate any ideas to improve it.

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.

None yet

4 participants