Fork me on GitHub
a Sensio Labs Product

I ate three cookies 🍪 (v3.40.2) edition

Rule get_class_to_class_keyword

Replace get_class calls on object variables with class keyword syntax.


Using this rule is risky

Risky if the get_class function is overridden.


Example #1

--- Original
+++ New

Example #2

--- Original
+++ New

 $date = new \DateTimeImmutable();
-$class = get_class($date);
+$class = $date::class;

Rule sets

The rule is part of the following rule sets:

Source class