diff --git a/src/Illuminate/Cache/CacheManager.php b/src/Illuminate/Cache/CacheManager.php index f52053c9b0bf..19721aa471e7 100755 --- a/src/Illuminate/Cache/CacheManager.php +++ b/src/Illuminate/Cache/CacheManager.php @@ -98,15 +98,15 @@ protected function resolve($name) if (isset($this->customCreators[$config['driver']])) { return $this->callCustomCreator($config); - } else { - $driverMethod = 'create'.ucfirst($config['driver']).'Driver'; - - if (method_exists($this, $driverMethod)) { - return $this->{$driverMethod}($config); - } else { - throw new InvalidArgumentException("Driver [{$config['driver']}] is not supported."); - } } + + $driverMethod = 'create'.ucfirst($config['driver']).'Driver'; + + if (method_exists($this, $driverMethod)) { + return $this->{$driverMethod}($config); + } + + throw new InvalidArgumentException("Driver [{$config['driver']}] is not supported."); } /** diff --git a/src/Illuminate/Database/Concerns/BuildsQueries.php b/src/Illuminate/Database/Concerns/BuildsQueries.php index 1051f2c91c85..41277c8c32ca 100644 --- a/src/Illuminate/Database/Concerns/BuildsQueries.php +++ b/src/Illuminate/Database/Concerns/BuildsQueries.php @@ -89,7 +89,9 @@ public function when($value, $callback, $default = null) { if ($value) { return $callback($this, $value) ?: $this; - } elseif ($default) { + } + + if ($default) { return $default($this, $value) ?: $this; } @@ -119,7 +121,9 @@ public function unless($value, $callback, $default = null) { if (! $value) { return $callback($this, $value) ?: $this; - } elseif ($default) { + } + + if ($default) { return $default($this, $value) ?: $this; } diff --git a/src/Illuminate/Database/Connectors/SqlServerConnector.php b/src/Illuminate/Database/Connectors/SqlServerConnector.php index 87525d121b66..40f3fc720a81 100755 --- a/src/Illuminate/Database/Connectors/SqlServerConnector.php +++ b/src/Illuminate/Database/Connectors/SqlServerConnector.php @@ -45,7 +45,9 @@ protected function getDsn(array $config) // need to establish the PDO connections and return them back for use. if (in_array('dblib', $this->getAvailableDrivers())) { return $this->getDblibDsn($config); - } elseif ($this->prefersOdbc($config)) { + } + + if ($this->prefersOdbc($config)) { return $this->getOdbcDsn($config); } @@ -166,9 +168,9 @@ protected function buildHostString(array $config, $separator) { if (isset($config['port']) && ! empty($config['port'])) { return $config['host'].$separator.$config['port']; - } else { - return $config['host']; } + + return $config['host']; } /** diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php index 2893495cbfd5..a4168589b26a 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php @@ -1055,12 +1055,18 @@ protected function originalIsEquivalent($key, $current) if ($current === $original) { return true; - } elseif (is_null($current)) { + } + + if (is_null($current)) { return false; - } elseif ($this->isDateAttribute($key)) { + } + + if ($this->isDateAttribute($key)) { return $this->fromDateTime($current) === $this->fromDateTime($original); - } elseif ($this->hasCast($key)) { + } + + if ($this->hasCast($key)) { return $this->castAttribute($key, $current) === $this->castAttribute($key, $original); } diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasGlobalScopes.php b/src/Illuminate/Database/Eloquent/Concerns/HasGlobalScopes.php index 97a549f6c73b..4c09a72113d2 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasGlobalScopes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasGlobalScopes.php @@ -22,9 +22,13 @@ public static function addGlobalScope($scope, Closure $implementation = null) { if (is_string($scope) && ! is_null($implementation)) { return static::$globalScopes[static::class][$scope] = $implementation; - } elseif ($scope instanceof Closure) { + } + + if ($scope instanceof Closure) { return static::$globalScopes[static::class][spl_object_hash($scope)] = $scope; - } elseif ($scope instanceof Scope) { + } + + if ($scope instanceof Scope) { return static::$globalScopes[static::class][get_class($scope)] = $scope; } diff --git a/src/Illuminate/Database/Migrations/Migrator.php b/src/Illuminate/Database/Migrations/Migrator.php index d55046dab47f..5a9fa82796c6 100755 --- a/src/Illuminate/Database/Migrations/Migrator.php +++ b/src/Illuminate/Database/Migrations/Migrator.php @@ -219,9 +219,9 @@ protected function getMigrationsForRollback(array $options) { if (($steps = $options['step'] ?? 0) > 0) { return $this->repository->getMigrations($steps); - } else { - return $this->repository->getLast(); } + + return $this->repository->getLast(); } /** diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index 80702b6eb4ad..56f29608f9b9 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -282,11 +282,13 @@ protected function parseSubSelect($query) $query->columns = [$query->columns[0]]; return [$query->toSql(), $query->getBindings()]; - } elseif (is_string($query)) { + } + + if (is_string($query)) { return [$query, []]; - } else { - throw new InvalidArgumentException; } + + throw new InvalidArgumentException; } /** @@ -587,7 +589,9 @@ protected function prepareValueAndOperator($value, $operator, $useDefault = fals { if ($useDefault) { return [$operator, '=']; - } elseif ($this->invalidOperatorAndValue($operator, $value)) { + } + + if ($this->invalidOperatorAndValue($operator, $value)) { throw new InvalidArgumentException('Illegal operator and value combination.'); } @@ -1769,9 +1773,13 @@ public function getCountForPagination($columns = ['*']) // just return the count of the entire results set since that will be correct. if (isset($this->groups)) { return count($results); - } elseif (! isset($results[0])) { + } + + if (! isset($results[0])) { return 0; - } elseif (is_object($results[0])) { + } + + if (is_object($results[0])) { return (int) $results[0]->aggregate; } diff --git a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php b/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php index 149f300a2c34..0d627665d7d9 100755 --- a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php @@ -134,7 +134,9 @@ protected function compileCreateEngine($sql, Connection $connection, Blueprint $ { if (isset($blueprint->engine)) { return $sql.' engine = '.$blueprint->engine; - } elseif (! is_null($engine = $connection->getConfig('engine'))) { + } + + if (! is_null($engine = $connection->getConfig('engine'))) { return $sql.' engine = '.$engine; } diff --git a/src/Illuminate/Filesystem/FilesystemAdapter.php b/src/Illuminate/Filesystem/FilesystemAdapter.php index 81653450eb30..c1f276b04f2a 100644 --- a/src/Illuminate/Filesystem/FilesystemAdapter.php +++ b/src/Illuminate/Filesystem/FilesystemAdapter.php @@ -379,15 +379,21 @@ public function url($path) if (method_exists($adapter, 'getUrl')) { return $adapter->getUrl($path); - } elseif ($adapter instanceof AwsS3Adapter) { + } + + if ($adapter instanceof AwsS3Adapter) { return $this->getAwsUrl($adapter, $path); - } elseif ($adapter instanceof RackspaceAdapter) { + } + + if ($adapter instanceof RackspaceAdapter) { return $this->getRackspaceUrl($adapter, $path); - } elseif ($adapter instanceof LocalAdapter) { + } + + if ($adapter instanceof LocalAdapter) { return $this->getLocalUrl($path); - } else { - throw new RuntimeException('This driver does not support retrieving URLs.'); } + + throw new RuntimeException('This driver does not support retrieving URLs.'); } /** @@ -470,13 +476,17 @@ public function temporaryUrl($path, $expiration, array $options = []) if (method_exists($adapter, 'getTemporaryUrl')) { return $adapter->getTemporaryUrl($path, $expiration, $options); - } elseif ($adapter instanceof AwsS3Adapter) { + } + + if ($adapter instanceof AwsS3Adapter) { return $this->getAwsTemporaryUrl($adapter, $path, $expiration, $options); - } elseif ($adapter instanceof RackspaceAdapter) { + } + + if ($adapter instanceof RackspaceAdapter) { return $this->getRackspaceTemporaryUrl($adapter, $path, $expiration, $options); - } else { - throw new RuntimeException('This driver does not support creating temporary URLs.'); } + + throw new RuntimeException('This driver does not support creating temporary URLs.'); } /** diff --git a/src/Illuminate/Filesystem/FilesystemManager.php b/src/Illuminate/Filesystem/FilesystemManager.php index 37147b3f48ce..b27a2ce36d57 100644 --- a/src/Illuminate/Filesystem/FilesystemManager.php +++ b/src/Illuminate/Filesystem/FilesystemManager.php @@ -122,9 +122,9 @@ protected function resolve($name) if (method_exists($this, $driverMethod)) { return $this->{$driverMethod}($config); - } else { - throw new InvalidArgumentException("Driver [{$config['driver']}] is not supported."); } + + throw new InvalidArgumentException("Driver [{$config['driver']}] is not supported."); } /** diff --git a/src/Illuminate/Foundation/Console/TestMakeCommand.php b/src/Illuminate/Foundation/Console/TestMakeCommand.php index ea08d7cf8ce4..ff14acc62444 100644 --- a/src/Illuminate/Foundation/Console/TestMakeCommand.php +++ b/src/Illuminate/Foundation/Console/TestMakeCommand.php @@ -65,9 +65,9 @@ protected function getDefaultNamespace($rootNamespace) { if ($this->option('unit')) { return $rootNamespace.'\Unit'; - } else { - return $rootNamespace.'\Feature'; } + + return $rootNamespace.'\Feature'; } /** diff --git a/src/Illuminate/Foundation/Console/VendorPublishCommand.php b/src/Illuminate/Foundation/Console/VendorPublishCommand.php index 686f26b70a0b..84c20988a804 100644 --- a/src/Illuminate/Foundation/Console/VendorPublishCommand.php +++ b/src/Illuminate/Foundation/Console/VendorPublishCommand.php @@ -186,7 +186,9 @@ protected function publishItem($from, $to) { if ($this->files->isFile($from)) { return $this->publishFile($from, $to); - } elseif ($this->files->isDirectory($from)) { + } + + if ($this->files->isDirectory($from)) { return $this->publishDirectory($from, $to); } diff --git a/src/Illuminate/Foundation/Exceptions/Handler.php b/src/Illuminate/Foundation/Exceptions/Handler.php index f381382583c5..e548ab9139c7 100644 --- a/src/Illuminate/Foundation/Exceptions/Handler.php +++ b/src/Illuminate/Foundation/Exceptions/Handler.php @@ -168,7 +168,9 @@ public function render($request, Exception $e) { if (method_exists($e, 'render') && $response = $e->render($request)) { return Router::toResponse($request, $response); - } elseif ($e instanceof Responsable) { + } + + if ($e instanceof Responsable) { return $e->toResponse($request); } @@ -176,9 +178,13 @@ public function render($request, Exception $e) if ($e instanceof HttpResponseException) { return $e->getResponse(); - } elseif ($e instanceof AuthenticationException) { + } + + if ($e instanceof AuthenticationException) { return $this->unauthenticated($request, $e); - } elseif ($e instanceof ValidationException) { + } + + if ($e instanceof ValidationException) { return $this->convertValidationExceptionToResponse($e, $request); } diff --git a/src/Illuminate/Foundation/Http/FormRequest.php b/src/Illuminate/Foundation/Http/FormRequest.php index 3f57a2a83376..6ba12bed45be 100644 --- a/src/Illuminate/Foundation/Http/FormRequest.php +++ b/src/Illuminate/Foundation/Http/FormRequest.php @@ -130,9 +130,13 @@ protected function getRedirectUrl() if ($this->redirect) { return $url->to($this->redirect); - } elseif ($this->redirectRoute) { + } + + if ($this->redirectRoute) { return $url->route($this->redirectRoute); - } elseif ($this->redirectAction) { + } + + if ($this->redirectAction) { return $url->action($this->redirectAction); } diff --git a/src/Illuminate/Foundation/helpers.php b/src/Illuminate/Foundation/helpers.php index cabf0407d2dd..a224a56c6f1d 100644 --- a/src/Illuminate/Foundation/helpers.php +++ b/src/Illuminate/Foundation/helpers.php @@ -481,7 +481,9 @@ function factory() if (isset($arguments[1]) && is_string($arguments[1])) { return $factory->of($arguments[0], $arguments[1])->times($arguments[2] ?? null); - } elseif (isset($arguments[1])) { + } + + if (isset($arguments[1])) { return $factory->of($arguments[0])->times($arguments[1]); } diff --git a/src/Illuminate/Http/Response.php b/src/Illuminate/Http/Response.php index d962dca1bf49..6374c49a46d6 100755 --- a/src/Illuminate/Http/Response.php +++ b/src/Illuminate/Http/Response.php @@ -72,7 +72,9 @@ protected function morphToJson($content) { if ($content instanceof Jsonable) { return $content->toJson(); - } elseif ($content instanceof Arrayable) { + } + + if ($content instanceof Arrayable) { return json_encode($content->toArray()); } diff --git a/src/Illuminate/Log/Writer.php b/src/Illuminate/Log/Writer.php index acf77b2dbd95..6cac39f46ced 100755 --- a/src/Illuminate/Log/Writer.php +++ b/src/Illuminate/Log/Writer.php @@ -306,9 +306,13 @@ protected function formatMessage($message) { if (is_array($message)) { return var_export($message, true); - } elseif ($message instanceof Jsonable) { + } + + if ($message instanceof Jsonable) { return $message->toJson(); - } elseif ($message instanceof Arrayable) { + } + + if ($message instanceof Arrayable) { return var_export($message->toArray(), true); } diff --git a/src/Illuminate/Mail/Mailable.php b/src/Illuminate/Mail/Mailable.php index 86ea7a7ebfa8..fb76d612018f 100644 --- a/src/Illuminate/Mail/Mailable.php +++ b/src/Illuminate/Mail/Mailable.php @@ -191,7 +191,9 @@ protected function buildView() if (isset($this->view, $this->textView)) { return [$this->view, $this->textView]; - } elseif (isset($this->textView)) { + } + + if (isset($this->textView)) { return ['text' => $this->textView]; } @@ -522,7 +524,9 @@ protected function normalizeRecipient($recipient) { if (is_array($recipient)) { return (object) $recipient; - } elseif (is_string($recipient)) { + } + + if (is_string($recipient)) { return (object) ['email' => $recipient]; } diff --git a/src/Illuminate/Pipeline/Pipeline.php b/src/Illuminate/Pipeline/Pipeline.php index e227a583bef8..8100786c3e0b 100644 --- a/src/Illuminate/Pipeline/Pipeline.php +++ b/src/Illuminate/Pipeline/Pipeline.php @@ -129,7 +129,9 @@ protected function carry() // otherwise we'll resolve the pipes out of the container and call it with // the appropriate method and arguments, returning the results back out. return $pipe($passable, $stack); - } elseif (! is_object($pipe)) { + } + + if (! is_object($pipe)) { list($name, $parameters) = $this->parsePipeString($pipe); // If the pipe is a string we will parse the string and resolve the class out diff --git a/src/Illuminate/Queue/Console/ListFailedCommand.php b/src/Illuminate/Queue/Console/ListFailedCommand.php index be46d960c159..5331f0b35949 100644 --- a/src/Illuminate/Queue/Console/ListFailedCommand.php +++ b/src/Illuminate/Queue/Console/ListFailedCommand.php @@ -83,7 +83,9 @@ private function extractJobName($payload) if ($payload && (! isset($payload['data']['command']))) { return $payload['job'] ?? null; - } elseif ($payload && isset($payload['data']['command'])) { + } + + if ($payload && isset($payload['data']['command'])) { return $this->matchJobName($payload); } } diff --git a/src/Illuminate/Routing/Console/ControllerMakeCommand.php b/src/Illuminate/Routing/Console/ControllerMakeCommand.php index 4ce15afd985a..909e33624a1c 100755 --- a/src/Illuminate/Routing/Console/ControllerMakeCommand.php +++ b/src/Illuminate/Routing/Console/ControllerMakeCommand.php @@ -39,9 +39,13 @@ protected function getStub() { if ($this->option('parent')) { return __DIR__.'/stubs/controller.nested.stub'; - } elseif ($this->option('model')) { + } + + if ($this->option('model')) { return __DIR__.'/stubs/controller.model.stub'; - } elseif ($this->option('resource')) { + } + + if ($this->option('resource')) { return __DIR__.'/stubs/controller.stub'; } diff --git a/src/Illuminate/Routing/Matching/SchemeValidator.php b/src/Illuminate/Routing/Matching/SchemeValidator.php index fd5d5af8fa6b..66082abd9a68 100644 --- a/src/Illuminate/Routing/Matching/SchemeValidator.php +++ b/src/Illuminate/Routing/Matching/SchemeValidator.php @@ -18,7 +18,9 @@ public function matches(Route $route, Request $request) { if ($route->httpOnly()) { return ! $request->secure(); - } elseif ($route->secure()) { + } + + if ($route->secure()) { return $request->secure(); } diff --git a/src/Illuminate/Routing/ResourceRegistrar.php b/src/Illuminate/Routing/ResourceRegistrar.php index 5209e9e9279a..2ffdeb64d290 100644 --- a/src/Illuminate/Routing/ResourceRegistrar.php +++ b/src/Illuminate/Routing/ResourceRegistrar.php @@ -148,7 +148,9 @@ protected function getResourceMethods($defaults, $options) { if (isset($options['only'])) { return array_intersect($defaults, (array) $options['only']); - } elseif (isset($options['except'])) { + } + + if (isset($options['except'])) { return array_diff($defaults, (array) $options['except']); } @@ -433,8 +435,8 @@ public static function verbs(array $verbs = []) { if (empty($verbs)) { return static::$verbs; - } else { - static::$verbs = array_merge(static::$verbs, $verbs); } + + static::$verbs = array_merge(static::$verbs, $verbs); } } diff --git a/src/Illuminate/Routing/RouteUrlGenerator.php b/src/Illuminate/Routing/RouteUrlGenerator.php index b5a4c1cbf1ec..48a15110d1ec 100644 --- a/src/Illuminate/Routing/RouteUrlGenerator.php +++ b/src/Illuminate/Routing/RouteUrlGenerator.php @@ -138,7 +138,9 @@ protected function getRouteScheme($route) { if ($route->httpOnly()) { return 'http://'; - } elseif ($route->httpsOnly()) { + } + + if ($route->httpsOnly()) { return 'https://'; } @@ -210,7 +212,9 @@ protected function replaceNamedParameters($path, &$parameters) return preg_replace_callback('/\{(.*?)\??\}/', function ($m) use (&$parameters) { if (isset($parameters[$m[1]])) { return Arr::pull($parameters, $m[1]); - } elseif (isset($this->defaultParameters[$m[1]])) { + } + + if (isset($this->defaultParameters[$m[1]])) { return $this->defaultParameters[$m[1]]; } diff --git a/src/Illuminate/Routing/UrlGenerator.php b/src/Illuminate/Routing/UrlGenerator.php index bf1839b3f5f6..20431c209676 100755 --- a/src/Illuminate/Routing/UrlGenerator.php +++ b/src/Illuminate/Routing/UrlGenerator.php @@ -140,7 +140,9 @@ public function previous($fallback = false) if ($url) { return $url; - } elseif ($fallback) { + } + + if ($fallback) { return $this->to($fallback); } @@ -351,9 +353,9 @@ protected function formatAction($action) { if ($this->rootNamespace && ! (strpos($action, '\\') === 0)) { return $this->rootNamespace.'\\'.$action; - } else { - return trim($action, '\\'); } + + return trim($action, '\\'); } /** diff --git a/src/Illuminate/Support/Collection.php b/src/Illuminate/Support/Collection.php index 38dd526f0365..944d348ada6c 100644 --- a/src/Illuminate/Support/Collection.php +++ b/src/Illuminate/Support/Collection.php @@ -428,7 +428,9 @@ public function when($value, callable $callback, callable $default = null) { if ($value) { return $callback($this, $value); - } elseif ($default) { + } + + if ($default) { return $default($this, $value); } @@ -1622,9 +1624,13 @@ public function jsonSerialize() return array_map(function ($value) { if ($value instanceof JsonSerializable) { return $value->jsonSerialize(); - } elseif ($value instanceof Jsonable) { + } + + if ($value instanceof Jsonable) { return json_decode($value->toJson(), true); - } elseif ($value instanceof Arrayable) { + } + + if ($value instanceof Arrayable) { return $value->toArray(); } @@ -1753,15 +1759,25 @@ protected function getArrayableItems($items) { if (is_array($items)) { return $items; - } elseif ($items instanceof self) { + } + + if ($items instanceof self) { return $items->all(); - } elseif ($items instanceof Arrayable) { + } + + if ($items instanceof Arrayable) { return $items->toArray(); - } elseif ($items instanceof Jsonable) { + } + + if ($items instanceof Jsonable) { return json_decode($items->toJson(), true); - } elseif ($items instanceof JsonSerializable) { + } + + if ($items instanceof JsonSerializable) { return $items->jsonSerialize(); - } elseif ($items instanceof Traversable) { + } + + if ($items instanceof Traversable) { return iterator_to_array($items); } diff --git a/src/Illuminate/Support/Manager.php b/src/Illuminate/Support/Manager.php index 592776c2c859..0a420c1a708e 100755 --- a/src/Illuminate/Support/Manager.php +++ b/src/Illuminate/Support/Manager.php @@ -81,13 +81,14 @@ protected function createDriver($driver) // drivers using their own customized driver creator Closure to create it. if (isset($this->customCreators[$driver])) { return $this->callCustomCreator($driver); - } else { - $method = 'create'.Str::studly($driver).'Driver'; + } + + $method = 'create'.Str::studly($driver).'Driver'; - if (method_exists($this, $method)) { - return $this->$method(); - } + if (method_exists($this, $method)) { + return $this->$method(); } + throw new InvalidArgumentException("Driver [$driver] not supported."); } diff --git a/src/Illuminate/Support/ServiceProvider.php b/src/Illuminate/Support/ServiceProvider.php index 8ea8038aeef8..c250ac5bab90 100755 --- a/src/Illuminate/Support/ServiceProvider.php +++ b/src/Illuminate/Support/ServiceProvider.php @@ -208,11 +208,17 @@ protected static function pathsForProviderOrGroup($provider, $group) { if ($provider && $group) { return static::pathsForProviderAndGroup($provider, $group); - } elseif ($group && array_key_exists($group, static::$publishGroups)) { + } + + if ($group && array_key_exists($group, static::$publishGroups)) { return static::$publishGroups[$group]; - } elseif ($provider && array_key_exists($provider, static::$publishes)) { + } + + if ($provider && array_key_exists($provider, static::$publishes)) { return static::$publishes[$provider]; - } elseif ($group || $provider) { + } + + if ($group || $provider) { return []; } } diff --git a/src/Illuminate/Translation/MessageSelector.php b/src/Illuminate/Translation/MessageSelector.php index 3ac3386b6f91..68fe93ce4b3e 100755 --- a/src/Illuminate/Translation/MessageSelector.php +++ b/src/Illuminate/Translation/MessageSelector.php @@ -73,9 +73,13 @@ private function extractFromString($part, $number) if ($to == '*' && $number >= $from) { return $value; - } elseif ($from == '*' && $number <= $to) { + } + + if ($from == '*' && $number <= $to) { return $value; - } elseif ($number >= $from && $number <= $to) { + } + + if ($number >= $from && $number <= $to) { return $value; } } diff --git a/src/Illuminate/Translation/Translator.php b/src/Illuminate/Translation/Translator.php index 8633b69a28b2..ffffe84f03a2 100755 --- a/src/Illuminate/Translation/Translator.php +++ b/src/Illuminate/Translation/Translator.php @@ -243,7 +243,9 @@ protected function getLine($namespace, $group, $locale, $item, array $replace) if (is_string($line)) { return $this->makeReplacements($line, $replace); - } elseif (is_array($line) && count($line) > 0) { + } + + if (is_array($line) && count($line) > 0) { return $line; } } diff --git a/src/Illuminate/Validation/Concerns/FormatsMessages.php b/src/Illuminate/Validation/Concerns/FormatsMessages.php index 5744830d217d..657a5e04674a 100644 --- a/src/Illuminate/Validation/Concerns/FormatsMessages.php +++ b/src/Illuminate/Validation/Concerns/FormatsMessages.php @@ -182,9 +182,13 @@ protected function getAttributeType($attribute) // list doesn't have it we'll just consider it a string by elimination. if ($this->hasRule($attribute, $this->numericRules)) { return 'numeric'; - } elseif ($this->hasRule($attribute, ['Array'])) { + } + + if ($this->hasRule($attribute, ['Array'])) { return 'array'; - } elseif ($this->getValue($attribute) instanceof UploadedFile) { + } + + if ($this->getValue($attribute) instanceof UploadedFile) { return 'file'; } @@ -210,7 +214,9 @@ public function makeReplacements($message, $attribute, $rule, $parameters) if (isset($this->replacers[Str::snake($rule)])) { return $this->callReplacer($message, $attribute, Str::snake($rule), $parameters, $this); - } elseif (method_exists($this, $replacer = "replace{$rule}")) { + } + + if (method_exists($this, $replacer = "replace{$rule}")) { return $this->$replacer($message, $attribute, $rule, $parameters); } @@ -359,7 +365,9 @@ protected function callReplacer($message, $attribute, $rule, $parameters, $valid if ($callback instanceof Closure) { return call_user_func_array($callback, func_get_args()); - } elseif (is_string($callback)) { + } + + if (is_string($callback)) { return $this->callClassBasedReplacer($callback, $message, $attribute, $rule, $parameters, $validator); } } diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index 453c81e6629d..657e810d00ef 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -1080,11 +1080,17 @@ public function validateRequired($attribute, $value) { if (is_null($value)) { return false; - } elseif (is_string($value) && trim($value) === '') { + } + + if (is_string($value) && trim($value) === '') { return false; - } elseif ((is_array($value) || $value instanceof Countable) && count($value) < 1) { + } + + if ((is_array($value) || $value instanceof Countable) && count($value) < 1) { return false; - } elseif ($value instanceof File) { + } + + if ($value instanceof File) { return (string) $value->getPath() !== ''; } @@ -1129,7 +1135,9 @@ protected function convertValuesToBoolean($values) return array_map(function ($value) { if ($value === 'true') { return true; - } elseif ($value === 'false') { + } + + if ($value === 'false') { return false; } @@ -1392,9 +1400,13 @@ protected function getSize($attribute, $value) // entire length of the string will be considered the attribute size. if (is_numeric($value) && $hasNumeric) { return $value; - } elseif (is_array($value)) { + } + + if (is_array($value)) { return count($value); - } elseif ($value instanceof File) { + } + + if ($value instanceof File) { return $value->getSize() / 1024; } diff --git a/src/Illuminate/Validation/ValidationRuleParser.php b/src/Illuminate/Validation/ValidationRuleParser.php index 43a28db989d8..7118fa51c2e5 100644 --- a/src/Illuminate/Validation/ValidationRuleParser.php +++ b/src/Illuminate/Validation/ValidationRuleParser.php @@ -85,7 +85,8 @@ protected function explodeExplicitRule($rule) { if (is_string($rule)) { return explode('|', $rule); - } elseif (is_object($rule)) { + } + if (is_object($rule)) { return [$this->prepareRule($rule)]; } diff --git a/src/Illuminate/Validation/Validator.php b/src/Illuminate/Validation/Validator.php index 2c85af8b1905..927a2facad9a 100755 --- a/src/Illuminate/Validation/Validator.php +++ b/src/Illuminate/Validation/Validator.php @@ -1101,7 +1101,9 @@ protected function callExtension($rule, $parameters) if (is_callable($callback)) { return call_user_func_array($callback, $parameters); - } elseif (is_string($callback)) { + } + + if (is_string($callback)) { return $this->callClassBasedExtension($callback, $parameters); } } diff --git a/src/Illuminate/View/Compilers/Concerns/CompilesTranslations.php b/src/Illuminate/View/Compilers/Concerns/CompilesTranslations.php index feb7e6510c6b..f155da31da2e 100644 --- a/src/Illuminate/View/Compilers/Concerns/CompilesTranslations.php +++ b/src/Illuminate/View/Compilers/Concerns/CompilesTranslations.php @@ -14,7 +14,9 @@ protected function compileLang($expression) { if (is_null($expression)) { return 'startTranslation(); ?>'; - } elseif ($expression[1] === '[') { + } + + if ($expression[1] === '[') { return "startTranslation{$expression}; ?>"; } diff --git a/src/Illuminate/View/Concerns/ManagesEvents.php b/src/Illuminate/View/Concerns/ManagesEvents.php index f3d7717c3ca2..2a88418c41fa 100644 --- a/src/Illuminate/View/Concerns/ManagesEvents.php +++ b/src/Illuminate/View/Concerns/ManagesEvents.php @@ -77,7 +77,9 @@ protected function addViewEvent($view, $callback, $prefix = 'composing: ') $this->addEventListener($prefix.$view, $callback); return $callback; - } elseif (is_string($callback)) { + } + + if (is_string($callback)) { return $this->addClassEvent($view, $callback, $prefix); } }