Skip to content

Commit

Permalink
Fix: Return early
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Apr 27, 2023
1 parent 542181c commit 1bd434f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 2 additions & 5 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.7.7@e028ba46ba0d7f9a78bc3201c251e137383e145f">
<files psalm-version="5.9.0@8b9ad1eb9e8b7d3101f949291da2b9f7767cd163">
<file src="src/Faker/Calculator/Luhn.php">
<InvalidReturnStatement>
<code>0</code>
Expand Down Expand Up @@ -140,11 +140,8 @@
</file>
<file src="src/Faker/Provider/Base.php">
<InvalidArgument>
<code><![CDATA[[static::class, 'randomDigit']]]></code>
<code>[static::class, 'randomDigit']</code>
</InvalidArgument>
<NoValue>
<code>$array</code>
</NoValue>
<UndefinedDocblockClass>
<code>Closure</code>
</UndefinedDocblockClass>
Expand Down
6 changes: 5 additions & 1 deletion src/Faker/Provider/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ public static function randomElements($array = ['a', 'b', 'c'], $count = 1, $all
*/
public static function randomElement($array = ['a', 'b', 'c'])
{
if (!$array || ($array instanceof \Traversable && !count($array))) {
if ([] === $array) {
return null;
}

if ($array instanceof \Traversable && !count($array)) {
return null;
}

Expand Down

0 comments on commit 1bd434f

Please sign in to comment.