Description
Preconditions (*)
In PHP 8, \ReflectionType has become abstract and ReflectionType::isBuiltin() has been moved to ReflectionNamedType::isBuiltin() .
Now, if $method->getReturnType() is called, it may return ReflectionNamedType (which has isBuiltin method) or ReflectionUnionType (which doesn't).
Details: https://www.php.net/manual/en/class.reflectiontype.php#reflectiontype.changelog
There are several places in the code where a construction like this is used:
$method->getReturnType()->isBuiltin()
and because of changes described it may cause Fatal error in some cases.
We need to check our codebase in all repositories and add an additional check to be sure that such fatal error will not occur.
Expected result (*)
Check and update the codebase to avoid fatal error when using ReflectionType::isBuiltin() method.
example of a possible fix:
https://github.com/magento/magento2/pull/34192/files#diff-d4ad1b0935431ef01f9f01309d7a3990f0eaef6c9bc0e0a52be4c6533ec7fefdR129