Closed n18l closed 3 years ago
Could you supply your phpcs configuration please (standards used, .xml file)?
Sorry for the slow response on this! Here's the project's current phpcs.xml
file:
<?xml version="1.0"?>
<ruleset name="ddm-standard">
<description>PSR2 based coding standard.</description>
<file>web/app/themes</file>
<exclude-pattern>*/twenty*/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/cache/*</exclude-pattern>
<exclude-pattern>*/*.js</exclude-pattern>
<exclude-pattern>*/*.css</exclude-pattern>
<exclude-pattern>*/*.xml</exclude-pattern>
<exclude-pattern>*/autoload.php</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>dist</exclude-pattern>
<rule ref="PSR1">
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
</rule>
<rule ref="PSR2">
<exclude name="Generic.Files.LineLength.TooLong" />
</rule>
<!--PHPCBF doesn't fix this violation automatically so mark it as a warning to prevent CI failures-->
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<type>warning</type>
<severity>8</severity>
</rule>
<!--PHPCBF doesn't fix this violation automatically so mark it as a warning to prevent CI failures-->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
<property name="absoluteLineLimit" value="120"/>
</properties>
<type>warning</type>
<severity>8</severity>
</rule>
</ruleset>
I fix this changing a variable in the settings.json
"php.validate.executablePath": "C:/php/php.exe"
this line allows vs to use a more updated version of php lint
Could not reproduce, does not seem an issue with the extension anyway — would probably be a bug in PHP_CodeSniffer.
Describe the bug
I'm experiencing what I believe to be false-positive error highlighting when attempting to use PHP 7.3's flexible HEREDOC syntax. From what I can tell, it's failing to consider the HEREDOC terminator as the actual end of a string unless it's in the first column of the editor.
PHPCS itself doesn't flag any errors with the way I'm using HEREDOC in this case, nor does PHP throw errors/warnings; only the extension seems to think something is out of place. My code's actual output works as intended.
To Reproduce
The following contrived example highlights an error:
You can resolve this error by moving the HEREDOC terminator to the first column (a pre-7.3 requirement):
You can also resolve it by not using HEREDOC at all, naturally:
But the previous example will give an identical error to the first if you forget to close your double-quote, like so:
This is what leads me to believe that the HEREDOC string is being treated as "unclosed" unless its terminator begins at column 0.
Expected behavior
No highlighted errors in the first example.
Environment
Extension settings
Additional context
I'm not 100% convinced vscode-php-sniffer is to blame for what I'm seeing, but so far it's the only link in the chain I don't have any additional control over. The test cases above were checked in VS Code with all other extensions disabled.
Thanks for any insight you can provide!