-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fixer breaks the file when code violates both PEAR.Functions.FunctionDeclaration
and Squiz.WhiteSpace.ScopeClosingBrace
#3736
Comments
Thanks for reporting this. I can confirm the bug and it is unrelated to the This can be confirmed by using the following code sample: // Removes the close brace of the function declaration.
class Test
{
public function __construct(
protected int $id
)
{}
}
// Fixes fine, no problems.
class Test
{
public function __construct(
protected int $id
)
{ }
}
// Fixes fine, no problems.
class Test
{
public function __construct(
protected int $id
)
{
// comment
}
} The changeset for the first two code samples is as follows:
And the problem is clearly visible in the first changeset:
|
PR #3739 should fix this. Testing appreciated. |
FYI: the fix for this issue is included in today's PHP_CodeSniffer 3.8.0 release. As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo). |
Describe the bug
If there is a code that violates both
PEAR.Functions.FunctionDeclaration
andSquiz.WhiteSpace.ScopeClosingBrace
sniffs, the fixer (CBF) will break the file because of deleting the extra brace.Code sample
Custom ruleset
To reproduce
Steps to reproduce the behavior:
test.php
with the code sample above...phpcbf test.php ...
test.php
Expected behavior
Fixer should not "eat" the closing brace of the class.
Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: