Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply PHP 8 compatibility changes #3947

Merged
merged 2 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/I18n/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ public function setYear($value)
*/
public function setMonth($value)
{
if (is_numeric($value) && $value < 1 || $value > 12)
if (is_numeric($value) && ($value < 1 || $value > 12))
{
throw I18nException::forInvalidMonth($value);
}
Expand Down
4 changes: 2 additions & 2 deletions system/Validation/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public function matches(string $str = null, string $field, array $data): bool
*/
public function max_length(string $str = null, string $val): bool
{
return ($val >= mb_strlen($str));
return (is_numeric($val) && $val >= mb_strlen($str));
}

//--------------------------------------------------------------------
Expand All @@ -289,7 +289,7 @@ public function max_length(string $str = null, string $val): bool
*/
public function min_length(string $str = null, string $val): bool
{
return ($val <= mb_strlen($str));
return (is_numeric($val) && $val <= mb_strlen($str));
}

//--------------------------------------------------------------------
Expand Down
11 changes: 10 additions & 1 deletion tests/system/Helpers/ArrayHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,16 @@ public function testArraySortByMultipleKeysFailsEmptyParameter($data, $sortColum
*/
public function testArraySortByMultipleKeysFailsInconsistentArraySizes($data)
{
$this->expectException('ErrorException');
// PHP 8 changes this error type
if (version_compare(PHP_VERSION, '8.0', '<'))
{
$this->expectException('ErrorException');
}
else
{
$this->expectException('ValueError');
}

$this->expectExceptionMessage('Array sizes are inconsistent');

$sortColumns = [
Expand Down