jordanbrauer / phelpers

Collection of random helper QoL functions for PHP.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

the `get` function cannot read data from objects which implement magic properties & methods

jordanbrauer opened this issue · comments

The specific place is when we actually check for the existence of a property on the object. In this case we just need to add an additional condition the check using isset.

if ($isObject and (isset($subject, $path) or \property_exists($subject, $path))) {
    # ...
}

isset is first in the existence check as it is the fastest (being a language construct, not a function call) and if true will short circuit the calls to property_exists. In other words, property_exists should be our plan B and isset should be first line of defence.