1.2.618. Is_A() With String

When using is_a() with a string as first argument, the third argument is compulsory. The third argument is $allow_string, and is necessary to work on strings.

<?php

// is_a() works with string as first argument, when the third argument is 'true'
if (is_a('A', 'B', true)) {}

// is_a() works with object as first argument
if (is_a(new A, 'A')) {}
?>

See also is_a.

1.2.618.1. Suggestions

  • Add the third argument, and set it to true

  • Use an object as a first argument

1.2.618.2. Specs

Short name

Php/IsAWithString

Rulesets

All, Analyze, CE, CI-checks, Changed Behavior, Rector

Exakat since

1.9.9

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

class, interface

Available in

Entreprise Edition, Community Edition, Exakat Cloud