php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81630 PHP 8.1: ReflectionClass->getTraitAliases() crashes with Internal error
Submitted: 2021-11-17 12:55 UTC Modified: 2021-11-17 14:28 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: ondrej at mirtes dot cz Assigned:
Status: Closed Package: Reflection related
PHP Version: 8.1.0RC6 OS: N/A
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ondrej at mirtes dot cz
New email:
PHP Version: OS:

 

 [2021-11-17 12:55 UTC] ondrej at mirtes dot cz
Description:
------------
Unfortunately I don't have a simple reproducing script here, but I know there's a bug in ReflectionClass when asking for trait aliases.

A code that executes the same methods crashes when I run it in context of PHPStan: https://3v4l.org/oSI4m

The error message is:

Uncaught Error: Internal error: Failed to retrieve the reflection object in phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/Php/PhpClassReflectionExtension.php:576 #0 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/Php/PhpClassReflectionExtension.php(576): ReflectionClass->getTraitAliases() #1 

Maybe it's related to some internal state of ReflectionClass or maybe the way how it was obtained, but calling `ReflectionClass->getTraitAliases()` always results in a crash on PHP 8.1. It works on PHP 8.0.

Hopefully this gives you enough information to track it down. Thanks.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-17 13:43 UTC] nikic@php.net
Any non-simple way of reproducing it (like running phpstan tests?) I don't think this is directly related to getTraitAliases(), the exception indicates that the ReflectionClass object is not fully uninitialized.
 [2021-11-17 13:47 UTC] ondrej at mirtes dot cz
There’s a repository that shows the bug inside Docker: https://github.com/edubacco/phpstan-bug-5954-php81

I tried to reproduce it outside of PHPStan but with no luck :/ It also doesn’t help thst the Laravel classes and traits are so huge.
 [2021-11-17 14:28 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2021-11-17 14:28 UTC] nikic@php.net
Thanks, I can reproduce with the provided repo.
 [2021-11-17 14:55 UTC] git@php.net
Automatic comment on behalf of nikic
Revision: https://github.com/php/php-src/commit/6641e3b8f42795bd5955f59112c459435131d5ba
Log: Fix bug #81630: Don't claim known hash in getTraitAliases()
 [2021-11-17 14:55 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC