Closed
Description
Describe the bug
When creating an anonymous class while passing constructor arguments phpcs requests a space between class
and the (
. I did not expect this and it looks off.
Code sample
<?php
namespace foo;
class Foo
{
protected function foo()
{
new class(1) extends Bar { // line 9
};
}
}
Custom ruleset
<?xml version="1.0"?>
<ruleset>
<file>./test/</file>
<arg name="extensions" value="php" />
<arg value="p"/>
<arg name="basepath" value="."/>
<rule ref="PSR12"/>
</ruleset>
To reproduce
Steps to reproduce the behavior:
- Create a file called
test.php
with the code sample above. - Run
phpcs test.php
- See error message displayed
FILE: test/test.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
9 | ERROR | [x] Expected 1 space after class keyword; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
Expected behavior
I expected that error not to be reported, because I believe there should not be a space between class
and (
.
Versions (please complete the following information):
- OS: Docker container (Debian based) on Ubuntu host.
- PHP: 7.4.12
- PHPCS: 3.5.8 (stable)
- Standard: PSR12
Additional context
PHP-CS-Fixer with the PSR2 ruleset expects the space to not be there.
Metadata
Metadata
Assignees
Labels
No labels