Closed
Description
Describe the bug
When instantiating a parent class using the keyword "parent", PHPCS flags this as wrong and PHPCBF inserts brackets after the new
thus breaking code.
Code sample
see also: https://3v4l.org/5WDl4
class SomeClass extends ParentClass
{
//...
public function foo(): static
{
$class = new parent();
//...
}
}
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
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------
line | ERROR | [x] Parentheses must be used when instantiating a new class
| | (PSR12.Classes.ClassInstantiation.MissingParentheses)
Expected behavior
No error report and no changed code from PHPCBF.
Versions (please complete the following information):
- OS: Linux
- PHP: 8.0
- PHPCS: 3.7.1
- Standard: PSR12