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

[5.7] Always prefer stricter assertions for count comparisons #26157

Merged
merged 1 commit into from
Oct 18, 2018
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 src/Illuminate/Auth/Recaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ protected function hasAllSegments()
{
$segments = explode('|', $this->recaller);

return count($segments) == 3 && trim($segments[0]) !== '' && trim($segments[1]) !== '';
return count($segments) === 3 && trim($segments[0]) !== '' && trim($segments[1]) !== '';
}
}
2 changes: 1 addition & 1 deletion src/Illuminate/Console/Scheduling/ManagesFrequencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function dailyAt($time)
$segments = explode(':', $time);

return $this->spliceIntoPosition(2, (int) $segments[0])
->spliceIntoPosition(1, count($segments) == 2 ? (int) $segments[1] : '0');
->spliceIntoPosition(1, count($segments) === 2 ? (int) $segments[1] : '0');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Container/BoundMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected static function callClass($container, $target, array $parameters = [],
// We will assume an @ sign is used to delimit the class name from the method
// name. We will split on this @ sign and then build a callable array that
// we can pass right back into the "call" method for dependency binding.
$method = count($segments) == 2
$method = count($segments) === 2
? $segments[1] : $defaultMethod;

if (is_null($method)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function isGuarded($key)
*/
public function totallyGuarded()
{
return count($this->getFillable()) == 0 && $this->getGuarded() == ['*'];
return count($this->getFillable()) === 0 && $this->getGuarded() == ['*'];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function withCount($relations)

unset($alias);

if (count($segments) == 3 && Str::lower($segments[1]) === 'as') {
if (count($segments) === 3 && Str::lower($segments[1]) === 'as') {
[$name, $alias] = [$segments[0], $segments[2]];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/Console/ListFailedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ListFailedCommand extends Command
*/
public function handle()
{
if (count($jobs = $this->getFailedJobs()) == 0) {
if (count($jobs = $this->getFailedJobs()) === 0) {
return $this->info('No failed jobs!');
}

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Redis/Connections/PhpRedisConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function setnx($key, $value)
*/
public function hmget($key, ...$dictionary)
{
if (count($dictionary) == 1) {
if (count($dictionary) === 1) {
$dictionary = $dictionary[0];
}

Expand All @@ -119,7 +119,7 @@ public function hmget($key, ...$dictionary)
*/
public function hmset($key, ...$dictionary)
{
if (count($dictionary) == 1) {
if (count($dictionary) === 1) {
$dictionary = $dictionary[0];
} else {
$input = collect($dictionary);
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Routing/RouteUrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ protected function getRouteQueryString(array $parameters)
// First we will get all of the string parameters that are remaining after we
// have replaced the route wildcards. We'll then build a query string from
// these string parameters then use it as a starting point for the rest.
if (count($parameters) == 0) {
if (count($parameters) === 0) {
return '';
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function median($key = null)
*/
public function mode($key = null)
{
if ($this->count() == 0) {
if ($this->count() === 0) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Translation/MessageSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function choose($line, $number, $locale)

$pluralIndex = $this->getPluralIndex($locale, $number);

if (count($segments) == 1 || ! isset($segments[$pluralIndex])) {
if (count($segments) === 1 || ! isset($segments[$pluralIndex])) {
return $segments[0];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ public function validateIn($attribute, $value, $parameters)
}
}

return count(array_diff($value, $parameters)) == 0;
return count(array_diff($value, $parameters)) === 0;
}

return ! is_array($value) && in_array((string) $value, $parameters);
Expand Down