Skip to content

Commit bb4d381

Browse files
authored
[9.x] Simplify some conditions with is_countable() (#41168)
* Simplify come conditions with is_countable(). * Remove useless import.
1 parent ed8d75b commit bb4d381

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/Illuminate/Translation/Translator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function choice($key, $number, array $replace = [], $locale = null)
153153
// If the given "number" is actually an array or countable we will simply count the
154154
// number of elements in an instance. This allows developers to pass an array of
155155
// items without having to count it on their end first which gives bad syntax.
156-
if (is_array($number) || $number instanceof Countable) {
156+
if (is_countable($number)) {
157157
$number = count($number);
158158
}
159159

src/Illuminate/Validation/Concerns/ValidatesAttributes.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Illuminate\Validation\Concerns;
44

5-
use Countable;
65
use DateTime;
76
use DateTimeInterface;
87
use Egulias\EmailValidator\EmailValidator;
@@ -1518,7 +1517,7 @@ public function validateRequired($attribute, $value)
15181517
return false;
15191518
} elseif (is_string($value) && trim($value) === '') {
15201519
return false;
1521-
} elseif ((is_array($value) || $value instanceof Countable) && count($value) < 1) {
1520+
} elseif (is_countable($value) && count($value) < 1) {
15221521
return false;
15231522
} elseif ($value instanceof File) {
15241523
return (string) $value->getPath() !== '';

0 commit comments

Comments
 (0)