-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reflection: FilesystemIterator uses unknown class as type-hint #2057
Comments
(Moving the discussion back from the commit comments to here) Can you give a short view into what's being done here? Assuming the code reads something like this: $param= new ReflectionParameter(...);
if ($param->isArray()) {
// Handle array type hint
} else if ($param->isCallable()) {
// Handle callable type hint (PHP 5 >= 5.4.0)
} else if (null !== ($class= $param->getClass())) {
// Handle classes
} else {
// No type hint
} ...I don't see how this breaks; we'll run into the No type hint branch in both HHVM (with #1600 applied) and PHP. |
Putting the above script into a test.php and letting it run with various environments: PHP 5.5.10Timm@slate ~
$ /cygdrive/c/Programme/php-5.5.10/php test.php FilesystemIterator::setFlags
Primitive HHVM 2.4.0:friebe@xpsrv ~/devel/hhvm $ hhvm test.php FilesystemIterator::setFlags
HipHop Fatal error: Uncaught exception 'ReflectionException' with message 'Class int does not exist' in :
Stack trace:
#0 (): ReflectionClass->__construct()
#1 /home/friebe/devel/hhvm/test.php(18): ReflectionParameter->getClass()
#2 {main} HHVM 2.5.0-dev with #1600 applied:friebe@xpsrv ~/devel/hhvm $ ./hphp/hhvm/hhvm test.php FilesystemIterator::setFlags
Primitive |
@thekid ah, I completely missed the branch where that commit was: apologies! Yes, if the "no-hint" path will be hit, then we're fine. Sorry about all the noise, I just misunderstood your fix. |
No problem. Also, the fix is not yet merged:) |
Thanks for reporting this. |
Sorry, we weren't able to take #1600 as it changed too much at the same time, and it was impractical to debug all the issues it raised. I'll take a look at this now. It seems like this demonstrates the issue: <?php
function foo(int $bar) {
};
$rp = new ReflectionParameter('foo', 'bar');
var_dump($rp->getClass());
It should output NULL. |
Fix up for review internally (changing ReflectionParameter::getClass()). FB: D1356779 |
It seems like
FilesystemIterator#setFlags()
has a parameter hintedint $flags
.While this is obviously working within HHVM, reflection chokes on it with a
HipHop Fatal error: Uncaught exception 'ReflectionException' with message 'Class int does not exist
Not sure what the solution here would be. Is there a list of scalar typehints that should be excluded from trying to introspect method parameters?
The issue currently affects
Zend\Code\Reflection
and related API.Note: the simplest resolution is to just remove the hint for now.
Edit: #1600 is actually a possible fix for this.
The text was updated successfully, but these errors were encountered: