]> granicus.if.org Git - php/commitdiff
Support regenerating all stubs
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 12 Aug 2019 08:27:08 +0000 (10:27 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 12 Aug 2019 08:27:22 +0000 (10:27 +0200)
ext/gettext/gettext_arginfo.h
ext/json/json_arginfo.h
scripts/dev/gen_stub.php

index 6ac4cac5e5ae8fb1db98b48df9f5dabccb2e8180..ee248aafaeb62a3ca654ac240a9469e51a52c557 100644 (file)
@@ -1,6 +1,6 @@
 /* This is a generated file, edit the .stub.php file instead. */
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_textdomain, 0, 0, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_textdomain, 0, 0, 1)
        ZEND_ARG_TYPE_INFO(0, domain, IS_STRING, 1)
 ZEND_END_ARG_INFO()
 
index fa0dcea5aed3211168ccda306c0af1cbe752b185..9c6f30686a606fd988ef0cc0702e17f7e99dc9f2 100644 (file)
@@ -8,7 +8,7 @@ ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_json_decode, 0, 0, 1)
        ZEND_ARG_TYPE_INFO(0, json, IS_STRING, 0)
-       ZEND_ARG_TYPE_INFO(0, assoc, _IS_BOOL, 0)
+       ZEND_ARG_TYPE_INFO(0, assoc, _IS_BOOL, 1)
        ZEND_ARG_TYPE_INFO(0, depth, IS_LONG, 0)
        ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0)
 ZEND_END_ARG_INFO()
index 48b89da1138fde411da14c09cf98d6525a5b8c3b..6caffda14d7d1b32db7c8fe6b1553ce9a2a9a2ea 100755 (executable)
@@ -13,20 +13,34 @@ try {
     exit(1);
 }
 
-if ($argc < 2) {
-    die("Usage: php gen_stub.php foobar.stub.php\n");
+if ($argc >= 2) {
+    // Generate single file.
+    processStubFile($argv[1]);
+} else {
+    // Regenerate all stub files we can find.
+    $it = new RecursiveIteratorIterator(
+        new RecursiveDirectoryIterator('.'),
+        RecursiveIteratorIterator::LEAVES_ONLY
+    );
+    foreach ($it as $file) {
+        $pathName = $file->getPathName();
+        if (preg_match('/\.stub\.php$/', $pathName)) {
+            processStubFile($pathName);
+        }
+    }
 }
 
-$stubFile = $argv[1];
-$arginfoFile = str_replace('.stub.php', '', $stubFile) . '_arginfo.h';
+function processStubFile(string $stubFile) {
+    $arginfoFile = str_replace('.stub.php', '', $stubFile) . '_arginfo.h';
 
-try {
-    $funcInfos = parseStubFile($stubFile);
-    $arginfoCode = generateArgInfoCode($funcInfos);
-    file_put_contents($arginfoFile, $arginfoCode);
-} catch (Exception $e) {
-    echo "Caught {$e->getMessage()} while processing $stubFile\n";
-    exit(1);
+    try {
+        $funcInfos = parseStubFile($stubFile);
+        $arginfoCode = generateArgInfoCode($funcInfos);
+        file_put_contents($arginfoFile, $arginfoCode);
+    } catch (Exception $e) {
+        echo "Caught {$e->getMessage()} while processing $stubFile\n";
+        exit(1);
+    }
 }
 
 class Type {