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]));
36 $ext = new ReflectionExtension($ext);
37 foreach ($ext->getConstants() as $constant => $value) {
38 printf("define('%s', '%s');\n", $constant, $value);
42 foreach ($ext->getFunctions() as $f) {
43 printf("function %s(", $f->getName());
45 foreach ($f->getParameters() as $p) {
46 $p1 = sprintf("%s%s\$%s", t($p), $p->isPassedByReference()?
"&":"", $p->getName());
47 if ($p->isOptional()) {
48 if ($p->isDefaultValueAvailable()) {
49 $p1 .= sprintf(" = %s", var_export($p->getDefaultValue(), true));
50 } elseif (!($p->isArray() ||
$p->getClass()) ||
$p->allowsNull()) {
52 } elseif ($p->isArray()) {
58 printf("%s) {\n}\n", implode(", ", $ps));
62 $classes = $ext->getClasses();
63 usort($classes, function($a,$b) {
64 $cmp = strcmp($a->getNamespaceName(), $b->getNamespaceName());
66 $cmp = strcmp($a->getShortName(), $b->getShortName());
72 foreach ($classes as $class) {
74 if ($class->inNamespace()) {
75 printf("namespace %s\n{\n", $class->getNamespaceName());
77 printf("\t%s%s %s ", m($class->getModifiers()), $class->isInterface() ?
"interface":"class" ,$class->getShortName());
78 if ($p = $class->getParentClass()) {
79 printf("extends \\%s ", $p->getName());
81 if ($i = $class->getInterfaceNames()) {
82 printf("implements \\%s ", implode(", \\", array_filter($i,function($v){return$v!="Traversable";})));
87 foreach ($class->getConstants() as $n => $v) {
88 c($n, $class) and $_+
=printf("\t\tconst %s = %s;\n", $n, var_export($v, true));
92 foreach ($class->getProperties() as $p) {
93 if ($p->getDeclaringClass()->getName() == $class->getName()) {
94 $_+
=printf("\t\t%s\$%s;\n", m($p->getModifiers()), $p->getName());
99 foreach ($class->getMethods() as $m) {
100 if ($m->getDeclaringClass()->getName() == $class->getName()) {
101 printf("\t\t%sfunction %s(", m($m->getModifiers()), $m->getName());
103 foreach ($m->getParameters() as $p) {
104 $p1 = sprintf("%s%s\$%s", t($p), $p->isPassedByReference()?
"&":"", $p->getName());
105 if ($p->isOptional()) {
106 if ($p->isDefaultValueAvailable()) {
107 $p1 .= sprintf(" = %s", var_export($p->getDefaultValue(), true));
108 } elseif (!($p->isArray() ||
$p->getClass()) ||
$p->allowsNull()) {
109 $p1 .= sprintf(" = NULL");
110 } elseif ($p->isArray()) {
116 printf("%s)", implode(", ", $ps));
117 if ($m->isAbstract()) {
120 printf(" {\n\t\t}\n\n");
126 if ($class->inNamespace()) {