diff --git a/core/modules/file/src/FileRepository.php b/core/modules/file/src/FileRepository.php index 3ec359c61db770d5978014b872703cbf3ac75cfc..1a2d08d75af16cc0fb6577f74e8134fc4ea983f6 100644 --- a/core/modules/file/src/FileRepository.php +++ b/core/modules/file/src/FileRepository.php @@ -88,7 +88,7 @@ public function __construct(FileSystemInterface $fileSystem, StreamWrapperManage */ public function writeData(string $data, string $destination, int $replace = FileSystemInterface::EXISTS_RENAME): FileInterface { if (!$this->streamWrapperManager->isValidUri($destination)) { - throw new InvalidStreamWrapperException(sprintf('Invalid stream wrapper: %destination', ['%destination' => $destination])); + throw new InvalidStreamWrapperException("Invalid stream wrapper: {$destination}"); } $uri = $this->fileSystem->saveData($data, $destination, $replace); return $this->createOrUpdate($uri, $destination, $replace === FileSystemInterface::EXISTS_RENAME); @@ -132,7 +132,7 @@ protected function createOrUpdate(string $uri, string $destination, bool $rename */ public function copy(FileInterface $source, string $destination, int $replace = FileSystemInterface::EXISTS_RENAME): FileInterface { if (!$this->streamWrapperManager->isValidUri($destination)) { - throw new InvalidStreamWrapperException(sprintf('Invalid stream wrapper: %destination', ['%destination' => $destination])); + throw new InvalidStreamWrapperException("Invalid stream wrapper: {$destination}"); } $uri = $this->fileSystem->copy($source->getFileUri(), $destination, $replace); @@ -166,7 +166,7 @@ public function copy(FileInterface $source, string $destination, int $replace = */ public function move(FileInterface $source, string $destination, int $replace = FileSystemInterface::EXISTS_RENAME): FileInterface { if (!$this->streamWrapperManager->isValidUri($destination)) { - throw new InvalidStreamWrapperException(sprintf('Invalid stream wrapper: %destination', ['%destination' => $destination])); + throw new InvalidStreamWrapperException("Invalid stream wrapper: {$destination}"); } $uri = $this->fileSystem->move($source->getFileUri(), $destination, $replace); $delete_source = FALSE; diff --git a/core/modules/file/tests/src/Kernel/CopyTest.php b/core/modules/file/tests/src/Kernel/CopyTest.php index 668f99ae408938cd0257b4aa1cfa165292ad3033..9c8e79766b79dff48650732634f4c97c0b6f3aad 100644 --- a/core/modules/file/tests/src/Kernel/CopyTest.php +++ b/core/modules/file/tests/src/Kernel/CopyTest.php @@ -185,6 +185,7 @@ public function testExistingError() { */ public function testInvalidStreamWrapper() { $this->expectException(InvalidStreamWrapperException::class); + $this->expectExceptionMessage('Invalid stream wrapper: foo://'); $source = $this->createFile(); $this->fileRepository->copy($source, 'foo://'); } diff --git a/core/modules/file/tests/src/Kernel/FileRepositoryTest.php b/core/modules/file/tests/src/Kernel/FileRepositoryTest.php index 7db4dd08b9fcc82d90613995dcf7a95eb4516c2d..b7790a659c4938829493fa3fbc99a3169b1d55c4 100644 --- a/core/modules/file/tests/src/Kernel/FileRepositoryTest.php +++ b/core/modules/file/tests/src/Kernel/FileRepositoryTest.php @@ -170,6 +170,7 @@ public function testExistingError() { */ public function testInvalidStreamWrapper() { $this->expectException(InvalidStreamWrapperException::class); + $this->expectExceptionMessage('Invalid stream wrapper: foo://'); $this->fileRepository->writeData('asdf', 'foo://'); } diff --git a/core/modules/file/tests/src/Kernel/MoveTest.php b/core/modules/file/tests/src/Kernel/MoveTest.php index 389b86210fe679a9b22e6b2cbf735c4d6899832f..c48ed721cd095e1e3183f582afd8c1e873589af4 100644 --- a/core/modules/file/tests/src/Kernel/MoveTest.php +++ b/core/modules/file/tests/src/Kernel/MoveTest.php @@ -209,6 +209,7 @@ public function testExistingError() { */ public function testInvalidStreamWrapper() { $this->expectException(InvalidStreamWrapperException::class); + $this->expectExceptionMessage('Invalid stream wrapper: foo://'); $source = $this->createFile(); $this->fileRepository->move($source, 'foo://'); }