-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add test for ValidConstantFunctionRule #282
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,17 @@ | |
{{ constant('ThisDoesNotExist::SomeKey') }} | ||
{{ constant(someVar) }} | ||
{{ constant('ThisDoesNotExist::class') }} | ||
{{ constant(1) }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this because the return type was mixed according to psalm or PHPStan. Shouldn't be the case I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So maybe beter to report an error in that case. |
||
|
||
{{ constant(constant='DateTimeInterface::ATOM') }} | ||
{{ constant(constant='DATE_ATOM') }} | ||
{{ constant(constant='TwigCsFixer\\Tests\\Rules\\Node\\ValidConstantFunction\\ValidConstantFunctionRuleTest::SOME_CONSTANT') }} | ||
{{ constant(constant='class', someObject) }} | ||
|
||
{{ constant(constant='ThisDoesNotExist::SomeKey') }} | ||
{{ constant(constant=someVar) }} | ||
{{ constant(constant='ThisDoesNotExist::class') }} | ||
{{ constant(constant=1) }} | ||
|
||
{{ notConstant('ThisDoesNotExist::class') }} | ||
{% endblock %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take any suggestion here @ruudk but I'd like to avoid a too long error message.
So far I always had short message like "Variable should be called foo" or "Expected 2 spaces, found 1". This gave report with all the error messages written on single line every time and I'm not happy with the fact that this error would be certainly written with multiples lines.
Maybe letter something like an additional help text could be written, but so far I'd like a short message.
I try
'You cannot use the function "constant()" to resolve class names.'
but take any suggestionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine. This is coming directly from https://github.com/twigphp/Twig/blob/1377f2da4efa020d2ad9b8fb8b722d688ab297ad/src/Extension/CoreExtension.php#L1474