Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 49719392e6855ef1727e286bfc378395589c29d5 1 parent bbd76d8
Nikolay Matveev authored
Showing with 69 additions and 0 deletions.
  1. +2 −0  .gitignore
  2. +67 −0 phpstubgen.php
View
2  .gitignore
@@ -0,0 +1,2 @@
+.idea
+out
View
67 phpstubgen.php
@@ -0,0 +1,67 @@
+<?php
+$outDir = getcwd() . "/out";
+if (!file_exists($outDir)) {
+ $result = mkdir($outDir, 0755, true);
+}
+
+$loaded_extensions = get_loaded_extensions();
+
+foreach ($loaded_extensions as $extensionName) {
+ handleExtension($extensionName);
+}
+
+function handleExtension($extensionName)
+{
+
+ $out = fopen("out\\$extensionName.php", 'w');
+ fwrite($out, "<?php\n");
+ $reflectionExtension = new ReflectionExtension($extensionName);
+
+ //constants
+ $constants = $reflectionExtension->getConstants();
+ foreach ($constants as $constantName => $constantValue) {
+ if (is_string($constantValue)) {
+ $constantValue = "'$constantValue'";
+ }
+ fwrite($out, "const $constantName = $constantValue;\n");
+ }
+
+ //functions
+ $defined_functions = $reflectionExtension->getFunctions();
+ foreach ($defined_functions as $definedFunction) {
+ /** @var $definedFunction ReflectionFunction */
+ $definedFunctionName = $definedFunction->getName();
+ fwrite($out, "function $definedFunctionName(");
+ $parameters = $definedFunction->getParameters();
+ $isFirstParameter = true;
+ foreach ($parameters as $parameter) {
+ if ($isFirstParameter) {
+ $isFirstParameter = false;
+ } else {
+ fwrite($out, ", ");
+ }
+ /** @var $parameter ReflectionParameter */
+ if ($parameter->isPassedByReference()) {
+ fwrite($out, "&");
+ }
+ $parameterName = $parameter->getName();
+ fwrite($out, "$$parameterName");
+ if ($parameter->isDefaultValueAvailable()) {
+ fwrite($out, " = ");
+ print_r($parameter->getDefaultValue());
+ }
+ }
+ fwrite($out, "){ }\n");
+ }
+
+ //classes
+ $classes = $reflectionExtension->getClasses();
+ foreach ($classes as $class) {
+ /** @var $class ReflectionClass */
+ $className = $class->getName();
+
+ fwrite($out, "class $className {\n");
+ fwrite($out, "}\n");
+ }
+ fclose($out);
+}

0 comments on commit 4971939

Please sign in to comment.
Something went wrong with that request. Please try again.