-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
refactor: replace empty() Part 1 #8345
Conversation
102b20c
to
c666bf7
Compare
👋 Hi, @kenjis! |
52a6dbc
to
bd0ef26
Compare
0364948
to
687b611
Compare
👋 Hi, @kenjis! |
1e92f25
to
269986e
Compare
@@ -257,13 +257,13 @@ protected function doFirst() | |||
|
|||
if ($this->tempUseSoftDeletes) { | |||
$builder->where($this->table . '.' . $this->deletedField, null); | |||
} elseif ($this->useSoftDeletes && empty($builder->QBGroupBy) && $this->primaryKey) { | |||
} elseif ($this->useSoftDeletes && ($builder->QBGroupBy === []) && $this->primaryKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is ()
around $builder->QBGroupBy === []
is forced by our tooling? Seems unnecessary.
$builder->groupBy($this->table . '.' . $this->primaryKey); | ||
} | ||
|
||
// Some databases, like PostgreSQL, need order | ||
// information to consistently return correct results. | ||
if ($builder->QBGroupBy && empty($builder->QBOrderBy) && $this->primaryKey) { | ||
if ($builder->QBGroupBy && ($builder->QBOrderBy === []) && $this->primaryKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
@@ -186,7 +186,7 @@ public function call(string $method, string $path, ?array $params = null) | |||
->run($routes, true); | |||
|
|||
$output = \ob_get_contents(); | |||
if (empty($response->getBody()) && ! ($output === '' || $output === false)) { | |||
if (($response->getBody() === null) && ! ($output === '' || $output === false)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably unnecessary ()
around $response->getBody() === null
.
@@ -918,7 +918,7 @@ protected function getErrorMessage( | |||
$message = str_replace('{field}', ($label === null || $label === '') ? $field : lang($label), $message); | |||
$message = str_replace( | |||
'{param}', | |||
empty($this->rules[$param]['label']) ? $param : lang($this->rules[$param]['label']), | |||
(! isset($this->rules[$param]['label'])) ? $param : lang($this->rules[$param]['label']), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need ()
around ! isset($this->rules[$param]['label'])
?
@@ -103,7 +103,7 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n | |||
} | |||
|
|||
$fileExt = pathinfo($view, PATHINFO_EXTENSION); | |||
$view = empty($fileExt) ? $view . '.php' : $view; // allow Views as .html, .tpl, etc (from CI3) | |||
$view = ($fileExt === '') ? $view . '.php' : $view; // allow Views as .html, .tpl, etc (from CI3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here... is it supposed to increase readability? For me, it's the opposite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, yes.
@@ -589,7 +589,7 @@ protected function applyFilters(string $replace, array $filters): string | |||
preg_match('/\([\w<>=\/\\\,:.\-\s\+]+\)/u', $filter, $param); | |||
|
|||
// Remove the () and spaces to we have just the parameter left | |||
$param = ! empty($param) ? trim($param[0], '() ') : null; | |||
$param = ($param !== []) ? trim($param[0], '() ') : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With only one check, I see no added value in using ()
.
@@ -178,7 +178,7 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n | |||
|
|||
$fileExt = pathinfo($view, PATHINFO_EXTENSION); | |||
// allow Views as .html, .tpl, etc (from CI3) | |||
$this->renderVars['view'] = empty($fileExt) ? $view . '.php' : $view; | |||
$this->renderVars['view'] = ($fileExt === '') ? $view . '.php' : $view; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
@@ -207,12 +207,12 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n | |||
$this->renderVars['file'] = $this->loader->locateFile( | |||
$this->renderVars['view'], | |||
'Views', | |||
empty($fileExt) ? 'php' : $fileExt | |||
($fileExt === '') ? 'php' : $fileExt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments, but it may be only my preference.
There are some unnecessary |
Needs #8344Description
Checklist: