Skip to content

DOM methods do not provide a return type for ReflectionMethod #12440

Description

@JoshyPHP

Description

DOM methods do not provide a return type when inspected via ReflectionMethod. I'm not sure whether it's by design, an oversight, or a bug. The DOM stub has return type annotations but no actual return type. As far as I can tell, DOM properties can be inspected normally too.

The following code:

<?php declare(strict_types=1);

$class    = new ReflectionClass('DOMDocument');
$method   = $class->getMethod('createElement');
$property = $class->getProperty('documentElement');
var_dump(
	phpversion(),
	$method->getReturnType(),
	$method->getTentativeReturnType(),
	$property->getType()->getName()
);

Resulted in this output:

string(8) "8.3.0RC4"
NULL
NULL
string(10) "DOMElement"

But I expected this output instead:

string(8) "8.3.0RC4"
object(ReflectionNamedType)
NULL
string(10) "DOMElement"

PHP Version

8.1.24, 8.2.11, 8.3.0RC4

Operating System

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions