From eb232f84f7647fda054fd83f149df74a69df2182 Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Thu, 2 Apr 2026 20:48:43 +0200 Subject: [PATCH 1/2] Integrate new io.Blob class --- src/main/php/text/json/Format.class.php | 15 +++++++++---- .../json/unittest/JsonOutputTest.class.php | 22 +++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/main/php/text/json/Format.class.php b/src/main/php/text/json/Format.class.php index 11afaba..8269057 100755 --- a/src/main/php/text/json/Format.class.php +++ b/src/main/php/text/json/Format.class.php @@ -1,6 +1,7 @@ 'value'; }]; } + /** @return iterable */ + private function blobs() { + yield ['""', new Blob()]; + yield ['"Test"', new Blob(['Test'])]; + yield ['"Test \"the\" west"', new Blob(['Test', ' "the" ', 'west'])]; + yield ['"Test\t"', new Blob(['Test', "\t"])]; + yield ['"Tested"', new Blob(['Test', 'ed'])]; + yield ['"Tested"', new Blob((function() { yield 'Test'; yield 'ed'; })())]; + } + #[Before] public function usePrecision() { self::$precision= ini_set('precision', 14); @@ -147,6 +158,17 @@ public function write_generator($expected, $write) { Assert::equals($expected, $this->write($write())); } + #[Test, Values(from: 'blobs')] + public function write_blob($expected, $write) { + Assert::equals($expected, $this->write($write)); + } + + /** @see https://bugs.php.net/bug.php?id=77069 */ + #[Test, Runtime(php: '>=7.4.14')] + public function write_encoded_blob() { + Assert::equals('"VGVzdA=="', $this->write((new Blob('Test'))->encoded('convert.base64-encode'))); + } + #[Test, Expect(IllegalArgumentException::class)] public function cannot_write_closures() { $this->write(function() { }); From c09b998bb1cd9b43d97a45c77a70fc304f934491 Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Sat, 17 Oct 2026 11:16:29 +0200 Subject: [PATCH 2/2] Drop XP 11 See https://github.com/xp-forge/json/pull/19#discussion_r4302173172 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 72618c9..85eaf2d 100755 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "description" : "Reads and writes JSON to and from various input sources", "keywords": ["module", "xp"], "require" : { - "xp-framework/core": "^12.11 | ^11.11", + "xp-framework/core": "^12.11", "php" : ">=7.4.0" }, "require-dev" : {