From 33db6310efe553863c256f0781e5d038268c1c5f Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 23 Mar 2023 07:36:38 +0100 Subject: [PATCH] Revert "[10.x] add Storage::json() method to read and decode a json file (#46548)" This reverts commit 706a076c93710f12763ea4bd04b022ab3ef6924a. --- src/Illuminate/Filesystem/Filesystem.php | 5 ++--- src/Illuminate/Filesystem/FilesystemAdapter.php | 14 -------------- tests/Filesystem/FilesystemAdapterTest.php | 14 -------------- 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/src/Illuminate/Filesystem/Filesystem.php b/src/Illuminate/Filesystem/Filesystem.php index 2219b15d7a17..b15ee1c6d633 100644 --- a/src/Illuminate/Filesystem/Filesystem.php +++ b/src/Illuminate/Filesystem/Filesystem.php @@ -63,15 +63,14 @@ public function get($path, $lock = false) * Get the contents of a file as decoded JSON. * * @param string $path - * @param int $flags * @param bool $lock * @return array * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ - public function json($path, $flags = 0, $lock = false) + public function json($path, $lock = false) { - return json_decode($this->get($path, $lock), true, 512, $flags); + return json_decode($this->get($path, $lock), true); } /** diff --git a/src/Illuminate/Filesystem/FilesystemAdapter.php b/src/Illuminate/Filesystem/FilesystemAdapter.php index 4a4fa1486b64..88ffe14dfdfe 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -262,20 +262,6 @@ public function get($path) } } - /** - * Get the contents of a file as decoded JSON. - * - * @param string $path - * @param int $flags - * @return array|null - */ - public function json($path, $flags = 0) - { - $content = $this->get($path); - - return is_null($content) ? null : json_decode($content, true, 512, $flags); - } - /** * Create a streamed response for a given file. * diff --git a/tests/Filesystem/FilesystemAdapterTest.php b/tests/Filesystem/FilesystemAdapterTest.php index d6cc99c64dcd..51d6d669c0a3 100644 --- a/tests/Filesystem/FilesystemAdapterTest.php +++ b/tests/Filesystem/FilesystemAdapterTest.php @@ -184,20 +184,6 @@ public function testGetFileNotFound() $this->assertNull($filesystemAdapter->get('file.txt')); } - public function testJsonReturnsDecodedJsonData() - { - $this->filesystem->write('file.json', '{"foo": "bar"}'); - $filesystemAdapter = new FilesystemAdapter($this->filesystem, $this->adapter); - $this->assertSame(['foo' => 'bar'], $filesystemAdapter->json('file.json')); - } - - public function testJsonReturnsNullIfJsonDataIsInvalid() - { - $this->filesystem->write('file.json', '{"foo":'); - $filesystemAdapter = new FilesystemAdapter($this->filesystem, $this->adapter); - $this->assertNull($filesystemAdapter->json('file.json')); - } - public function testMimeTypeNotDetected() { $this->filesystem->write('unknown.mime-type', '');