From 13d3564a51be4f0cd3167620d2b18f65ea5fc535 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 28 Aug 2023 11:49:26 +0200 Subject: [PATCH] Fix #12063 convert PHP single-quote to C double-quote string --- build/gen_stub.php | 4 ++++ ext/zend_test/test.stub.php | 2 +- ext/zend_test/test_arginfo.h | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 6050184b2a4..c42e62557e3 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -1768,6 +1768,10 @@ class EvaluatedValue // $this->expr has all its PHP constants replaced by C constants $prettyPrinter = new Standard; $expr = $prettyPrinter->prettyPrintExpr($this->expr); + // PHP single-quote to C double-quote string + if ($this->type->isString()) { + $expr = preg_replace("/(^'|'$)/", '"', $expr); + } return $expr[0] == '"' ? $expr : preg_replace('(\bnull\b)', 'NULL', str_replace('\\', '', $expr)); } } diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index b78704f161c..cc76a3a7395 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -143,7 +143,7 @@ namespace { enum ZendTestStringEnum: string { case Foo = "Test1"; - case Bar = "Test2"; + case Bar = 'Test2'; case Baz = "Test2\\a"; case FortyTwo = "42"; } diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 4a436461728..1598443e41d 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: db7a89e93849c707caa1c536f717e0cf50dcfb74 */ + * Stub hash: 06ac12255321035a2669fbc5abf2f3fda4c6ad76 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_array_return, 0, 0, IS_ARRAY, 0) ZEND_END_ARG_INFO()