Skip to content
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
10 changes: 5 additions & 5 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@

use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
use Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector;
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
Expand Down Expand Up @@ -167,6 +166,9 @@
CompactToVariablesRector::class,

RemoveDataProviderParamKeysRector::class,

// possibly isset() on purpose, on updated Config classes property accross versions
IssetOnPropertyObjectToPropertyExistsRector::class,
])
// auto import fully qualified class names
->withImportNames(removeUnusedImports: true)
Expand All @@ -179,9 +181,7 @@
CountArrayToEmptyArrayComparisonRector::class,
ChangeNestedForeachIfsToEarlyContinueRector::class,
ChangeIfElseValueAssignToEarlyReturnRector::class,
InlineIfToExplicitIfRector::class,
PreparedValueToEarlyReturnRector::class,
UnusedForeachValueToArrayKeysRector::class,
RemoveErrorSuppressInTryCatchStmtsRector::class,
FuncGetArgsToVariadicParamRector::class,
MakeInheritedMethodVisibilitySameAsParentRector::class,
Expand All @@ -202,4 +202,4 @@
// keep '\\' prefix string on string '\Foo\Bar'
StringClassNameToClassConstantRector::SHOULD_KEEP_PRE_SLASH => true,
])
->withCodeQualityLevel(41);
->withCodeQualityLevel(51);
2 changes: 1 addition & 1 deletion system/Commands/Database/CreateDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function run(array $params)
$config->{$group}['database'] = $name;

if ($name !== ':memory:') {
$dbName = ! str_contains($name, DIRECTORY_SEPARATOR) ? WRITEPATH . $name : $name;
$dbName = str_contains($name, DIRECTORY_SEPARATOR) ? $name : WRITEPATH . $name;

if (is_file($dbName)) {
CLI::error("Database \"{$dbName}\" already exists.", 'light_gray', 'red');
Expand Down
4 changes: 2 additions & 2 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ protected function _like($field, string $match = '', string $type = 'AND ', stri
return $this;
}

$keyValue = ! is_array($field) ? [$field => $match] : $field;
$keyValue = is_array($field) ? $field : [$field => $match];

foreach ($keyValue as $k => $v) {
if ($insensitiveSearch) {
Expand Down Expand Up @@ -3065,7 +3065,7 @@ protected function compileSelect($selectOverride = false): string
if ($selectOverride !== false) {
$sql = $selectOverride;
} else {
$sql = (! $this->QBDistinct) ? 'SELECT ' : 'SELECT DISTINCT ';
$sql = $this->QBDistinct ? 'SELECT DISTINCT ' : 'SELECT ';

if (empty($this->QBSelect)) {
$sql .= '*';
Expand Down
2 changes: 1 addition & 1 deletion system/Database/BaseUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function getXMLFromResult(ResultInterface $query, array $params = []): st
$xml .= $tab . '<' . $element . '>' . $newline;

foreach ($row as $key => $val) {
$val = (! empty($val)) ? xml_convert((string) $val) : '';
$val = empty($val) ? '' : xml_convert((string) $val);

$xml .= $tab . $tab . '<' . $key . '>' . $val . '</' . $key . '>' . $newline;
}
Expand Down
6 changes: 3 additions & 3 deletions system/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ protected function parseDSN(array $params): array
*/
protected function initDriver(string $driver, string $class, $argument): object
{
$classname = (! str_contains($driver, '\\'))
? "CodeIgniter\\Database\\{$driver}\\{$class}"
: $driver . '\\' . $class;
$classname = str_contains($driver, '\\')
? $driver . '\\' . $class
: "CodeIgniter\\Database\\{$driver}\\{$class}";

return new $classname($argument);
}
Expand Down
4 changes: 2 additions & 2 deletions system/Database/MigrationRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ public function getHistory(string $group = 'default'): array

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

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

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

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

/**
Expand Down
2 changes: 1 addition & 1 deletion system/Database/SQLSRV/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ protected function compileSelect($selectOverride = false): string
if ($selectOverride !== false) {
$sql = $selectOverride;
} else {
$sql = (! $this->QBDistinct) ? 'SELECT ' : 'SELECT DISTINCT ';
$sql = $this->QBDistinct ? 'SELECT DISTINCT ' : 'SELECT ';

// SQL Server can't work with select * if group by is specified
if (empty($this->QBSelect) && $this->QBGroupBy !== [] && is_array($this->QBGroupBy)) {
Expand Down
2 changes: 1 addition & 1 deletion system/Debug/Timer.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Timer
public function start(string $name, ?float $time = null)
{
$this->timers[strtolower($name)] = [
'start' => ! empty($time) ? $time : microtime(true),
'start' => empty($time) ? microtime(true) : $time,
'end' => null,
];

Expand Down
4 changes: 2 additions & 2 deletions system/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ public function setNewline($newline = "\n")
*/
public function setCRLF($CRLF = "\n")
{
$this->CRLF = ! in_array($CRLF, ["\n", "\r\n", "\r"], true) ? "\n" : $CRLF;
$this->CRLF = in_array($CRLF, ["\n", "\r\n", "\r"], true) ? $CRLF : "\n";

return $this;
}
Expand Down Expand Up @@ -2222,7 +2222,7 @@ protected function mimeTypes($ext = '')
{
$mime = Mimes::guessTypeFromExtension(strtolower($ext));

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

public function __destruct()
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function getStatusCode(): int
public function getReasonPhrase()
{
if ($this->reason === '') {
return ! empty($this->statusCode) ? static::$statusCodes[$this->statusCode] : '';
return empty($this->statusCode) ? '' : static::$statusCodes[$this->statusCode];
}

return $this->reason;
Expand Down
6 changes: 3 additions & 3 deletions system/HTTP/URI.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ public static function createURIString(
}

if ((string) $path !== '') {
$uri .= ! str_ends_with($uri, '/')
? '/' . ltrim($path, '/')
: ltrim($path, '/');
$uri .= str_ends_with($uri, '/')
? ltrim($path, '/')
: '/' . ltrim($path, '/');
}

if ((string) $query !== '') {
Expand Down
2 changes: 1 addition & 1 deletion system/Helpers/form_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ function form_checkbox($data = '', string $value = '', bool $checked = false, $e
{
$defaults = [
'type' => 'checkbox',
'name' => (! is_array($data) ? $data : ''),
'name' => is_array($data) ? '' : $data,
'value' => $value,
];

Expand Down
12 changes: 6 additions & 6 deletions system/Images/Handlers/ImageMagickHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function __construct($config = null)
*/
public function _resize(bool $maintainRatio = false)
{
$source = ! empty($this->resource) ? $this->resource : $this->image()->getPathname();
$source = empty($this->resource) ? $this->image()->getPathname() : $this->resource;
$destination = $this->getResourcePath();

$escape = '\\';
Expand All @@ -99,7 +99,7 @@ public function _resize(bool $maintainRatio = false)
*/
public function _crop()
{
$source = ! empty($this->resource) ? $this->resource : $this->image()->getPathname();
$source = empty($this->resource) ? $this->image()->getPathname() : $this->resource;
$destination = $this->getResourcePath();

$extent = ' ';
Expand All @@ -126,7 +126,7 @@ protected function _rotate(int $angle)
{
$angle = '-rotate ' . $angle;

$source = ! empty($this->resource) ? $this->resource : $this->image()->getPathname();
$source = empty($this->resource) ? $this->image()->getPathname() : $this->resource;
$destination = $this->getResourcePath();

$action = ' ' . $angle . ' ' . escapeshellarg($source) . ' ' . escapeshellarg($destination);
Expand All @@ -147,7 +147,7 @@ protected function _flatten(int $red = 255, int $green = 255, int $blue = 255)
{
$flatten = "-background 'rgb({$red},{$green},{$blue})' -flatten";

$source = ! empty($this->resource) ? $this->resource : $this->image()->getPathname();
$source = empty($this->resource) ? $this->image()->getPathname() : $this->resource;
$destination = $this->getResourcePath();

$action = ' ' . $flatten . ' ' . escapeshellarg($source) . ' ' . escapeshellarg($destination);
Expand All @@ -168,7 +168,7 @@ protected function _flip(string $direction)
{
$angle = $direction === 'horizontal' ? '-flop' : '-flip';

$source = ! empty($this->resource) ? $this->resource : $this->image()->getPathname();
$source = empty($this->resource) ? $this->image()->getPathname() : $this->resource;
$destination = $this->getResourcePath();

$action = ' ' . $angle . ' ' . escapeshellarg($source) . ' ' . escapeshellarg($destination);
Expand Down Expand Up @@ -411,7 +411,7 @@ protected function _text(string $text, array $options = [])
// Text
$cmd .= ' -annotate 0 ' . escapeshellarg($text);

$source = ! empty($this->resource) ? $this->resource : $this->image()->getPathname();
$source = empty($this->resource) ? $this->image()->getPathname() : $this->resource;
$destination = $this->getResourcePath();

$cmd = ' ' . escapeshellarg($source) . ' ' . $cmd . ' ' . escapeshellarg($destination);
Expand Down
2 changes: 1 addition & 1 deletion system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ protected function doInsert(array $row)

// If insertion succeeded then save the insert ID
if ($result) {
$this->insertID = ! $this->useAutoIncrement ? $row[$this->primaryKey] : $this->db->insertID();
$this->insertID = $this->useAutoIncrement ? $this->db->insertID() : $row[$this->primaryKey];
}

return $result;
Expand Down
2 changes: 1 addition & 1 deletion system/Test/Fabricator.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public static function resetCounts()
*/
public static function getCount(string $table): int
{
return ! isset(self::$tableCounts[$table]) ? 0 : self::$tableCounts[$table];
return self::$tableCounts[$table] ?? 0;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion system/Validation/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ protected function getErrorMessage(

$args = [
'field' => ($label === null || $label === '') ? $field : lang($label),
'param' => (! isset($this->rules[$param]['label'])) ? $param : lang($this->rules[$param]['label']),
'param' => isset($this->rules[$param]['label']) ? lang($this->rules[$param]['label']) : $param,
'value' => $value ?? '',
];

Expand Down
Loading