Replace get_class
calls on object variables with class keyword syntax.
Risky if the get_class
function is overridden.
--- Original
+++ New
<?php
-get_class($a);
+$a::class;
--- Original
+++ New
<?php
$date = new \DateTimeImmutable();
-$class = get_class($date);
+$class = $date::class;
The rule is part of the following rule sets:
- Fixer class: PhpCsFixer\Fixer\LanguageConstruct\GetClassToClassKeywordFixer
- Test class: PhpCsFixer\Tests\Fixer\LanguageConstruct\GetClassToClassKeywordFixerTest
The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.