|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-09-16 21:29 UTC] cmb@php.net
-Package: *Extensibility Functions
+Package: FFI
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 12:00:02 2025 UTC |
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 )