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 have a file, hello.php, with the following contents:
<?phpfunctionhi(): array
{
return [];
}
If I run phpcs against it, I got notified that it is violating WordPress.WhiteSpace.ControlStructureSpacing.OpenBraceNotSameLine:
$ vendor/bin/phpcs -s hello.php
FILE: hello.php
-------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------------------
3 | ERROR | [x] Opening brace should be on the same line as the declaration (WordPress.WhiteSpace.ControlStructureSpacing.OpenBraceNotSameLine)
-------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------------
So far so good. If I run phpcbf, it corrects it badly:
$ vendor/bin/phpcbf hello.php
PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE FIXED REMAINING
----------------------------------------------------------------------
hello.php 1 0
----------------------------------------------------------------------
A TOTAL OF 1 ERROR WERE FIXED IN 1 FILE
----------------------------------------------------------------------
The result is:
<?phpfunctionhi() {
return [];
}
As you can see, phpcbf has corrected the issue with the opening curly brace, but it has deleted the declared return type of the function hi. It should still have : array before the opening curly brace.
Here are my version numbers:
PHPCS: 3.1.0
WPCS: 0.13.1
PHP: 7.1.8
The text was updated successfully, but these errors were encountered:
I have a file,
hello.php
, with the following contents:If I run
phpcs
against it, I got notified that it is violating WordPress.WhiteSpace.ControlStructureSpacing.OpenBraceNotSameLine:So far so good. If I run
phpcbf
, it corrects it badly:The result is:
As you can see,
phpcbf
has corrected the issue with the opening curly brace, but it has deleted the declared return type of the functionhi
. It should still have: array
before the opening curly brace.Here are my version numbers:
The text was updated successfully, but these errors were encountered: