@@ -1636,6 +1636,23 @@ static ZEND_COLD void zend_ast_export_qstr(smart_str *str, char quote, const zen
16361636 }
16371637}
16381638
1639+ static ZEND_COLD void zend_ast_export_quoted_str (smart_str * str , zend_string * s )
1640+ {
1641+ size_t i ;
1642+
1643+ for (i = 0 ; i < ZSTR_LEN (s ); i ++ ) {
1644+ if ((unsigned char ) ZSTR_VAL (s )[i ] < ' ' ) {
1645+ smart_str_appendc (str , '"' );
1646+ zend_ast_export_qstr (str , '"' , s );
1647+ smart_str_appendc (str , '"' );
1648+ return ;
1649+ }
1650+ }
1651+ smart_str_appendc (str , '\'' );
1652+ zend_ast_export_str (str , s );
1653+ smart_str_appendc (str , '\'' );
1654+ }
1655+
16391656static ZEND_COLD void zend_ast_export_indent (smart_str * str , int indent )
16401657{
16411658 while (indent > 0 ) {
@@ -1907,9 +1924,7 @@ static ZEND_COLD void zend_ast_export_zval(smart_str *str, const zval *zv, int p
19071924 str , Z_DVAL_P (zv ), (int ) EG (precision ), /* zero_fraction */ true);
19081925 break ;
19091926 case IS_STRING :
1910- smart_str_appendc (str , '\'' );
1911- zend_ast_export_str (str , Z_STR_P (zv ));
1912- smart_str_appendc (str , '\'' );
1927+ zend_ast_export_quoted_str (str , Z_STR_P (zv ));
19131928 break ;
19141929 case IS_ARRAY : {
19151930 zend_long idx ;
@@ -1924,9 +1939,8 @@ static ZEND_COLD void zend_ast_export_zval(smart_str *str, const zval *zv, int p
19241939 smart_str_appends (str , ", " );
19251940 }
19261941 if (key ) {
1927- smart_str_appendc (str , '\'' );
1928- zend_ast_export_str (str , key );
1929- smart_str_appends (str , "' => " );
1942+ zend_ast_export_quoted_str (str , key );
1943+ smart_str_appends (str , " => " );
19301944 } else {
19311945 smart_str_append_long (str , idx );
19321946 smart_str_appends (str , " => " );
0 commit comments