[php-src] Issue #12865: Reflection parameter type could be more precise about specific BackedEnum::from() and tryFrom() type

From: Date: Mon, 04 Dec 2023 12:41:16 +0000
Subject: [php-src] Issue #12865: Reflection parameter type could be more precise about specific BackedEnum::from() and tryFrom() type
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245976@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12865 Author: ondrejmirtes ### Description The following code: ```php <?php declare(strict_types=1); enum IntBacked: int { case One = 1; } $rm = new ReflectionMethod(IntBacked::class, 'tryFrom'); var_export((string) $rm->getParameters()[0]->getType()); ``` Resulted in this output: ``` 'string|int' ``` But I expected this output instead: ``` 'int' ``` Because when a bad type is passed in there, it's rejected with TypeError: ``` Argument #1 ($value) must be of type int, string given ``` Related: https://github.com/php/php-src/issues/12863 ### PHP Version PHP 8.1+ ### Operating System _No response_

« previous php.bugs (#245976) next »