You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use PSR12, which extends previous standards like PSR1 and PSR2:
"php.format.codeStyle": "PSR-12",
So by default the extension should use this standard in formatting, but it looks like extension settings, even if not set, override chosen standard. First of all you might want to add null to acceptable value types to avoid warnings (unless it's a bug within VSCode itself):
Even though I don't set any styling rules in settings.json (means this should be null and the rule directly from PSR12 standard should be used) and I don't even have premium active, these rules are used anyway like they were true instead of null:
For example:
if (isset($myVar)) {
...
}
if (!empty($myVar)) {
...
{
is formatted as
if (isset ($myVar)) {
...
}
if (!empty ($myVar)) {
...
{
Of course I'm just guessing that's the rule causing this problem here. It would really help with debugging these if there was code style inspection available 🙏 Something like PHP Sniffer extension has:
showing specific rule that triggers styling error:
The text was updated successfully, but these errors were encountered:
Since the last update of the extension (1.45), I've noticed that the formatter in this extension automatically (and unwantingly) adds the space before opening parenthesis of the function calls. This was not the case before. I don't have premium and I do not have this setting enabled. Enabling or disabling suppressing premium features makes no difference. I do have some other PHP extensions but none that do formatting.
PHPCS then complains about it because like OP I've got PSR12 defined as coding standard.
I'm not sure what's going on, but since Google led me here after I experience the same warning and cause, I figured I'd share. There's no such thing as a coincidence 😄
I use PSR12, which extends previous standards like PSR1 and PSR2:
So by default the extension should use this standard in formatting, but it looks like extension settings, even if not set, override chosen standard. First of all you might want to add
null
to acceptable value types to avoid warnings (unless it's a bug within VSCode itself):Even though I don't set any styling rules in settings.json (means this should be null and the rule directly from PSR12 standard should be used) and I don't even have premium active, these rules are used anyway like they were
true
instead ofnull
:For example:
is formatted as
It breaks rule PSR2.Methods.FunctionCallSignature.SpaceBeforeOpenBracket:
These are control structures:
Of course I'm just guessing that's the rule causing this problem here. It would really help with debugging these if there was code style inspection available 🙏 Something like PHP Sniffer extension has:
showing specific rule that triggers styling error:
The text was updated successfully, but these errors were encountered: