]> granicus.if.org Git - php/commitdiff
Fix escapes for namespaced classes in gen_stub.php
authorTyson Andre <tysonandre775@hotmail.com>
Fri, 23 Aug 2019 01:14:00 +0000 (21:14 -0400)
committerChristoph M. Becker <cmbecker69@gmx.de>
Fri, 23 Aug 2019 10:29:55 +0000 (12:29 +0200)
Fix the string generated when the `ns\class` is passed to a macro

    #define ESCAPE(x) #x
    // puts(ESCAPE(ns\class));  // warning: unknown escape sequence: \c
    puts(ESCAPE(ns\\class));  // Properly prints ns\class to stdout.

scripts/dev/gen_stub.php

index 6146009df31b40abd88a21b0cce172e55a88641f..0ae4a441633ea413c484277ab754d74a9f323b79 100755 (executable)
@@ -305,7 +305,7 @@ function funcInfoToCode(FuncInfo $funcInfo): string {
             $code .= sprintf(
                 "ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_%s, %d, %d, %s, %d)\n",
                 $funcInfo->name, $funcInfo->return->byRef, $funcInfo->numRequiredArgs,
-                $returnType->name, $returnType->isNullable
+                str_replace('\\', '\\\\', $returnType->name), $returnType->isNullable
             );
         }
     } else {
@@ -328,7 +328,7 @@ function funcInfoToCode(FuncInfo $funcInfo): string {
                 $code .= sprintf(
                     "\tZEND_%s_OBJ_INFO(%d, %s, %s, %d)\n",
                     $argKind, $argInfo->byRef, $argInfo->name,
-                    $argInfo->type->name, $argInfo->type->isNullable
+                    str_replace('\\', '\\\\', $argInfo->type->name), $argInfo->type->isNullable
                 );
             }
         } else {