1.2.815. No Need For get_class()

There is no need to call get_class() to build a static call. The argument of get_class() may be used directly.

<?php

//
$a->b::$c

// This is too much code
get_class($a->b)::$c

?>

See also Scope Resolution Operator (::).

1.2.815.1. Suggestions

  • Use get_called_class(), which may carry different class names

  • Use self, static or parent keywords, if you are already in the current class

  • Use the argument of get_class() directly

1.2.815.2. Specs

Short name

Structures/NoNeedGetClass

Rulesets

All, Suggestions

Exakat since

1.8.1

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Features

class

Available in

Entreprise Edition, Exakat Cloud