Describe the bug
Sniff Squiz.Objects.ObjectInstantiation does not recognizes ?? and ??= operators as assignment.
Code sample
$time1 = new \DateTime();
$time2 ??= new \DateTime();
$time3 = $time1 ?? new \DateTime();
Custom ruleset
<?xml version="1.0"?>
<ruleset name="My Custom Standard">
<rule ref="Squiz.Objects.ObjectInstantiation" />
</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
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
4 | ERROR | New objects must be assigned to a variable
5 | ERROR | New objects must be assigned to a variable
Expected behavior
Error Squiz.Objects.ObjectInstantiation.NotAssigned is not reported for any of the lines.
Versions (please complete the following information):
- OS: Ubuntu Linux 20.10
- PHP: 8.0.5
- PHPCS: 3.6.0
- Standard: custom