[php-src] Issue #12440: DOM methods do not provide a return type for ReflectionMethod

From: Date: Sat, 14 Oct 2023 22:21:19 +0000
Subject: [php-src] Issue #12440: DOM methods do not provide a return type for ReflectionMethod
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245572@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12440
Author: 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](https://github.com/php/php-src/blob/d0b29d82863789cae658d13ccc8153c01c8a4d0c/ext/dom/php_dom.stub.php#L786-L787)
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
<?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.3.0RC4

### Operating System

_No response_


Thread (1 message)

  • JoshyPHP
« previous php.bugs (#245572) next »