Skip to content

Prevent "PHP Notice: Undefined property: stdClass::$psr-4...."

Jason Gill requested to merge jasongill/ClassFinder:prevent-psr4-notice into master

If there are no PSR-4 namespaces defined in composer.json, the notice

PHP Notice:  Undefined property: stdClass::$psr-4 in vendor/haydenpierce/class-finder/src/PSR4/PSR4NamespaceFactory.php on line 55

is emitted due to the fact that the code does not check if psr-4 exists in the autoload array prior to trying to access it.

This merge request (hopefully) simplifies the process of getting the psr-4 autoload list by using json_decode() in associative array mode, preventing us from having to deal with strangely-named objects at all.

Merge request reports