deprecated-packages / reveal-src

Static analysis for your templates is here!
9 stars 3 forks source link

Fix exceptions for twig rules #8

Closed gndk closed 2 years ago

gndk commented 2 years ago

Without these two fixes, the test cases cause exceptions.

Unfortunately, the nested test case has a wrong result.

{{ var.other.method }}
-----
<?php

// line 1
echo $var->method();
echo "\n";

This now causes an Call to an undefined method $other->method error, which is wrong, but at least more helpful than a ShouldNotHappenException and can be refactored to pass the rules.

I think the correct result should be:

{{ var.other.method }}
-----
<?php

// line 1
echo $var->other()->method();
echo "\n";

I worked on it for hours but I can't manage to achieve the recursive nesting 😞 . I was getting frustrated, so I thought I'd start the PR and discussion 😄 .

The nesting could also be an additional rule, like "max X levels of nesting/chained call". I'll add some thoughts on it in an issue.

With these and the refactoring from the other PR I can at least run the rules without exceptions in my project, so I think its a small step forward 🙂 . There seem to be few false positives so I use some ignore rules, but I think overall this will become a really cool package!

TomasVotruba commented 2 years ago

Hi, thank you for the PR. I've been moving few packages here to make all template-related PHPStan rules in one place :)

Could I ask you to rebase this PR? What can I help you with?

TomasVotruba commented 2 years ago

I'm checking the test and it seems they report false positive for success.

TomasVotruba commented 2 years ago

It seems there is no activity and will to continue. Closing for lack of feedback. Feel free to re-open with a fix :+1: