PhpStorm 2019.3 Help

Code Inspection: Possible polymorphic call

Reports polymorphic code usages. Such usages are ambiguous and can be potentially inoperable depending on the class instance passed as the argument.

In the following example, the $property property is only defined in ChildClass but not in ParentClass. As a result, the getProperty function call is operable when a ChildClass instance is passed as an argument, but inoperable when a ParentClass instance is passed.

class ParentClass { } class ChildClass extends ParentClass { public $property = 1; } function getProperty(ParentClass $a) { echo $a->property; } getProperty(new ChildClass()); //will work, since $property is defined in Child getProperty(new ParentClass()); //won't work, since $property is not defined in Parent
Last modified: 27 March 2020