Skip to content

Commit bc19e6d

Browse files
authored
Merge pull request #9743 from samsonasik/refactor-apply-code-quality-51
refactor: apply code quality level 51 for Rector
2 parents cd92eab + 47a3cc5 commit bc19e6d

File tree

16 files changed

+32
-32
lines changed

16 files changed

+32
-32
lines changed

rector.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313

1414
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
1515
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
16-
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
17-
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
1816
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
1917
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
18+
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
2019
use Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector;
2120
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
2221
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
@@ -167,6 +166,9 @@
167166
CompactToVariablesRector::class,
168167

169168
RemoveDataProviderParamKeysRector::class,
169+
170+
// possibly isset() on purpose, on updated Config classes property accross versions
171+
IssetOnPropertyObjectToPropertyExistsRector::class,
170172
])
171173
// auto import fully qualified class names
172174
->withImportNames(removeUnusedImports: true)
@@ -179,9 +181,7 @@
179181
CountArrayToEmptyArrayComparisonRector::class,
180182
ChangeNestedForeachIfsToEarlyContinueRector::class,
181183
ChangeIfElseValueAssignToEarlyReturnRector::class,
182-
InlineIfToExplicitIfRector::class,
183184
PreparedValueToEarlyReturnRector::class,
184-
UnusedForeachValueToArrayKeysRector::class,
185185
RemoveErrorSuppressInTryCatchStmtsRector::class,
186186
FuncGetArgsToVariadicParamRector::class,
187187
MakeInheritedMethodVisibilitySameAsParentRector::class,
@@ -202,4 +202,4 @@
202202
// keep '\\' prefix string on string '\Foo\Bar'
203203
StringClassNameToClassConstantRector::SHOULD_KEEP_PRE_SLASH => true,
204204
])
205-
->withCodeQualityLevel(41);
205+
->withCodeQualityLevel(51);

system/Commands/Database/CreateDatabase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function run(array $params)
109109
$config->{$group}['database'] = $name;
110110

111111
if ($name !== ':memory:') {
112-
$dbName = ! str_contains($name, DIRECTORY_SEPARATOR) ? WRITEPATH . $name : $name;
112+
$dbName = str_contains($name, DIRECTORY_SEPARATOR) ? $name : WRITEPATH . $name;
113113

114114
if (is_file($dbName)) {
115115
CLI::error("Database \"{$dbName}\" already exists.", 'light_gray', 'red');

system/Database/BaseBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ protected function _like($field, string $match = '', string $type = 'AND ', stri
11521152
return $this;
11531153
}
11541154

1155-
$keyValue = ! is_array($field) ? [$field => $match] : $field;
1155+
$keyValue = is_array($field) ? $field : [$field => $match];
11561156

11571157
foreach ($keyValue as $k => $v) {
11581158
if ($insensitiveSearch) {
@@ -3065,7 +3065,7 @@ protected function compileSelect($selectOverride = false): string
30653065
if ($selectOverride !== false) {
30663066
$sql = $selectOverride;
30673067
} else {
3068-
$sql = (! $this->QBDistinct) ? 'SELECT ' : 'SELECT DISTINCT ';
3068+
$sql = $this->QBDistinct ? 'SELECT DISTINCT ' : 'SELECT ';
30693069

30703070
if (empty($this->QBSelect)) {
30713071
$sql .= '*';

system/Database/BaseUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public function getXMLFromResult(ResultInterface $query, array $params = []): st
250250
$xml .= $tab . '<' . $element . '>' . $newline;
251251

252252
foreach ($row as $key => $val) {
253-
$val = (! empty($val)) ? xml_convert((string) $val) : '';
253+
$val = empty($val) ? '' : xml_convert((string) $val);
254254

255255
$xml .= $tab . $tab . '<' . $key . '>' . $val . '</' . $key . '>' . $newline;
256256
}

system/Database/Database.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ protected function parseDSN(array $params): array
136136
*/
137137
protected function initDriver(string $driver, string $class, $argument): object
138138
{
139-
$classname = (! str_contains($driver, '\\'))
140-
? "CodeIgniter\\Database\\{$driver}\\{$class}"
141-
: $driver . '\\' . $class;
139+
$classname = str_contains($driver, '\\')
140+
? $driver . '\\' . $class
141+
: "CodeIgniter\\Database\\{$driver}\\{$class}";
142142

143143
return new $classname($argument);
144144
}

system/Database/MigrationRunner.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ public function getHistory(string $group = 'default'): array
659659

660660
$query = $builder->orderBy('id', 'ASC')->get();
661661

662-
return ! empty($query) ? $query->getResultObject() : [];
662+
return empty($query) ? [] : $query->getResultObject();
663663
}
664664

665665
/**
@@ -676,7 +676,7 @@ public function getBatchHistory(int $batch, $order = 'asc'): array
676676
->orderBy('id', $order)
677677
->get();
678678

679-
return ! empty($query) ? $query->getResultObject() : [];
679+
return empty($query) ? [] : $query->getResultObject();
680680
}
681681

682682
/**

system/Database/SQLSRV/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ protected function compileSelect($selectOverride = false): string
584584
if ($selectOverride !== false) {
585585
$sql = $selectOverride;
586586
} else {
587-
$sql = (! $this->QBDistinct) ? 'SELECT ' : 'SELECT DISTINCT ';
587+
$sql = $this->QBDistinct ? 'SELECT DISTINCT ' : 'SELECT ';
588588

589589
// SQL Server can't work with select * if group by is specified
590590
if (empty($this->QBSelect) && $this->QBGroupBy !== [] && is_array($this->QBGroupBy)) {

system/Debug/Timer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Timer
4646
public function start(string $name, ?float $time = null)
4747
{
4848
$this->timers[strtolower($name)] = [
49-
'start' => ! empty($time) ? $time : microtime(true),
49+
'start' => empty($time) ? microtime(true) : $time,
5050
'end' => null,
5151
];
5252

system/Email/Email.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ public function setNewline($newline = "\n")
839839
*/
840840
public function setCRLF($CRLF = "\n")
841841
{
842-
$this->CRLF = ! in_array($CRLF, ["\n", "\r\n", "\r"], true) ? "\n" : $CRLF;
842+
$this->CRLF = in_array($CRLF, ["\n", "\r\n", "\r"], true) ? $CRLF : "\n";
843843

844844
return $this;
845845
}
@@ -2222,7 +2222,7 @@ protected function mimeTypes($ext = '')
22222222
{
22232223
$mime = Mimes::guessTypeFromExtension(strtolower($ext));
22242224

2225-
return ! empty($mime) ? $mime : 'application/x-unknown-content-type';
2225+
return empty($mime) ? 'application/x-unknown-content-type' : $mime;
22262226
}
22272227

22282228
public function __destruct()

system/HTTP/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public function getStatusCode(): int
221221
public function getReasonPhrase()
222222
{
223223
if ($this->reason === '') {
224-
return ! empty($this->statusCode) ? static::$statusCodes[$this->statusCode] : '';
224+
return empty($this->statusCode) ? '' : static::$statusCodes[$this->statusCode];
225225
}
226226

227227
return $this->reason;

0 commit comments

Comments
 (0)