From f54f7a400ca8b9875bebbc7a1eab120f6bb19b0e Mon Sep 17 00:00:00 2001 From: madflow Date: Tue, 3 Dec 2019 15:39:12 +0100 Subject: [PATCH] add PHP 7.4 --- .travis.yml | 5 ++++- src/Spout/Common/Helper/FileSystemHelper.php | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6df82ba..ac931ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -dist: trusty +dist: bionic sudo: false language: php @@ -13,6 +13,9 @@ matrix: env: WITH_PHPUNIT=true - php: 7.3 env: WITH_PHPUNIT=true + - php: 7.4 + env: WITH_PHPUNIT=true + cache: directories: diff --git a/src/Spout/Common/Helper/FileSystemHelper.php b/src/Spout/Common/Helper/FileSystemHelper.php index 4d5d223..4d21fd3 100644 --- a/src/Spout/Common/Helper/FileSystemHelper.php +++ b/src/Spout/Common/Helper/FileSystemHelper.php @@ -17,7 +17,7 @@ class FileSystemHelper implements FileSystemHelperInterface /** * @param string $baseFolderPath The path of the base folder where all the I/O can occur */ - public function __construct($baseFolderPath) + public function __construct(string $baseFolderPath) { $this->baseFolderRealPath = \realpath($baseFolderPath); } @@ -117,12 +117,16 @@ class FileSystemHelper implements FileSystemHelperInterface * should occur is not inside the base folder. * * @param string $operationFolderPath The path of the folder where the I/O operation should occur - * @throws \Box\Spout\Common\Exception\IOException If the folder where the I/O operation should occur is not inside the base folder + * @throws \Box\Spout\Common\Exception\IOException If the folder where the I/O operation should occur + * is not inside the base folder or the base folder does not exist * @return void */ - protected function throwIfOperationNotInBaseFolder($operationFolderPath) + protected function throwIfOperationNotInBaseFolder(string $operationFolderPath) { $operationFolderRealPath = \realpath($operationFolderPath); + if (!$this->baseFolderRealPath) { + throw new IOException("The base folder path is invalid: {$this->baseFolderRealPath}"); + } $isInBaseFolder = (\strpos($operationFolderRealPath, $this->baseFolderRealPath) === 0); if (!$isInBaseFolder) { throw new IOException("Cannot perform I/O operation outside of the base folder: {$this->baseFolderRealPath}");