Skip to content

Commit

Permalink
v2.0.14
Browse files Browse the repository at this point in the history
* Fix errors in PHP 8.
  • Loading branch information
ve3 committed Dec 13, 2021
1 parent 38e1aed commit dc184c7
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
10 changes: 5 additions & 5 deletions Rundiz/Upload/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.<br>
* 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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -623,7 +623,7 @@ protected function setErrorMessage(
return false;
}
if (is_string($replaceValues)) {
$replaceValues = [$replaceValues];
$replaceValues = array($replaceValues);
}
// end check argument types. -------------------------

Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/PHP70/UploadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/PHP70/ValidatePropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/PHP72/UploadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/PHP72/ValidatePropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/PHPB70/UploadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/PHPB70/ValidatePropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit dc184c7

Please sign in to comment.