Skip to content

Commit ae3c398

Browse files
committed
Update nette/neon
1 parent a40b5d6 commit ae3c398

File tree

3 files changed

+51
-8
lines changed

3 files changed

+51
-8
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"jetbrains/phpstorm-stubs": "dev-master#bdc8acd7c04c0c87197849c7cdd27e44b67b56c7",
1919
"nette/bootstrap": "^3.0",
2020
"nette/di": "^3.1.4",
21-
"nette/neon": "^3.3.1",
21+
"nette/neon": "3.3.3",
2222
"nette/schema": "^1.2.2",
2323
"nette/utils": "^3.2.5",
2424
"nikic/php-parser": "^4.17.1",
@@ -109,6 +109,9 @@
109109
],
110110
"nette/di": [
111111
"patches/DependencyChecker.patch"
112+
],
113+
"nette/neon": [
114+
"patches/NetteNeonStringNode.patch"
112115
]
113116
}
114117
},

composer.lock

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

patches/NetteNeonStringNode.patch

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--- src/Neon/Node/StringNode.php 2022-03-10 03:04:26
2+
+++ src/Neon/Node/StringNode.php 2024-08-26 14:53:45
3+
@@ -79,27 +79,18 @@
4+
5+
public function toString(): string
6+
{
7+
- if (strpos($this->value, "\n") === false) {
8+
- return "'" . str_replace("'", "''", $this->value) . "'";
9+
+ $res = json_encode($this->value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
10+
+ if ($res === false) {
11+
+ throw new Nette\Neon\Exception('Invalid UTF-8 sequence: ' . $this->value);
12+
+ }
13+
14+
- } elseif (preg_match('~\n[\t ]+\'{3}~', $this->value)) {
15+
- $s = json_encode($this->value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
16+
- $s = preg_replace_callback(
17+
- '#[^\\\\]|\\\\(.)#s',
18+
- function ($m) {
19+
- return ['n' => "\n", 't' => "\t", '"' => '"'][$m[1] ?? ''] ?? $m[0];
20+
- },
21+
- substr($s, 1, -1)
22+
- );
23+
- $s = str_replace('"""', '""\"', $s);
24+
- $delim = '"""';
25+
-
26+
- } else {
27+
- $s = $this->value;
28+
- $delim = "'''";
29+
+ if (strpos($this->value, "\n") !== false) {
30+
+ $res = preg_replace_callback('#[^\\\\]|\\\\(.)#s', function ($m) {
31+
+ return ['n' => "\n\t", 't' => "\t", '"' => '"'][$m[1] ?? ''] ?? $m[0];
32+
+ }, $res);
33+
+ $res = '"""' . "\n\t" . substr($res, 1, -1) . "\n" . '"""';
34+
}
35+
36+
- $s = preg_replace('#^(?=.)#m', "\t", $s);
37+
- return $delim . "\n" . $s . "\n" . $delim;
38+
+ return $res;
39+
}
40+
}

0 commit comments

Comments
 (0)