Skip to content

Commit 8ac2225

Browse files
committed
gen_stub: Unit test for stub escaped strings
1 parent 5530139 commit 8ac2225

5 files changed

Lines changed: 29 additions & 7 deletions

File tree

ext/zend_test/test.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class _ZendTestClass implements _ZendTestInterface {
6060
public static int $staticIntProp = 123;
6161

6262
/* If there's a problem with escapes in quotes in generated headers,
63-
* the generated header won't compile. */
63+
* the generated header won't compile. (tests/gh22169.phpt) */
6464
public static string $doubleQuoteEscaped = "BEGIN \n\r\t\v\e\f\\\$\"\101\x41\u{41} END";
6565
public static string $singleQuoteEscaped = 'BEGIN \n\r\t\v\e\f\\\$\"\101\x41\u{41} END';
6666
public static string $escapeInterpolated = "begin \$ \\$ end";

ext/zend_test/test_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/zend_test/test_decl.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/zend_test/test_legacy_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/zend_test/tests/gh22169.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-22169: Ensure escaped strings in stubs are valid
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
8+
// Avoid funny control characters in output...
9+
// "BEGIN " 424547494e20
10+
// "\n\r\t\v\e\f" 0a0d090b1b0c
11+
// "\\\$\"" 5c2422
12+
// "\101\x41\u{41}" 414141
13+
// " END" 20454e44
14+
var_dump(bin2hex(_ZendTestClass::$doubleQuoteEscaped));
15+
var_dump(_ZendTestClass::$singleQuoteEscaped);
16+
var_dump(_ZendTestClass::$escapeInterpolated);
17+
?>
18+
--EXPECT--
19+
string(44) "424547494e200a0d090b1b0c5c242241414120454e44"
20+
string(43) "BEGIN \n\r\t\v\e\f\\\\$\"\101\x41\u{41} END"
21+
string(14) "begin $ \$ end"
22+

0 commit comments

Comments
 (0)