Merge pull request #4313 from samsonasik/re-run-rector-inline-if

[Rector] Re-run rector with improved InlineIfToExplicitIfRector
This commit is contained in:
Abdul Malik Ikhsan 2021-02-21 08:19:36 +07:00 committed by GitHub
commit 0bd6efae04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 171 additions and 49 deletions

View File

@ -372,7 +372,10 @@ class BaseBuilder
}
// If the escape value was not set, we will base it on the global setting
is_bool($escape) || $escape = $this->db->protectIdentifiers;
if (! is_bool($escape))
{
$escape = $this->db->protectIdentifiers;
}
foreach ($select as $val)
{
@ -656,7 +659,10 @@ class BaseBuilder
// in the protectIdentifiers to know whether to add a table prefix
$this->trackAliases($table);
is_bool($escape) || $escape = $this->db->protectIdentifiers;
if (! is_bool($escape))
{
$escape = $this->db->protectIdentifiers;
}
if (! $this->hasOperator($cond))
{
@ -776,7 +782,10 @@ class BaseBuilder
}
// If the escape value was not set will base it on the global setting
is_bool($escape) || $escape = $this->db->protectIdentifiers;
if (! is_bool($escape))
{
$escape = $this->db->protectIdentifiers;
}
foreach ($key as $k => $v)
{
@ -1036,7 +1045,10 @@ class BaseBuilder
// @codeCoverageIgnoreEnd
}
is_bool($escape) || $escape = $this->db->protectIdentifiers;
if (! is_bool($escape))
{
$escape = $this->db->protectIdentifiers;
}
$ok = $key;
@ -1546,7 +1558,10 @@ class BaseBuilder
*/
public function groupBy($by, bool $escape = null)
{
is_bool($escape) || $escape = $this->db->protectIdentifiers;
if (! is_bool($escape))
{
$escape = $this->db->protectIdentifiers;
}
if (is_string($by))
{
@ -1638,7 +1653,10 @@ class BaseBuilder
$direction = in_array($direction, ['ASC', 'DESC'], true) ? ' ' . $direction : '';
}
is_bool($escape) || $escape = $this->db->protectIdentifiers;
if (! is_bool($escape))
{
$escape = $this->db->protectIdentifiers;
}
if ($escape === false)
{
@ -2686,7 +2704,10 @@ class BaseBuilder
return null;
}
is_bool($escape) || $escape = $this->db->protectIdentifiers;
if (! is_bool($escape))
{
$escape = $this->db->protectIdentifiers;
}
foreach ($key as $v)
{

View File

@ -288,7 +288,10 @@ abstract class BaseResult implements ResultInterface
if (! is_numeric($n))
{
// We cache the row data for subsequent uses
is_array($this->rowData) || $this->rowData = $this->getRowArray();
if (! is_array($this->rowData))
{
$this->rowData = $this->getRowArray();
}
// array_key_exists() instead of isset() to allow for NULL values
if (empty($this->rowData) || ! array_key_exists($n, $this->rowData))

View File

@ -774,7 +774,10 @@ class Forge
public function addColumn(string $table, $field): bool
{
// Work-around for literal column definitions
is_array($field) || $field = [$field]; // @phpstan-ignore-line
if (! is_array($field))
{
$field = [$field];
}
foreach (array_keys($field) as $k)
{
@ -845,7 +848,10 @@ class Forge
public function modifyColumn(string $table, $field): bool
{
// Work-around for literal column definitions
is_array($field) || $field = [$field]; // @phpstan-ignore-line
if (! is_array($field))
{
$field = [$field];
}
foreach (array_keys($field) as $k)
{

View File

@ -121,11 +121,26 @@ class Connection extends BaseConnection
{
$ssl = [];
empty($this->encrypt['ssl_key']) || $ssl['key'] = $this->encrypt['ssl_key'];
empty($this->encrypt['ssl_cert']) || $ssl['cert'] = $this->encrypt['ssl_cert'];
empty($this->encrypt['ssl_ca']) || $ssl['ca'] = $this->encrypt['ssl_ca'];
empty($this->encrypt['ssl_capath']) || $ssl['capath'] = $this->encrypt['ssl_capath'];
empty($this->encrypt['ssl_cipher']) || $ssl['cipher'] = $this->encrypt['ssl_cipher'];
if (! empty($this->encrypt['ssl_key']))
{
$ssl['key'] = $this->encrypt['ssl_key'];
}
if (! empty($this->encrypt['ssl_cert']))
{
$ssl['cert'] = $this->encrypt['ssl_cert'];
}
if (! empty($this->encrypt['ssl_ca']))
{
$ssl['ca'] = $this->encrypt['ssl_ca'];
}
if (! empty($this->encrypt['ssl_capath']))
{
$ssl['capath'] = $this->encrypt['ssl_capath'];
}
if (! empty($this->encrypt['ssl_cipher']))
{
$ssl['cipher'] = $this->encrypt['ssl_cipher'];
}
if (! empty($ssl))
{

View File

@ -235,8 +235,10 @@ class Forge extends BaseForge
continue;
}
// @phpstan-ignore-next-line
is_array($this->keys[$i]) || $this->keys[$i] = [$this->keys[$i]];
if (! is_array($this->keys[$i]))
{
$this->keys[$i] = [$this->keys[$i]];
}
$unique = in_array($i, $this->uniqueKeys, true) ? 'UNIQUE ' : '';

View File

@ -507,7 +507,10 @@ class Connection extends BaseConnection
*/
protected function buildDSN()
{
$this->DSN === '' || $this->DSN = ''; // @phpstan-ignore-line
if ($this->DSN !== '')
{
$this->DSN = '';
}
// If UNIX sockets are used, we shouldn't set a port
if (strpos($this->hostname, '/') !== false)
@ -515,7 +518,10 @@ class Connection extends BaseConnection
$this->port = '';
}
$this->hostname === '' || $this->DSN = "host={$this->hostname} ";
if ($this->hostname !== '')
{
$this->DSN = "host={$this->hostname} ";
}
if (! empty($this->port) && ctype_digit($this->port))
{
@ -528,11 +534,16 @@ class Connection extends BaseConnection
// An empty password is valid!
// password must be set to null to ignore it.
$this->password === null || $this->DSN .= "password='{$this->password}' ";
if ($this->password !== null)
{
$this->DSN .= "password='{$this->password}' ";
}
}
$this->database === '' || $this->DSN .= "dbname={$this->database} ";
if ($this->database !== '')
{
$this->DSN .= "dbname={$this->database} ";
}
// We don't have these options as elements in our standard configuration
// array, but they might be set by parse_url() if the configuration was

View File

@ -130,7 +130,10 @@ class Builder extends BaseBuilder
// in the protectIdentifiers to know whether to add a table prefix
$this->trackAliases($table);
is_bool($escape) || $escape = $this->db->protectIdentifiers;
if (! is_bool($escape))
{
$escape = $this->db->protectIdentifiers;
}
if (! $this->hasOperator($cond))
{
@ -676,7 +679,10 @@ class Builder extends BaseBuilder
}
// If the escape value was not set will base it on the global setting
is_bool($escape) || $escape = $this->db->protectIdentifiers;
if (! is_bool($escape))
{
$escape = $this->db->protectIdentifiers;
}
foreach ($key as $k => $v)
{

View File

@ -388,7 +388,10 @@ class Email
public function __construct($config = null)
{
$this->initialize($config);
isset(static::$func_overload) || static::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
if (! isset(static::$func_overload))
{
static::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
}
}
/**
@ -506,7 +509,10 @@ class Email
}
$this->setHeader('From', $name . ' <' . $from . '>');
isset($returnPath) || $returnPath = $from;
if (! isset($returnPath))
{
$returnPath = $from;
}
$this->setHeader('Return-Path', '<' . $returnPath . '>');
$this->tmpArchive['returnPath'] = $returnPath;
@ -912,7 +918,10 @@ class Email
{
$this->protocol = strtolower($this->protocol);
in_array($this->protocol, $this->protocols, true) || $this->protocol = 'mail'; // @phpstan-ignore-line
if (! in_array($this->protocol, $this->protocols, true))
{
$this->protocol = 'mail';
}
return $this->protocol;
}
@ -924,7 +933,10 @@ class Email
*/
protected function getEncoding()
{
in_array($this->encoding, $this->bitDepths, true) || $this->encoding = '8bit'; // @phpstan-ignore-line
if (! in_array($this->encoding, $this->bitDepths, true))
{
$this->encoding = '8bit';
}
foreach ($this->baseCharsets as $charset)
{
@ -1432,7 +1444,10 @@ class Email
// $name won't be set if no attachments were appended,
// and therefore a boundary wouldn't be necessary
empty($name) || $body .= '--' . $boundary . '--';
if (! empty($name))
{
$body .= '--' . $boundary . '--';
}
}
/**
@ -1658,11 +1673,14 @@ class Email
}
// We might already have this set for UTF-8
isset($chars) || $chars = static::strlen($str);
if (! isset($chars))
{
$chars = static::strlen($str);
}
$output = '=?' . $this->charset . '?Q?';
for ($i = 0, $length = static::strlen($output); $i < $chars; $i ++) // @phpstan-ignore-line
for ($i = 0, $length = static::strlen($output); $i < $chars; $i ++)
{
$chr = ($this->charset === 'UTF-8' && extension_loaded('iconv')) ? '=' . implode('=', str_split(strtoupper(bin2hex(iconv_substr($str, $i, 1, $this->charset))), 2)) : '=' . strtoupper(bin2hex($str[$i]));
@ -2365,14 +2383,23 @@ class Email
// Determine which parts of our raw data needs to be printed
$rawData = '';
is_array($include) || $include = [$include]; // @phpstan-ignore-line
if (! is_array($include))
{
$include = [$include];
}
if (in_array('headers', $include, true))
{
$rawData = htmlspecialchars($this->headerStr) . "\n";
}
in_array('subject', $include, true) && $rawData .= htmlspecialchars($this->subject) . "\n";
in_array('body', $include, true) && $rawData .= htmlspecialchars($this->finalBody);
if (in_array('subject', $include, true))
{
$rawData .= htmlspecialchars($this->subject) . "\n";
}
if (in_array('body', $include, true))
{
$rawData .= htmlspecialchars($this->finalBody);
}
return $msg . ($rawData === '' ? '' : '<pre>' . $rawData . '</pre>');
}

View File

@ -48,7 +48,10 @@ if (! function_exists('directory_map'))
continue;
}
is_dir($sourceDir . $file) && $file .= DIRECTORY_SEPARATOR;
if (is_dir($sourceDir . $file))
{
$file .= DIRECTORY_SEPARATOR;
}
if (($directoryDepth < 1 || $newDepth > 0) && is_dir($sourceDir . $file))
{

View File

@ -217,8 +217,11 @@ if (! function_exists('form_password'))
*/
function form_password($data = '', string $value = '', $extra = ''): string
{
is_array($data) || $data = ['name' => $data]; // @phpstan-ignore-line
$data['type'] = 'password';
if (! is_array($data))
{
$data = ['name' => $data];
}
$data['type'] = 'password';
return form_input($data, $value, $extra);
}
@ -246,7 +249,10 @@ if (! function_exists('form_upload'))
'name' => '',
];
is_array($data) || $data = ['name' => $data]; // @phpstan-ignore-line
if (! is_array($data))
{
$data = ['name' => $data];
}
$data['type'] = 'file';
@ -363,9 +369,14 @@ if (! function_exists('form_dropdown'))
$defaults = ['name' => $data];
}
is_array($selected) || $selected = [$selected]; // @phpstan-ignore-line
is_array($options) || $options = [$options]; // @phpstan-ignore-line
if (! is_array($selected))
{
$selected = [$selected];
}
if (! is_array($options))
{
$options = [$options];
}
// If no selected state was submitted we will attempt to set it automatically
if (empty($selected))
@ -483,8 +494,11 @@ if (! function_exists('form_radio'))
*/
function form_radio($data = '', string $value = '', bool $checked = false, $extra = ''): string
{
is_array($data) || $data = ['name' => $data]; // @phpstan-ignore-line
$data['type'] = 'radio';
if (! is_array($data))
{
$data = ['name' => $data];
}
$data['type'] = 'radio';
return form_checkbox($data, $value, $checked, $extra);
}

View File

@ -78,8 +78,10 @@ class RedisHandler extends BaseHandler
if (preg_match('#(?:tcp://)?([^:?]+)(?:\:(\d+))?(\?.+)?#', $this->savePath, $matches))
{
// @phpstan-ignore-next-line
isset($matches[3]) || $matches[3] = ''; // Just to avoid undefined index notices below
if (! isset($matches[3]))
{
$matches[3] = '';
} // Just to avoid undefined index notices below
$this->savePath = [
'host' => $matches[1],

View File

@ -687,7 +687,10 @@ class Session implements SessionInterface
{
foreach ($_SESSION['__ci_vars'] as $key => &$value)
{
is_int($value) || $flashdata[$key] = $_SESSION[$key];
if (! is_int($value))
{
$flashdata[$key] = $_SESSION[$key];
}
}
}
@ -786,7 +789,10 @@ class Session implements SessionInterface
$keys = [];
foreach (array_keys($_SESSION['__ci_vars']) as $key)
{
is_int($_SESSION['__ci_vars'][$key]) || $keys[] = $key;
if (! is_int($_SESSION['__ci_vars'][$key]))
{
$keys[] = $key;
}
}
return $keys;
@ -922,7 +928,10 @@ class Session implements SessionInterface
return;
}
is_array($key) || $key = [$key]; // @phpstan-ignore-line
if (! is_array($key))
{
$key = [$key];
}
foreach ($key as $k)
{

View File

@ -247,7 +247,10 @@ class Table
foreach ($args as $key => $val)
{
is_array($val) || $args[$key] = ['data' => $val]; // @phpstan-ignore-line
if (! is_array($val))
{
$args[$key] = ['data' => $val];
}
}
return $args;