Bug #78544 [NEW]: FFI\CData et al do not support ReflectionObject nor get_object_vars()
| From: | asmqb7 at gmail dot com | Date: | Sun, 15 Sep 2019 13:43:56 +0000 |
| Subject: | Bug #78544 [NEW]: FFI\CData et al do not support ReflectionObject nor get_object_vars() | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-222755@lists.php.net to get a copy of this message | ||
From: asmqb7 at gmail dot com
Operating system: Linux
PHP version: 7.4.0RC1
Package: *Extensibility Functions
Bug Type: Bug
Bug description:FFI\CData et al do not support ReflectionObject nor get_object_vars()
Description:
------------
I fully expect this is already known and in the to-implement queue;
perhaps this bug could be use to track progress.
FFI\CData does not support reflection-based analysis, rendering
virtually all third-party data inspection tools (ie alternatives to
print_r() and var_dump()) useless (unless there are some cool obscure
bits I'm missing - I sadly doubt this, but hey, just in case...).
One related thing of possibly-particular note is that var_dump() and
print_r() are able to access an informative type label like
"FFI\CData:struct test", while ReflectionObject and get_object_vars()
only seem to have access to an effectively meaningless "FFI\CData".
Hopefully this is just because reflection-specific capabilities are not
yet implemented(?).
Thanks very much in advance whenever this gets fixed! :)
Test script:
---------------
<?php
$ffi = FFI::cdef(' struct test { int dummy; }; ');
$test = $ffi->new('struct test');
$r = new ReflectionObject($test);
print "getShortName: "; var_dump($r->getShortName());
print "getMethods: "; var_dump($r->getMethods());
print "__toString: "; var_dump($r->__toString());
print "getDefaultProperties: "; var_dump($r->getDefaultProperties());
print "getProperties: "; var_dump($r->getProperties());
print "get_object_vars: "; var_dump(get_object_vars($r));
print "var_dump(): "; var_dump($test);
print "print_r(): "; print_r($test);
Expected result:
----------------
For the output made available through var_dump() et al to be accessible
via ReflectionObject
Actual result:
--------------
getShortName: string(5) "CData"
getMethods: array(0) {
}
__toString: <<<boring, snipped>>>
getDefaultProperties: array(0) {
}
getProperties: array(0) {
}
get_object_vars: array(1) {
["name"]=>
string(9) "FFI\CData"
}
var_dump(): object(FFI\CData:struct test)#2 (1) {
["dummy"]=>
int(0)
}
print_r(): FFI\CData:struct test Object
(
[dummy] => 0
)
--
Edit bug report at https://bugs.php.net/bug.php?id=78544&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78544&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78544&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78544&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78544&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78544&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78544&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78544&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78544&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78544&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78544&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78544&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78544&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78544&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78544&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78544&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78544&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78544&r=mysqlcfg