76 $files = \glob ( $pattern, $flags );
77 foreach ( \glob ( \dirname ( $pattern ) .
'/*', GLOB_ONLYDIR | GLOB_NOSORT ) as $dir ) {
78 $files = \array_merge ( $files, $this->glob_recursive ( $dir .
'/' . \basename ( $pattern ), $flags ) );
97 $tokens = \token_get_all ( $phpCode );
98 $count = \count ( $tokens );
101 $namespace_ok =
false;
102 while ( $i < $count ) {
103 $token = $tokens [$i];
104 if (\is_array ( $token ) && $token [0] === T_NAMESPACE) {
106 while ( ++ $i < $count ) {
107 if ($tokens [$i] ===
';') {
108 $namespace_ok =
true;
109 $namespace = \trim ( $namespace );
112 $namespace .= \is_array ( $tokens [$i] ) ? $tokens [$i] [1] : $tokens [$i];
118 if (! $namespace_ok) {
126 $tokens = \token_get_all ( $phpCode );
127 $count = count ( $tokens );
128 for($i = 2; $i < $count; $i ++) {
129 $elm = $tokens [$i - 2] [0];
130 if ($elm == T_CLASS && $tokens [$i - 1] [0] == T_WHITESPACE && $tokens [$i] [0] == T_STRING) {
131 $class_name = $tokens [$i] [1];
132 $classes [] = $class_name;
135 if (isset ( $classes [0] ))
140 private function asPhpArray($array, $prefix =
"", $depth = 1, $format =
false) {
146 $tab = \str_repeat (
"\t", $depth );
149 foreach ( $array as $k => $v ) {
150 if (\is_string ( $k )) {
151 $exts [] =
"\"" . $this->doubleBackSlashes ( $k ) .
"\"=>" . $this->parseValue ( $v,
'array', $depth + 1, $format );
153 $exts [] = $this->parseValue ( $v, $prefix, $depth + 1, $format );
156 if (\count ( $exts ) > 0 || $prefix !==
"") {
157 $extsStr =
"(" . \implode (
"," . $nl . $tab, $exts ) .
")";
158 if (\count ( $exts ) > 0) {
159 $extsStr =
"(" . $nl . $tab . \implode (
"," . $nl . $tab, $exts ) . $nl . $tab .
")";
162 return $prefix . $extsStr;
165 private function parseValue($v, $prefix =
"", $depth = 1, $format =
false) {
166 if (\is_array ( $v )) {
167 $result = $this->asPhpArray ( $v, $prefix, $depth + 1, $format );
168 } elseif ($v instanceof \Closure) {
169 $result = $this->closure_dump ( $v );
171 $result = $this->doubleBackSlashes ( $v );
172 $result =
"\"" . \str_replace ( [
'$',
'"' ], [
'\$',
'\"' ], $result ) .
"\"";
179 $r = new \ReflectionFunction ( $c );
181 foreach ( $r->getParameters () as $p ) {
183 if ($p->isArray ()) {
185 }
else if ($p->getClass ()) {
186 $s .= $p->getClass ()->name .
' ';
188 if ($p->isPassedByReference ()) {
191 $s .=
'$' . $p->name;
192 if ($p->isOptional ()) {
193 $s .=
' = ' . \var_export ( $p->getDefaultValue (), TRUE );
197 $str .= \implode (
', ', $params );
199 $lines = file ( $r->getFileName () );
200 $sLine = $r->getStartLine ();
201 $eLine = $r->getEndLine ();
202 if ($eLine === $sLine) {
203 $match = \strstr ( $lines [$sLine - 1],
"function" );
204 $str .= \strstr ( \strstr ( $match,
"{" ),
"}",
true ) .
"}";
206 $str .= \strrchr ( $lines [$sLine - 1],
"{" );
207 for($l = $sLine; $l < $eLine - 1; $l ++) {
210 $str .= \strstr ( $lines [$eLine - 1],
"}",
true ) .
"}";
212 $vars = $r->getStaticVariables ();
213 foreach ( $vars as $k => $v ) {
214 $str = \str_replace (
'$' . $k, \var_export ( $v,
true ), $str );