[php-src] Issue #11023: Uncaught Error: Call to undefined method ReflectionUnionType::getName()

From: Date: Wed, 05 Apr 2023 22:52:33 +0000
Subject: [php-src] Issue #11023: Uncaught Error: Call to undefined method ReflectionUnionType::getName()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244115@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11023 Author: binemmanuel ### Description The following code: ```php # User.php <?php class User extends BaseModel { public ?String $userId; public ?String $username; public ?String $email; public ?String $password; } # User.php <?php $props = array_map( array: (new \ReflectionClass(User::class))->getProperties(), callback: fn (\ReflectionProperty $prop) => [ 'name' => $prop->getName(), 'type' => $prop->getType()->getName(), ], ); ``` Resulted in this output: ``` [Wed Apr 5 23:17:26 2023] 127.0.0.1:58975 [200]: GET /make-table - Uncaught Error: Call to undefined method ReflectionUnionType::getName() in /Users/binemmanuel/Projects/easyphp/example/src/controllers/Home.php:39 Stack trace: #0 [internal function]:Example\Controller\Home->Example\Controller\{closure}(Object(ReflectionProperty)) #1 /app/example/src/controllers/Home.php(40): array_map(Object(Closure), Array) #2 /app/src/Router.php(144):Example\Controller\Home->makeDBTable(Object(App\Request), Object(App\Response), NULL) #3 /app/example/public_html/index.php(119): App\Router->run() #4 {main} thrown in /app/example/src/controllers/Home.php on line 39 ``` ### PHP Version PHP 8.1.13 ### Operating System MacOS 13.1

« previous php.bugs (#244115) next »