|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-11-05 22:44 UTC] nikic@php.net
-Status: Open
+Status: Not a bug
[2021-11-05 22:44 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 08:00:02 2025 UTC |
Description: ------------ Using the latest PHP version 8.1 RC 5 I would expect the ParameterUnionType to return the ReflectionNamedTypes in order in which they are defined at the method, but as it seems they are returned in a fixed order. Test script: --------------- <?php class MyClass { public function __construct(int|string $value) { } } $reflectionMethod = new ReflectionMethod(MyClass::class, '__construct'); $parameterUnionType = $reflectionMethod->getParameters()[0]->getType(); $types = array_map(fn(ReflectionNamedType $type) => $type->getName(), $parameterUnionType->getTypes()); // Expected: ['int', 'string'] // Actual: ['string', 'int'] Expected result: ---------------- // Expected: ['int', 'string'] Actual result: -------------- // Actual: ['string', 'int']