File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 99
1010namespace Nette \Neon \Node ;
1111
12+ use Nette \Neon \Exception ;
1213use Nette \Neon \Node ;
1314
1415
@@ -74,6 +75,9 @@ public function toString(): string
7475 return $ this ->value ;
7576
7677 } elseif (is_float ($ this ->value )) {
78+ if (!is_finite ($ this ->value )) {
79+ throw new Exception ('INF and NAN cannot be encoded to NEON ' );
80+ }
7781 $ res = json_encode ($ this ->value );
7882 return str_contains ($ res , '. ' ) ? $ res : $ res . '.0 ' ;
7983
Original file line number Diff line number Diff line change @@ -164,3 +164,9 @@ Assert::same(
164164 '[] ' ,
165165 Neon::encode ([], Neon::BLOCK ),
166166);
167+
168+ Assert::exception (
169+ fn () => Neon::encode (INF ),
170+ Nette \Neon \Exception::class,
171+ 'INF and NAN cannot be encoded to NEON ' ,
172+ );
You can’t perform that action at this time.
0 commit comments