Category
stdlib
Problem
ReflectionMethod (and ReflectionFunctionAbstract) must expose typed-return introspection per PHP 8+. This compiler implements getParameters() / getAttributes() but getReturnType(), isDeprecated(), and hasTentativeReturnType() are undefined — framework code using return-type reflection fails.
Pairs #5141 (hasReturnType() boolean probe) and #6594 (ReflectionType abstract hierarchy).
php-src reference
Repro (failure today)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "class T{function f(): int{}} \$m=new ReflectionMethod(T::class,\"f\"); var_export(\$m->getReturnType()?->getName());"
php -r "class T{function f(): int{}} \$m=new ReflectionMethod(T::class,\"f\"); var_export(\$m->getReturnType()?->getName());"
'
| Runtime |
Result |
| Zend PHP 8.2 |
'int' |
bin/vm.php |
Call to undefined method ReflectionMethod::getReturnType() |
Additional probes:
#[\Deprecated] class D { function f() {} }
(new ReflectionMethod(D::class, 'f'))->isDeprecated(); // Zend: true
class Tentative { function f(): int {} } // PHP 8.1 tentative on inherited — use fixture from php-src tests
Scope (this repo)
| Component |
Path |
| Metadata |
lib/VM/ReflectionSupport.php, compile-time return type storage on ClassMethod |
| VM methods |
lib/VM/Builtin/ReflectionMethodGetReturnType.php (new), register in BuiltinClasses.php |
| Return type objects |
#6594 — must return ReflectionNamedType / union / intersection extending ReflectionType |
| Compliance |
test/compliance/cases/stdlib/reflection_method_get_return_type.phpt |
PHP-in-PHP: implement in lib/VM/ + ext/standard/VmReflection.php; no C runtime.
Done when
- Repro prints
'int' for : int method; null for untyped legacy method
isDeprecated() matches #[\Deprecated] attribute on method/class (php-src rules)
hasTentativeReturnType() matches Zend on inherited tentative fixtures
- No undefined-method fatals for the three APIs on VM
- JIT/AOT: VM-only v1 documented in capability matrix
Strictness: php-src-strict
Related
Category
stdlibProblem
ReflectionMethod(andReflectionFunctionAbstract) must expose typed-return introspection per PHP 8+. This compiler implementsgetParameters()/getAttributes()butgetReturnType(),isDeprecated(), andhasTentativeReturnType()are undefined — framework code using return-type reflection fails.Pairs #5141 (
hasReturnType()boolean probe) and #6594 (ReflectionTypeabstract hierarchy).php-src reference
ext/reflection/php_reflection.c—reflection_method_get_return_type,reflection_method_is_deprecated,reflection_method_has_tentative_return_typeext/reflection/php_reflection.stub.phpRepro (failure today)
'int'bin/vm.phpCall to undefined method ReflectionMethod::getReturnType()Additional probes:
Scope (this repo)
lib/VM/ReflectionSupport.php, compile-time return type storage onClassMethodlib/VM/Builtin/ReflectionMethodGetReturnType.php(new), register inBuiltinClasses.php#6594— must returnReflectionNamedType/ union / intersection extendingReflectionTypetest/compliance/cases/stdlib/reflection_method_get_return_type.phptPHP-in-PHP: implement in
lib/VM/+ext/standard/VmReflection.php; no C runtime.Done when
'int'for: intmethod;nullfor untyped legacy methodisDeprecated()matches#[\Deprecated]attribute on method/class (php-src rules)hasTentativeReturnType()matches Zend on inherited tentative fixturesStrictness: php-src-strict
Related
hasReturnType()ReflectionTypehierarchy