When using php 8, trying to use/resolve a non-existent class - such as in a ContainerConfig via set() and then lazyGet() - gives the following obscure and misleading error:
Fatal error: Uncaught TypeError: get_parent_class(): Argument #1 ($object_or_class) must be an object or a valid class name, string given in /var/www/vendor/aura/di/src/Resolver/Resolver.php:209
In reality, get_parent_class() does accept a string and this hasn't changed in php 8. The important part of the error is 'valid class name', not 'string given'. This had me stumped for a good hour or more thinking the issue was php 8 when in fact it was a class name typo. It would be great if a better error could be generated by checking for the existence of a class before passing it to get_parent_class() or something. It's a fatal error so I'm not sure anything could be done after the error to catch and improve the message.
When using php 8, trying to use/resolve a non-existent class - such as in a ContainerConfig via
set()
and thenlazyGet()
- gives the following obscure and misleading error:In reality,
get_parent_class()
does accept a string and this hasn't changed in php 8. The important part of the error is 'valid class name', not 'string given'. This had me stumped for a good hour or more thinking the issue was php 8 when in fact it was a class name typo. It would be great if a better error could be generated by checking for the existence of a class before passing it toget_parent_class()
or something. It's a fatal error so I'm not sure anything could be done after the error to catch and improve the message.