1.2.1629. get_class() Without Argument

get_class() and get_parent_class() should not be called without arguments. It was possible until PHP 8.3, but it is now a deprecated behavior.

<?php

$a = new stdClass;

print get_class($a);

?>

1.2.1629.1. Suggestions

  • Use get_called_class() instead

  • Use __CLASS__ magic constant instead

1.2.1629.2. Specs

Short name

Structures/GetClassWithoutArg

Rulesets

All, CompatibilityPHP83

Exakat since

2.6.1

PHP Version

With PHP 9.0 and older

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Available in

Entreprise Edition, Exakat Cloud