The reflection API works in a similar way of Python’s dir() function. The API provides a rich set of classes to reverse engineer classes, methods, parameters and functions.
Suppose, we want to explore and reverse engineer a class, then use the following code:
1 2 3 |
<?php Reflection::export(new ReflectionClass("Class_Name")); ?> |
For example:
1 2 3 |
<?php Reflection::export(new ReflectionClass("ZipArchive")); ?> |
Outputs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
Class [ <internal:zip> class ZipArchive ] { - Constants [43] { Constant [ integer CREATE ] { 1 } Constant [ integer EXCL ] { 2 } Constant [ integer CHECKCONS ] { 4 } Constant [ integer OVERWRITE ] { 8 } Constant [ integer FL_NOCASE ] { 1 } Constant [ integer FL_NODIR ] { 2 } Constant [ integer FL_COMPRESSED ] { 4 } Constant [ integer FL_UNCHANGED ] { 8 } Constant [ integer CM_DEFAULT ] { -1 } Constant [ integer CM_STORE ] { 0 } Constant [ integer CM_SHRINK ] { 1 } Constant [ integer CM_REDUCE_1 ] { 2 } Constant [ integer CM_REDUCE_2 ] { 3 } Constant [ integer CM_REDUCE_3 ] { 4 } Constant [ integer CM_REDUCE_4 ] { 5 } Constant [ integer CM_IMPLODE ] { 6 } Constant [ integer CM_DEFLATE ] { 8 } Constant [ integer CM_DEFLATE64 ] { 9 } Constant [ integer CM_PKWARE_IMPLODE ] { 10 } Constant [ integer ER_OK ] { 0 } Constant [ integer ER_MULTIDISK ] { 1 } Constant [ integer ER_RENAME ] { 2 } Constant [ integer ER_CLOSE ] { 3 } Constant [ integer ER_SEEK ] { 4 } Constant [ integer ER_READ ] { 5 } Constant [ integer ER_WRITE ] { 6 } Constant [ integer ER_CRC ] { 7 } Constant [ integer ER_ZIPCLOSED ] { 8 } Constant [ integer ER_NOENT ] { 9 } Constant [ integer ER_EXISTS ] { 10 } Constant [ integer ER_OPEN ] { 11 } Constant [ integer ER_TMPOPEN ] { 12 } Constant [ integer ER_ZLIB ] { 13 } Constant [ integer ER_MEMORY ] { 14 } Constant [ integer ER_CHANGED ] { 15 } Constant [ integer ER_COMPNOTSUPP ] { 16 } Constant [ integer ER_EOF ] { 17 } Constant [ integer ER_INVAL ] { 18 } Constant [ integer ER_NOZIP ] { 19 } Constant [ integer ER_INTERNAL ] { 20 } Constant [ integer ER_INCONS ] { 21 } Constant [ integer ER_REMOVE ] { 22 } Constant [ integer ER_DELETED ] { 23 } } - Static properties [0] { } - Static methods [0] { } - Properties [0] { } - Methods [27] { Method [ <internal:zip> public method open ] { } Method [ <internal:zip> public method close ] { } Method [ <internal:zip> public method addEmptyDir ] { } Method [ <internal:zip> public method addFromString ] { } Method [ <internal:zip> public method addFile ] { } Method [ <internal:zip> public method renameIndex ] { } Method [ <internal:zip> public method renameName ] { } Method [ <internal:zip> public method setArchiveComment ] { } Method [ <internal:zip> public method getArchiveComment ] { } Method [ <internal:zip> public method setCommentIndex ] { } Method [ <internal:zip> public method setCommentName ] { } Method [ <internal:zip> public method getCommentIndex ] { } Method [ <internal:zip> public method getCommentName ] { } Method [ <internal:zip> public method deleteIndex ] { } Method [ <internal:zip> public method deleteName ] { } Method [ <internal:zip> public method statName ] { } Method [ <internal:zip> public method statIndex ] { } Method [ <internal:zip> public method locateName ] { } Method [ <internal:zip> public method getNameIndex ] { } Method [ <internal:zip> public method unchangeArchive ] { } Method [ <internal:zip> public method unchangeAll ] { } Method [ <internal:zip> public method unchangeIndex ] { } Method [ <internal:zip> public method unchangeName ] { } Method [ <internal:zip> public method extractTo ] { } Method [ <internal:zip> public method getFromName ] { } Method [ <internal:zip> public method getFromIndex ] { } Method [ <internal:zip> public method getStream ] { } } } |
Cool, isn’t it? I loved it ! Thanks to Hasin Hayder for referring me to this API.
Read more at: http://www.php.net/language.oop5.reflection 😉