From dc184c7ff8ada13111097408ed0b2cff5048bb99 Mon Sep 17 00:00:00 2001 From: ve3 Date: Mon, 13 Dec 2021 15:18:07 +0700 Subject: [PATCH] v2.0.14 * Fix errors in PHP 8. --- Rundiz/Upload/Upload.php | 10 +++++----- tests/phpunit/PHP70/UploadTest.php | 2 +- tests/phpunit/PHP70/ValidatePropertiesTest.php | 3 ++- tests/phpunit/PHP72/UploadTest.php | 2 +- tests/phpunit/PHP72/ValidatePropertiesTest.php | 3 ++- tests/phpunit/PHPB70/UploadTest.php | 2 +- tests/phpunit/PHPB70/ValidatePropertiesTest.php | 3 ++- 7 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Rundiz/Upload/Upload.php b/Rundiz/Upload/Upload.php index 077f2f8..5dc1181 100644 --- a/Rundiz/Upload/Upload.php +++ b/Rundiz/Upload/Upload.php @@ -13,7 +13,7 @@ * PHP upload class that is able to validate requirements and limitations, real file's mime type check, detect the errors and report. * * @package Upload - * @version 2.0.13 + * @version 2.0.14 * @author Vee W. * * @property-read array $predefinedErrorMessages Pre-defined error messages. @@ -85,7 +85,7 @@ class Upload * Important! This property is not recommend to set it if you upload multiple files with same input file name. It is recommended to leave this as null and set overwrite property to true or false.
* If you want to set the name while upload multiple files, it is recommended that you set overwrite property to false. */ - public $new_file_name; + public $new_file_name = ''; /** * @var boolean To overwrite the uploaded file set it to true, otherwise set it to false. @@ -272,7 +272,7 @@ public function clear() $this->max_image_dimensions = array(); $this->move_uploaded_queue = array(); $this->move_uploaded_to = '.'; - $this->new_file_name = null; + $this->new_file_name = ''; $this->overwrite = false; $this->web_safe_file_name = true; $this->security_scan = false; @@ -623,7 +623,7 @@ protected function setErrorMessage( return false; } if (is_string($replaceValues)) { - $replaceValues = [$replaceValues]; + $replaceValues = array($replaceValues); } // end check argument types. ------------------------- @@ -1360,7 +1360,7 @@ protected function validateOptionsProperties() } if (!is_string($this->new_file_name) && $this->new_file_name != null) { - $this->new_file_name = null; + $this->new_file_name = ''; } if (!is_bool($this->overwrite)) { diff --git a/tests/phpunit/PHP70/UploadTest.php b/tests/phpunit/PHP70/UploadTest.php index 61d1044..737a331 100644 --- a/tests/phpunit/PHP70/UploadTest.php +++ b/tests/phpunit/PHP70/UploadTest.php @@ -409,7 +409,7 @@ public function testWebSafeFileName() ), ); $Upload->setFilesPropertyForCheck(); - $Upload->new_file_name = null; + $Upload->new_file_name = ''; $Upload->setNewFileName(); $Upload->setWebSafeFileName(); $this->assertNotSame('', $Upload->new_file_name); diff --git a/tests/phpunit/PHP70/ValidatePropertiesTest.php b/tests/phpunit/PHP70/ValidatePropertiesTest.php index 49d95f9..eef0a37 100644 --- a/tests/phpunit/PHP70/ValidatePropertiesTest.php +++ b/tests/phpunit/PHP70/ValidatePropertiesTest.php @@ -166,7 +166,8 @@ public function testNewFileName() $Upload->new_file_name = array('newFileName'); $Upload->validateOptionsProperties(); - $this->assertNull($Upload->new_file_name); + $this->assertIsString($Upload->new_file_name); + $this->assertEmpty($Upload->new_file_name); $Upload->new_file_name = 'newFileName'; $Upload->validateOptionsProperties(); diff --git a/tests/phpunit/PHP72/UploadTest.php b/tests/phpunit/PHP72/UploadTest.php index fb35921..498b364 100644 --- a/tests/phpunit/PHP72/UploadTest.php +++ b/tests/phpunit/PHP72/UploadTest.php @@ -417,7 +417,7 @@ public function testWebSafeFileName() ), ); $Upload->setFilesPropertyForCheck(); - $Upload->new_file_name = null; + $Upload->new_file_name = ''; $Upload->setNewFileName(); $Upload->setWebSafeFileName(); $this->assertNotSame('', $Upload->new_file_name); diff --git a/tests/phpunit/PHP72/ValidatePropertiesTest.php b/tests/phpunit/PHP72/ValidatePropertiesTest.php index c492b99..5ca90e1 100644 --- a/tests/phpunit/PHP72/ValidatePropertiesTest.php +++ b/tests/phpunit/PHP72/ValidatePropertiesTest.php @@ -166,7 +166,8 @@ public function testNewFileName() $Upload->new_file_name = array('newFileName'); $Upload->validateOptionsProperties(); - $this->assertNull($Upload->new_file_name); + $this->assertIsString($Upload->new_file_name); + $this->assertEmpty($Upload->new_file_name); $Upload->new_file_name = 'newFileName'; $Upload->validateOptionsProperties(); diff --git a/tests/phpunit/PHPB70/UploadTest.php b/tests/phpunit/PHPB70/UploadTest.php index 7c69c69..6f9876d 100644 --- a/tests/phpunit/PHPB70/UploadTest.php +++ b/tests/phpunit/PHPB70/UploadTest.php @@ -409,7 +409,7 @@ public function testWebSafeFileName() ), ); $Upload->setFilesPropertyForCheck(); - $Upload->new_file_name = null; + $Upload->new_file_name = ''; $Upload->setNewFileName(); $Upload->setWebSafeFileName(); $this->assertNotSame('', $Upload->new_file_name); diff --git a/tests/phpunit/PHPB70/ValidatePropertiesTest.php b/tests/phpunit/PHPB70/ValidatePropertiesTest.php index 8a45416..6634bd4 100644 --- a/tests/phpunit/PHPB70/ValidatePropertiesTest.php +++ b/tests/phpunit/PHPB70/ValidatePropertiesTest.php @@ -166,7 +166,8 @@ public function testNewFileName() $Upload->new_file_name = array('newFileName'); $Upload->validateOptionsProperties(); - $this->assertNull($Upload->new_file_name); + $this->assertIsString($Upload->new_file_name); + $this->assertEmpty($Upload->new_file_name); $Upload->new_file_name = 'newFileName'; $Upload->validateOptionsProperties();