c55eb65290bb0c2a19656ca967ff9abf8ba7d31b
6 foreach (Reflection
::getModifierNames($m) as $mn) {
12 if ($c = $p->getClass()) return "\\" . $c->getName() . " ";
13 if ($p->isArray()) return "array ";
17 while ($c = $c->getParentClass()) {
18 if (array_key_exists($n, $c->getConstants())) {
23 foreach ((array) $c->getInterfaces() as $i) {
24 if (array_key_exists($n, $i->getConstants()) ||
!c($n, $i)) {
31 if (!strlen($ext = $argv[1]))
32 die(sprintf("Usage: %s <ext>\n", $argv[0]));
34 $ext = new ReflectionExtension($ext);
35 foreach ($ext->getConstants() as $constant => $value) {
36 printf("const %s = %s;\n", $constant, $value);
40 foreach ($ext->getFunctions() as $f) {
41 printf("function %s(", $f->getName());
43 foreach ($f->getParameters() as $p) {
44 $p1 = sprintf("%s%s\$%s", t($p), $p->isPassedByReference()?
"&":"", $p->getName());
45 if ($p->isOptional()) {
46 if ($p->isDefaultValueAvailable()) {
47 $p1 .= sprintf(" = %s", var_export($p->getDefaultValue(), true));
48 } elseif (!($p->isArray() ||
$p->getClass()) ||
$p->allowsNull()) {
50 } elseif ($p->isArray()) {
56 printf("%s) {\n}\n", implode(", ", $ps));
60 foreach ($ext->getClasses() as $class) {
62 if ($class->inNamespace()) {
63 printf("namespace %s {\n", $class->getNamespaceName());
65 printf("%s%s %s ", m($class->getModifiers()), $class->isInterface() ?
"interface":"class" ,$class->getShortName());
66 if ($p = $class->getParentClass()) {
67 printf("extends \\%s ", $p->getName());
69 if ($i = $class->getInterfaceNames()) {
70 printf("implements \\%s ", implode(", \\", array_filter($i,function($v){return$v!="Traversable";})));
75 foreach ($class->getConstants() as $n => $v) {
76 c($n, $class) and $_+
=printf("\tconst %s = %s;\n", $n, var_export($v, true));
80 foreach ($class->getProperties() as $p) {
81 if ($p->getDeclaringClass()->getName() == $class->getName()) {
82 $_+
=printf("\t%s\$%s;\n", m($p->getModifiers()), $p->getName());
87 foreach ($class->getMethods() as $m) {
88 if ($m->getDeclaringClass()->getName() == $class->getName()) {
89 printf("\t%sfunction %s(", m($m->getModifiers()), $m->getName());
91 foreach ($m->getParameters() as $p) {
92 $p1 = sprintf("%s%s\$%s", t($p), $p->isPassedByReference()?
"&":"", $p->getName());
93 if ($p->isOptional()) {
94 if ($p->isDefaultValueAvailable()) {
95 $p1 .= sprintf(" = %s", var_export($p->getDefaultValue(), true));
96 } elseif (!($p->isArray() ||
$p->getClass()) ||
$p->allowsNull()) {
97 $p1 .= sprintf(" = NULL");
98 } elseif ($p->isArray()) {
104 printf("%s) {\n\t}\n", implode(", ", $ps));
109 if ($class->inNamespace()) {