Skip to content

Commit a8f17c5

Browse files
browner12taylorotwell
authored andcommitted
optimize method calls (#24783)
replace `strpos(strtolower(` with `stripos(`.
1 parent 4d81abb commit a8f17c5

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

src/Illuminate/Database/Grammar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function wrap($value, $prefixAlias = false)
5858
// If the value being wrapped has a column alias we will need to separate out
5959
// the pieces so we can wrap each of the segments of the expression on its
6060
// own, and then join these both back together using the "as" connector.
61-
if (strpos(strtolower($value), ' as ') !== false) {
61+
if (stripos($value, ' as ') !== false) {
6262
return $this->wrapAliasedValue($value, $prefixAlias);
6363
}
6464

src/Illuminate/Database/Query/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,7 @@ protected function runPaginationCountQuery($columns = ['*'])
20572057
protected function withoutSelectAliases(array $columns)
20582058
{
20592059
return array_map(function ($column) {
2060-
return is_string($column) && ($aliasPosition = strpos(strtolower($column), ' as ')) !== false
2060+
return is_string($column) && ($aliasPosition = stripos($column, ' as ')) !== false
20612061
? substr($column, 0, $aliasPosition) : $column;
20622062
}, $columns);
20632063
}

src/Illuminate/Database/Query/Grammars/Grammar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ public function wrap($value, $prefixAlias = false)
905905
// If the value being wrapped has a column alias we will need to separate out
906906
// the pieces so we can wrap each of the segments of the expression on its
907907
// own, and then join these both back together using the "as" connector.
908-
if (strpos(strtolower($value), ' as ') !== false) {
908+
if (stripos($value, ' as ') !== false) {
909909
return $this->wrapAliasedValue($value, $prefixAlias);
910910
}
911911

src/Illuminate/Database/Query/Grammars/MySqlGrammar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ protected function compileDeleteWithJoins($query, $table, $where)
276276
{
277277
$joins = ' '.$this->compileJoins($query, $query->joins);
278278

279-
$alias = strpos(strtolower($table), ' as ') !== false
279+
$alias = stripos($table, ' as ') !== false
280280
? explode(' as ', $table)[1] : $table;
281281

282282
return trim("delete {$alias} from {$table}{$joins} {$where}");

src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ protected function compileDeleteWithJoins(Builder $query, $table, $where)
298298
{
299299
$joins = ' '.$this->compileJoins($query, $query->joins);
300300

301-
$alias = strpos(strtolower($table), ' as ') !== false
301+
$alias = stripos($table, ' as ') !== false
302302
? explode(' as ', $table)[1] : $table;
303303

304304
return trim("delete {$alias} from {$table}{$joins} {$where}");
@@ -364,7 +364,7 @@ protected function parseUpdateTable($table)
364364
{
365365
$table = $alias = $this->wrapTable($table);
366366

367-
if (strpos(strtolower($table), '] as [') !== false) {
367+
if (stripos($table, '] as [') !== false) {
368368
$alias = '['.explode('] as [', $table)[1];
369369
}
370370

0 commit comments

Comments
 (0)