1.2.1360. Use get_debug_type()¶
get_debug_type() returns the given type of a variable. It was introduced in PHP 8.0: this makes it incompatible with previous versions.
<?php
// From the RFC
throw new TypeError('Expected ' . Foo::class . ' got ' . (is_object($bar) ? get_class($bar) : gettype($bar)));
// Becomes
throw new TypeError('Expected ' . Foo::class . ' got ' . get_debug_type($bar));
?>
See also PHP RFC: get_debug_type.
1.2.1360.1. Connex PHP features¶
1.2.1360.1.1. Suggestions¶
Replace the ternary with a call to get_debug_type()
1.2.1360.1.2. Specs¶
Short name |
Php/UseGetDebugType |
Rulesets |
|
Exakat since |
2.1.9 |
PHP Version |
With PHP 8.0 and more recent |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Medium |
Available in |