1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix #12063 convert PHP single-quote to C double-quote string

This commit is contained in:
Remi Collet
2023-08-28 11:49:26 +02:00
committed by Remi Collet
parent ba9650d697
commit 13d3564a51
3 changed files with 6 additions and 2 deletions

View File

@@ -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));
}
}

View File

@@ -143,7 +143,7 @@ namespace {
enum ZendTestStringEnum: string {
case Foo = "Test1";
case Bar = "Test2";
case Bar = 'Test2';
case Baz = "Test2\\a";
case FortyTwo = "42";
}

View File

@@ -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()