summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2021-06-16 10:06:17 +0200
committerRemi Collet <remi@remirepo.net>2021-06-16 10:06:17 +0200
commitd18cf8bc918d26cdad25d1311a7effe4bd308f48 (patch)
tree7edbee7a806f8339213cad22879a16eff9e6bdcc
parent7e6f833ca3f4421f410322aa1f1b398173befe00 (diff)
add small script to sort reflection of an PHP extension (only methods)
-rw-r--r--.gitignore10
-rwxr-xr-xsortrefl51
2 files changed, 61 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5090361
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,10 @@
+checkpkgist/
+diffrpmtree
+docker/
+ffi-examples/
+git2rss/
+mine.lst
+mock/
+myrpms
+repodata/
+
diff --git a/sortrefl b/sortrefl
new file mode 100755
index 0000000..f38efb5
--- /dev/null
+++ b/sortrefl
@@ -0,0 +1,51 @@
+#!/usr/bin/php
+<?php
+if ($_SERVER['argc'] < 2) {
+ die("usage %s filename\n");
+}
+$in = fopen($name = $_SERVER['argv'][1], "r");
+if (!$in) {
+ die("Can't read input file $name\n");
+}
+
+$res = [];
+$tab = [];
+$class = $method = false;
+fprintf(STDERR, "Reading $name:\n");
+while ($buf = fgets($in)) {
+ if (preg_match("/Class .* class ([^ ]*) /", $buf, $m)) {
+ $class = strtolower($m[1]);
+ $res[$class] = [];
+ $tab[$class] = $buf;
+ fprintf(STDERR, "+ $class\n");
+ } else if (preg_match("/Method .* method ([^ ]*) /", $buf, $m)) {
+ $method = strtolower($m[1]);
+ $res[$class][$method] = '';
+ fprintf(STDERR, "+ $method\n");
+ }
+
+ if ($class) {
+ if ($method) {
+ $res[$class][$method] .= $buf;
+ }
+ }
+
+ if (strpos($buf, "}") == 8) {
+ $method = false;
+ } else if (strpos($buf, "}") == 4) {
+ $class = false;
+ }
+}
+
+ksort($res);
+foreach ($res as $class => $methods) {
+ echo $tab[$class];
+
+ ksort($methods);
+ foreach ($methods as $method => $def) {
+ echo $def;
+ }
+}
+fprintf(STDERR, "\nDone\n");
+fclose($in);
+?>