mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
commit
bff33ac7aa
@ -49,7 +49,7 @@ if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) {
|
||||
case is_array($value):
|
||||
return count($value) ? '[...]' : '[]';
|
||||
|
||||
case is_null($value):
|
||||
case $value === null:
|
||||
return 'null'; // return the lowercased version
|
||||
|
||||
default:
|
||||
|
@ -110,7 +110,7 @@ trait ResponseTrait
|
||||
$output = $this->format($data);
|
||||
}
|
||||
|
||||
if (! is_null($output)) {
|
||||
if ($output !== null) {
|
||||
if ($this->format === 'json') {
|
||||
return $this->response->setJSON($output)->setStatusCode($status, $message);
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ class CLI
|
||||
*/
|
||||
public static function strlen(?string $string): int
|
||||
{
|
||||
if (is_null($string)) {
|
||||
if ($string === null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -632,7 +632,7 @@ class CLI
|
||||
*/
|
||||
public static function getWidth(int $default = 80): int
|
||||
{
|
||||
if (\is_null(static::$width)) {
|
||||
if (static::$width === null) {
|
||||
static::generateDimensions();
|
||||
}
|
||||
|
||||
@ -650,7 +650,7 @@ class CLI
|
||||
*/
|
||||
public static function getHeight(int $default = 32): int
|
||||
{
|
||||
if (\is_null(static::$height)) {
|
||||
if (static::$height === null) {
|
||||
static::generateDimensions();
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ trait GeneratorTrait
|
||||
// Gets the class name from input.
|
||||
$class = $this->params[0] ?? CLI::getSegment(2);
|
||||
|
||||
if (is_null($class) && $this->hasClassName) {
|
||||
if ($class === null && $this->hasClassName) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$nameLang = $this->classNameLang ?: 'CLI.generator.className.default';
|
||||
$class = CLI::prompt(lang($nameLang), null, 'required');
|
||||
@ -388,6 +388,6 @@ trait GeneratorTrait
|
||||
return CLI::getOption($name);
|
||||
}
|
||||
|
||||
return is_null($this->params[$name]) ? true : $this->params[$name];
|
||||
return $this->params[$name] ?? true;
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ abstract class BaseHandler implements CacheInterface
|
||||
{
|
||||
$value = $this->get($key);
|
||||
|
||||
if (! is_null($value)) {
|
||||
if ($value !== null) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
@ -379,7 +379,7 @@ class CodeIgniter
|
||||
|
||||
// If any filters were specified within the routes file,
|
||||
// we need to ensure it's active for the current request
|
||||
if (! is_null($routeFilter)) {
|
||||
if ($routeFilter !== null) {
|
||||
$filters->enableFilter($routeFilter, 'before');
|
||||
$filters->enableFilter($routeFilter, 'after');
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ if (! function_exists('cache')) {
|
||||
$cache = Services::cache();
|
||||
|
||||
// No params - return cache object
|
||||
if (is_null($key)) {
|
||||
if ($key === null) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
@ -482,10 +482,10 @@ if (! function_exists('force_https')) {
|
||||
*/
|
||||
function force_https(int $duration = 31536000, RequestInterface $request = null, ResponseInterface $response = null)
|
||||
{
|
||||
if (is_null($request)) {
|
||||
if ($request === null) {
|
||||
$request = Services::request(null, true);
|
||||
}
|
||||
if (is_null($response)) {
|
||||
if ($response === null) {
|
||||
$response = Services::response(null, true);
|
||||
}
|
||||
|
||||
@ -674,7 +674,7 @@ if (! function_exists('helper')) {
|
||||
// Now actually include all of the files
|
||||
if (! empty($includes)) {
|
||||
foreach ($includes as $path) {
|
||||
include_once($path);
|
||||
include_once $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -861,7 +861,7 @@ if (! function_exists('old')) {
|
||||
|
||||
// Return the default value if nothing
|
||||
// found in the old input.
|
||||
if (is_null($value)) {
|
||||
if ($value === null) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ class BaseConfig
|
||||
foreach (array_keys($property) as $key) {
|
||||
$this->initEnvValue($property[$key], "{$name}.{$key}", $prefix, $shortPrefix);
|
||||
}
|
||||
} elseif (($value = $this->getEnvValue($name, $prefix, $shortPrefix)) !== false && ! is_null($value)) {
|
||||
} elseif (($value = $this->getEnvValue($name, $prefix, $shortPrefix)) !== false && $value !== null) {
|
||||
if ($value === 'false') {
|
||||
$value = false;
|
||||
} elseif ($value === 'true') {
|
||||
|
@ -230,7 +230,7 @@ class DotEnv
|
||||
function ($matchedPatterns) {
|
||||
$nestedVariable = $this->getVariable($matchedPatterns[1]);
|
||||
|
||||
if (is_null($nestedVariable)) {
|
||||
if ($nestedVariable === null) {
|
||||
return $matchedPatterns[0];
|
||||
}
|
||||
|
||||
|
@ -1619,7 +1619,7 @@ class BaseBuilder
|
||||
*/
|
||||
public function limit(?int $value = null, ?int $offset = 0)
|
||||
{
|
||||
if (! is_null($value)) {
|
||||
if ($value !== null) {
|
||||
$this->QBLimit = $value;
|
||||
}
|
||||
|
||||
@ -1778,7 +1778,7 @@ class BaseBuilder
|
||||
*/
|
||||
public function get(int $limit = null, int $offset = 0, bool $reset = true)
|
||||
{
|
||||
if (! is_null($limit)) {
|
||||
if ($limit !== null) {
|
||||
$this->limit($limit, $offset);
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ abstract class BaseResult implements ResultInterface
|
||||
return $this->customResultObject[$className];
|
||||
}
|
||||
|
||||
is_null($this->rowData) || $this->dataSeek();
|
||||
$this->rowData === null || $this->dataSeek();
|
||||
$this->customResultObject[$className] = [];
|
||||
|
||||
while ($row = $this->fetchObject($className)) {
|
||||
@ -196,7 +196,7 @@ abstract class BaseResult implements ResultInterface
|
||||
return $this->resultArray;
|
||||
}
|
||||
|
||||
is_null($this->rowData) || $this->dataSeek();
|
||||
$this->rowData === null || $this->dataSeek();
|
||||
|
||||
while ($row = $this->fetchAssoc()) {
|
||||
$this->resultArray[] = $row;
|
||||
@ -235,7 +235,7 @@ abstract class BaseResult implements ResultInterface
|
||||
return $this->resultObject;
|
||||
}
|
||||
|
||||
is_null($this->rowData) || $this->dataSeek();
|
||||
$this->rowData === null || $this->dataSeek();
|
||||
|
||||
while ($row = $this->fetchObject()) {
|
||||
if (! is_subclass_of($row, Entity::class) && method_exists($row, 'syncOriginal')) {
|
||||
|
@ -48,7 +48,7 @@ abstract class Migration
|
||||
*/
|
||||
public function __construct(Forge $forge = null)
|
||||
{
|
||||
$this->forge = ! is_null($forge) ? $forge : Database::forge($this->DBGroup ?? config('Database')->defaultGroup);
|
||||
$this->forge = $forge ?? Database::forge($this->DBGroup ?? config('Database')->defaultGroup);
|
||||
|
||||
$this->db = $this->forge->getConnection();
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ class MigrationRunner
|
||||
$this->ensureTable();
|
||||
|
||||
// Set database group if not null
|
||||
if (! is_null($group)) {
|
||||
if ($group !== null) {
|
||||
$this->groupFilter = $group;
|
||||
$this->setGroup($group);
|
||||
}
|
||||
@ -248,7 +248,7 @@ class MigrationRunner
|
||||
}
|
||||
|
||||
// Set database group if not null
|
||||
if (! is_null($group)) {
|
||||
if ($group !== null) {
|
||||
$this->setGroup($group);
|
||||
}
|
||||
|
||||
@ -370,7 +370,7 @@ class MigrationRunner
|
||||
$this->ensureTable();
|
||||
|
||||
// Set database group if not null
|
||||
if (! is_null($group)) {
|
||||
if ($group !== null) {
|
||||
$this->groupFilter = $group;
|
||||
$this->setGroup($group);
|
||||
}
|
||||
@ -1006,7 +1006,7 @@ class MigrationRunner
|
||||
}
|
||||
|
||||
// Skip migration if group filtering was set
|
||||
if ($direction === 'up' && ! is_null($this->groupFilter) && $this->groupFilter !== $group) {
|
||||
if ($direction === 'up' && $this->groupFilter !== null && $this->groupFilter !== $group) {
|
||||
$this->groupSkip = true;
|
||||
|
||||
return true;
|
||||
|
@ -107,7 +107,7 @@ class Query implements QueryInterface
|
||||
{
|
||||
$this->originalQueryString = $sql;
|
||||
|
||||
if (! is_null($binds)) {
|
||||
if ($binds !== null) {
|
||||
if (! is_array($binds)) {
|
||||
$binds = [$binds];
|
||||
}
|
||||
@ -181,7 +181,7 @@ class Query implements QueryInterface
|
||||
{
|
||||
$this->startTime = $start;
|
||||
|
||||
if (is_null($end)) {
|
||||
if ($end === null) {
|
||||
$end = microtime(true);
|
||||
}
|
||||
|
||||
|
@ -682,7 +682,7 @@ class Builder extends BaseBuilder
|
||||
*/
|
||||
public function get(int $limit = null, int $offset = 0, bool $reset = true)
|
||||
{
|
||||
if (! is_null($limit)) {
|
||||
if ($limit !== null) {
|
||||
$this->limit($limit, $offset);
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ class Exceptions
|
||||
// it to an Exception and use the Exception handler to display it
|
||||
// to the user.
|
||||
// Fatal Error?
|
||||
if (! is_null($error) && in_array($error['type'], [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE], true)) {
|
||||
if ($error !== null && in_array($error['type'], [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE], true)) {
|
||||
$this->exceptionHandler(new ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']));
|
||||
}
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ class Toolbar
|
||||
header('Content-Type: application/javascript');
|
||||
|
||||
ob_start();
|
||||
include($this->config->viewsPath . 'toolbarloader.js.php');
|
||||
include $this->config->viewsPath . 'toolbarloader.js.php';
|
||||
$output = ob_get_clean();
|
||||
|
||||
exit($output);
|
||||
@ -465,7 +465,7 @@ class Toolbar
|
||||
extract($data);
|
||||
$parser = Services::parser($this->config->viewsPath, null, false);
|
||||
ob_start();
|
||||
include($this->config->viewsPath . 'toolbar.tpl.php');
|
||||
include $this->config->viewsPath . 'toolbar.tpl.php';
|
||||
$output = ob_get_clean();
|
||||
break;
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
||||
<img src="<?= $c['icon'] ?>">
|
||||
<span class="hide-sm">
|
||||
<?= $c['title'] ?>
|
||||
<?php if (! is_null($c['badgeValue'])) : ?>
|
||||
<?php if ($c['badgeValue'] !== null) : ?>
|
||||
<span class="badge"><?= $c['badgeValue'] ?></span>
|
||||
<?php endif ?>
|
||||
</span>
|
||||
|
@ -27,7 +27,7 @@ class JsonCast extends BaseCast
|
||||
{
|
||||
$associative = in_array('array', $params, true);
|
||||
|
||||
$tmp = ! is_null($value) ? ($associative ? [] : new stdClass()) : null;
|
||||
$tmp = $value !== null ? ($associative ? [] : new stdClass()) : null;
|
||||
|
||||
if (function_exists('json_decode')
|
||||
&& (
|
||||
|
@ -263,7 +263,7 @@ class Entity implements JsonSerializable
|
||||
public function hasChanged(string $key = null): bool
|
||||
{
|
||||
// If no parameter was given then check all attributes
|
||||
if (is_null($key)) {
|
||||
if ($key === null) {
|
||||
return $this->original !== $this->attributes;
|
||||
}
|
||||
|
||||
@ -358,7 +358,7 @@ class Entity implements JsonSerializable
|
||||
if (strpos($type, '?') === 0) {
|
||||
$isNullable = true;
|
||||
|
||||
if (is_null($value)) {
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -435,7 +435,7 @@ class Entity implements JsonSerializable
|
||||
*/
|
||||
public function cast(bool $cast = null)
|
||||
{
|
||||
if (is_null($cast)) {
|
||||
if ($cast === null) {
|
||||
return $this->_cast;
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ class Events
|
||||
*/
|
||||
public static function removeAllListeners($eventName = null)
|
||||
{
|
||||
if (! is_null($eventName)) {
|
||||
if ($eventName !== null) {
|
||||
unset(static::$listeners[$eventName]);
|
||||
} else {
|
||||
static::$listeners = [];
|
||||
|
@ -383,7 +383,7 @@ class Filters
|
||||
*/
|
||||
public function getArguments(string $key = null)
|
||||
{
|
||||
return is_null($key) ? $this->arguments : $this->arguments[$key];
|
||||
return $key === null ? $this->arguments : $this->arguments[$key];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -499,7 +499,7 @@ class CURLRequest extends Request
|
||||
|
||||
if ($method === 'PUT' || $method === 'POST') {
|
||||
// See http://tools.ietf.org/html/rfc7230#section-3.3.2
|
||||
if (is_null($this->header('content-length')) && ! isset($this->config['multipart'])) {
|
||||
if ($this->header('content-length') === null && ! isset($this->config['multipart'])) {
|
||||
$this->setHeader('Content-Length', '0');
|
||||
}
|
||||
} elseif ($method === 'HEAD') {
|
||||
|
@ -141,7 +141,7 @@ class UploadedFile extends File implements UploadedFileInterface
|
||||
throw HTTPException::forInvalidFile();
|
||||
}
|
||||
|
||||
$name = is_null($name) ? $this->getName() : $name;
|
||||
$name = $name ?? $this->getName();
|
||||
$destination = $overwrite ? $targetPath . $name : $this->getDestination($targetPath . $name);
|
||||
|
||||
try {
|
||||
|
@ -340,7 +340,7 @@ class IncomingRequest extends Request
|
||||
*/
|
||||
public function negotiate(string $type, array $supported, bool $strictMatch = false): string
|
||||
{
|
||||
if (is_null($this->negotiator)) {
|
||||
if ($this->negotiator === null) {
|
||||
$this->negotiator = Services::negotiator($this, true);
|
||||
}
|
||||
|
||||
@ -457,7 +457,7 @@ class IncomingRequest extends Request
|
||||
*/
|
||||
public function getPath(): string
|
||||
{
|
||||
if (is_null($this->path)) {
|
||||
if ($this->path === null) {
|
||||
$this->detectPath($this->config->uriProtocol);
|
||||
}
|
||||
|
||||
@ -523,8 +523,8 @@ class IncomingRequest extends Request
|
||||
*/
|
||||
public function getVar($index = null, $filter = null, $flags = null)
|
||||
{
|
||||
if (strpos($this->getHeaderLine('Content-Type'), 'application/json') !== false && ! is_null($this->body)) {
|
||||
if (is_null($index)) {
|
||||
if (strpos($this->getHeaderLine('Content-Type'), 'application/json') !== false && $this->body !== null) {
|
||||
if ($index === null) {
|
||||
return $this->getJSON();
|
||||
}
|
||||
|
||||
@ -743,7 +743,7 @@ class IncomingRequest extends Request
|
||||
// Check for an array value in POST.
|
||||
if (isset($_SESSION['_ci_old_input']['post'])) {
|
||||
$value = dot_array_search($key, $_SESSION['_ci_old_input']['post']);
|
||||
if (! is_null($value)) {
|
||||
if ($value !== null) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@ -751,7 +751,7 @@ class IncomingRequest extends Request
|
||||
// Check for an array value in GET.
|
||||
if (isset($_SESSION['_ci_old_input']['get'])) {
|
||||
$value = dot_array_search($key, $_SESSION['_ci_old_input']['get']);
|
||||
if (! is_null($value)) {
|
||||
if ($value !== null) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@ -770,7 +770,7 @@ class IncomingRequest extends Request
|
||||
*/
|
||||
public function getFiles(): array
|
||||
{
|
||||
if (is_null($this->files)) {
|
||||
if ($this->files === null) {
|
||||
$this->files = new FileCollection();
|
||||
}
|
||||
|
||||
@ -787,7 +787,7 @@ class IncomingRequest extends Request
|
||||
*/
|
||||
public function getFileMultiple(string $fileID)
|
||||
{
|
||||
if (is_null($this->files)) {
|
||||
if ($this->files === null) {
|
||||
$this->files = new FileCollection();
|
||||
}
|
||||
|
||||
@ -804,7 +804,7 @@ class IncomingRequest extends Request
|
||||
*/
|
||||
public function getFile(string $fileID)
|
||||
{
|
||||
if (is_null($this->files)) {
|
||||
if ($this->files === null) {
|
||||
$this->files = new FileCollection();
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ class Negotiate
|
||||
*/
|
||||
public function __construct(RequestInterface $request = null)
|
||||
{
|
||||
if (! is_null($request)) {
|
||||
if ($request !== null) {
|
||||
$this->request = $request;
|
||||
}
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ trait RequestTrait
|
||||
$flags = is_array($flags) ? $flags : (is_numeric($flags) ? (int) $flags : 0);
|
||||
|
||||
// Return all values when $index is null
|
||||
if (is_null($index)) {
|
||||
if ($index === null) {
|
||||
$values = [];
|
||||
|
||||
foreach ($this->globals[$method] as $key => $value) {
|
||||
@ -301,7 +301,7 @@ trait RequestTrait
|
||||
}
|
||||
|
||||
// Cannot filter these types of data automatically...
|
||||
if (is_array($value) || is_object($value) || is_null($value)) {
|
||||
if (is_array($value) || is_object($value) || $value === null) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ class URI
|
||||
*/
|
||||
public function __construct(string $uri = null)
|
||||
{
|
||||
if (! is_null($uri)) {
|
||||
if ($uri !== null) {
|
||||
$this->setURI($uri);
|
||||
}
|
||||
}
|
||||
@ -291,7 +291,7 @@ class URI
|
||||
*/
|
||||
public function setURI(string $uri = null)
|
||||
{
|
||||
if (! is_null($uri)) {
|
||||
if ($uri !== null) {
|
||||
$parts = parse_url($uri);
|
||||
|
||||
if ($parts === false) {
|
||||
@ -771,7 +771,7 @@ class URI
|
||||
*/
|
||||
public function setPort(int $port = null)
|
||||
{
|
||||
if (is_null($port)) {
|
||||
if ($port === null) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -1030,7 +1030,7 @@ class URI
|
||||
}
|
||||
|
||||
// Port
|
||||
if (isset($parts['port']) && ! is_null($parts['port'])) {
|
||||
if (isset($parts['port']) && $parts['port'] !== null) {
|
||||
// Valid port numbers are enforced by earlier parse_url or setPort()
|
||||
$port = $parts['port'];
|
||||
$this->port = $port;
|
||||
|
@ -235,7 +235,7 @@ if (! function_exists('get_filenames')) {
|
||||
|
||||
if ($includePath === false) {
|
||||
$files[] = $basename;
|
||||
} elseif (is_null($includePath)) {
|
||||
} elseif ($includePath === null) {
|
||||
$files[] = str_replace($sourceDir, '', $name);
|
||||
} else {
|
||||
$files[] = $name;
|
||||
|
@ -82,7 +82,7 @@ class Time extends DateTime
|
||||
$this->locale = ! empty($locale) ? $locale : Locale::getDefault();
|
||||
|
||||
// If a test instance has been provided, use it instead.
|
||||
if (is_null($time) && static::$testNow instanceof Time) {
|
||||
if ($time === null && static::$testNow instanceof Time) {
|
||||
if (empty($timezone)) {
|
||||
$timezone = static::$testNow->getTimezone();
|
||||
}
|
||||
@ -255,9 +255,9 @@ class Time extends DateTime
|
||||
*/
|
||||
public static function create(int $year = null, int $month = null, int $day = null, int $hour = null, int $minutes = null, int $seconds = null, $timezone = null, string $locale = null)
|
||||
{
|
||||
$year = is_null($year) ? date('Y') : $year;
|
||||
$month = is_null($month) ? date('m') : $month;
|
||||
$day = is_null($day) ? date('d') : $day;
|
||||
$year = $year ?? date('Y');
|
||||
$month = $month ?? date('m');
|
||||
$day = $day ?? date('d');
|
||||
$hour = empty($hour) ? 0 : $hour;
|
||||
$minutes = empty($minutes) ? 0 : $minutes;
|
||||
$seconds = empty($seconds) ? 0 : $seconds;
|
||||
@ -380,7 +380,7 @@ class Time extends DateTime
|
||||
public static function setTestNow($datetime = null, $timezone = null, string $locale = null)
|
||||
{
|
||||
// Reset the test instance
|
||||
if (is_null($datetime)) {
|
||||
if ($datetime === null) {
|
||||
static::$testNow = null;
|
||||
|
||||
return;
|
||||
@ -405,7 +405,7 @@ class Time extends DateTime
|
||||
*/
|
||||
public static function hasTestNow(): bool
|
||||
{
|
||||
return ! is_null(static::$testNow);
|
||||
return static::$testNow !== null;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -598,7 +598,7 @@ abstract class BaseHandler implements ImageHandlerInterface
|
||||
case IMAGETYPE_JPEG:
|
||||
case IMAGETYPE_TIFF_II:
|
||||
$exif = @exif_read_data($this->image()->getPathname());
|
||||
if (! is_null($key) && is_array($exif)) {
|
||||
if ($key !== null && is_array($exif)) {
|
||||
$exif = $exif[$key] ?? false;
|
||||
}
|
||||
}
|
||||
@ -635,7 +635,7 @@ abstract class BaseHandler implements ImageHandlerInterface
|
||||
|
||||
[$cropWidth, $cropHeight] = $this->calcAspectRatio($width, $height, $origWidth, $origHeight);
|
||||
|
||||
if (is_null($height)) {
|
||||
if ($height === null) {
|
||||
$height = ceil(($width / $cropWidth) * $cropHeight);
|
||||
}
|
||||
|
||||
@ -664,7 +664,7 @@ abstract class BaseHandler implements ImageHandlerInterface
|
||||
|
||||
// If $height is null, then we have it easy.
|
||||
// Calc based on full image size and be done.
|
||||
if (is_null($height)) {
|
||||
if ($height === null) {
|
||||
$height = ($width / $origWidth) * $origHeight;
|
||||
|
||||
return [
|
||||
|
@ -321,7 +321,7 @@ class ImageMagickHandler extends BaseHandler
|
||||
*/
|
||||
protected function getResourcePath()
|
||||
{
|
||||
if (! is_null($this->resource)) {
|
||||
if ($this->resource !== null) {
|
||||
return $this->resource;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ class Image extends File
|
||||
{
|
||||
$targetPath = rtrim($targetPath, '/ ') . '/';
|
||||
|
||||
$targetName = is_null($targetName) ? $this->getFilename() : $targetName;
|
||||
$targetName = $targetName ?? $this->getFilename();
|
||||
|
||||
if (empty($targetName)) {
|
||||
throw ImageException::forInvalidFile($targetName);
|
||||
|
@ -75,7 +75,7 @@ class Language
|
||||
*/
|
||||
public function setLocale(string $locale = null)
|
||||
{
|
||||
if (! is_null($locale)) {
|
||||
if ($locale !== null) {
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ class ChromeLoggerHandler extends BaseHandler
|
||||
*/
|
||||
public function sendLogs(ResponseInterface &$response = null)
|
||||
{
|
||||
if (is_null($response)) {
|
||||
if ($response === null) {
|
||||
$response = Services::response(null, true);
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ class PagerRenderer
|
||||
*/
|
||||
protected function updatePages(int $count = null)
|
||||
{
|
||||
if (is_null($count)) {
|
||||
if ($count === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1316,7 +1316,7 @@ class RouteCollection implements RouteCollectionInterface
|
||||
protected function create(string $verb, string $from, $to, array $options = null)
|
||||
{
|
||||
$overwrite = false;
|
||||
$prefix = is_null($this->group) ? '' : $this->group . '/';
|
||||
$prefix = $this->group === null ? '' : $this->group . '/';
|
||||
|
||||
$from = filter_var($prefix . $from, FILTER_SANITIZE_STRING);
|
||||
|
||||
@ -1435,7 +1435,7 @@ class RouteCollection implements RouteCollectionInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_null($this->currentSubdomain)) {
|
||||
if ($this->currentSubdomain === null) {
|
||||
$this->currentSubdomain = $this->determineCurrentSubdomain();
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ class Security implements SecurityInterface
|
||||
*/
|
||||
protected function generateHash(): string
|
||||
{
|
||||
if (is_null($this->hash)) {
|
||||
if ($this->hash === null) {
|
||||
// If the cookie exists we will use its value.
|
||||
// We don't necessarily want to regenerate it with
|
||||
// each page load since a page could contain embedded
|
||||
|
@ -134,7 +134,7 @@ class DatabaseHandler extends BaseHandler
|
||||
}
|
||||
|
||||
// Needed by write() to detect session_regenerate_id() calls
|
||||
if (is_null($this->sessionID)) { // @phpstan-ignore-line
|
||||
if (! isset($this->sessionID)) {
|
||||
$this->sessionID = $sessionID;
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ class FileHandler extends BaseHandler
|
||||
}
|
||||
|
||||
// Needed by write() to detect session_regenerate_id() calls
|
||||
if (is_null($this->sessionID)) { // @phpstan-ignore-line
|
||||
if (! isset($this->sessionID)) {
|
||||
$this->sessionID = $sessionID;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ class MemcachedHandler extends BaseHandler
|
||||
{
|
||||
if (isset($this->memcached) && $this->lockSession($sessionID)) {
|
||||
// Needed by write() to detect session_regenerate_id() calls
|
||||
if (is_null($this->sessionID)) { // @phpstan-ignore-line
|
||||
if (! isset($this->sessionID)) {
|
||||
$this->sessionID = $sessionID;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ class RedisHandler extends BaseHandler
|
||||
{
|
||||
if (isset($this->redis) && $this->lockSession($sessionID)) {
|
||||
// Needed by write() to detect session_regenerate_id() calls
|
||||
if (is_null($this->sessionID)) { // @phpstan-ignore-line
|
||||
if (! isset($this->sessionID)) {
|
||||
$this->sessionID = $sessionID;
|
||||
}
|
||||
|
||||
|
@ -488,7 +488,7 @@ class Session implements SessionInterface
|
||||
*/
|
||||
public function get(string $key = null)
|
||||
{
|
||||
if (! empty($key) && (! is_null($value = $_SESSION[$key] ?? null) || ! is_null($value = dot_array_search($key, $_SESSION ?? [])))) {
|
||||
if (! empty($key) && (null !== ($value = $_SESSION[$key] ?? null) || null !== ($value = dot_array_search($key, $_SESSION ?? [])))) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ abstract class CIUnitTestCase extends TestCase
|
||||
*/
|
||||
private function callTraitMethods(string $stage): void
|
||||
{
|
||||
if (is_null($this->traits)) {
|
||||
if ($this->traits === null) {
|
||||
$this->traits = class_uses_recursive($this);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ class DOMParser
|
||||
public function see(string $search = null, string $element = null): bool
|
||||
{
|
||||
// If Element is null, we're just scanning for text
|
||||
if (is_null($element)) {
|
||||
if ($element === null) {
|
||||
$content = $this->dom->saveHTML($this->dom->documentElement);
|
||||
|
||||
return mb_strpos($content, $search) !== false;
|
||||
@ -261,7 +261,7 @@ class DOMParser
|
||||
}
|
||||
}
|
||||
|
||||
if (! is_null($search)) {
|
||||
if ($search !== null) {
|
||||
$path .= "[contains(., \"{$search}\")]";
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ class Fabricator
|
||||
$this->model = $model;
|
||||
|
||||
// If no locale was specified then use the App default
|
||||
if (is_null($locale)) {
|
||||
if ($locale === null) {
|
||||
$locale = config('App')->defaultLocale;
|
||||
}
|
||||
|
||||
@ -284,7 +284,7 @@ class Fabricator
|
||||
*/
|
||||
public function setFormatters(array $formatters = null): self
|
||||
{
|
||||
if (! is_null($formatters)) {
|
||||
if ($formatters !== null) {
|
||||
$this->formatters = $formatters;
|
||||
} elseif (method_exists($this->model, 'fake')) {
|
||||
$this->formatters = null;
|
||||
@ -372,7 +372,7 @@ class Fabricator
|
||||
public function make(int $count = null)
|
||||
{
|
||||
// If a singleton was requested then go straight to it
|
||||
if (is_null($count)) {
|
||||
if ($count === null) {
|
||||
return $this->model->returnType === 'array'
|
||||
? $this->makeArray()
|
||||
: $this->makeObject();
|
||||
@ -398,7 +398,7 @@ class Fabricator
|
||||
*/
|
||||
public function makeArray()
|
||||
{
|
||||
if (! is_null($this->formatters)) {
|
||||
if ($this->formatters !== null) {
|
||||
$result = [];
|
||||
|
||||
foreach ($this->formatters as $field => $formatter) {
|
||||
@ -435,7 +435,7 @@ class Fabricator
|
||||
*/
|
||||
public function makeObject(string $className = null): object
|
||||
{
|
||||
if (is_null($className)) {
|
||||
if ($className === null) {
|
||||
if ($this->model->returnType === 'object' || $this->model->returnType === 'array') {
|
||||
$className = 'stdClass';
|
||||
} else {
|
||||
@ -444,7 +444,7 @@ class Fabricator
|
||||
}
|
||||
|
||||
// If using the model's fake() method then check it for the correct return type
|
||||
if (is_null($this->formatters) && method_exists($this->model, 'fake')) {
|
||||
if ($this->formatters === null && method_exists($this->model, 'fake')) {
|
||||
$result = $this->model->fake($this->faker);
|
||||
|
||||
if ($result instanceof $className) {
|
||||
@ -511,7 +511,7 @@ class Fabricator
|
||||
$this->model->withDeleted();
|
||||
}
|
||||
|
||||
return $this->model->find(is_null($count) ? reset($ids) : $ids);
|
||||
return $this->model->find($count === null ? reset($ids) : $ids);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -567,6 +567,6 @@ class Fabricator
|
||||
$return[] = $result;
|
||||
}
|
||||
|
||||
return is_null($count) ? reset($return) : $return;
|
||||
return $count === null ? reset($return) : $return;
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ class FeatureTestCase extends CIUnitTestCase
|
||||
*/
|
||||
public function withSession(array $values = null)
|
||||
{
|
||||
$this->session = is_null($values) ? $_SESSION : $values;
|
||||
$this->session = $values ?? $_SESSION;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ trait FeatureTestTrait
|
||||
*/
|
||||
public function withSession(array $values = null)
|
||||
{
|
||||
$this->session = is_null($values) ? $_SESSION : $values;
|
||||
$this->session = $values ?? $_SESSION;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ trait FilterTestTrait
|
||||
$this->filtersConfig = $this->filtersConfig ?? config('Filters');
|
||||
$this->filters = $this->filters ?? new Filters($this->filtersConfig, $this->request, $this->response);
|
||||
|
||||
if (is_null($this->collection)) {
|
||||
if ($this->collection === null) {
|
||||
// Load the RouteCollection from Config to gather App route info
|
||||
// (creates $routes using the Service as a starting point)
|
||||
require APPPATH . 'Config/Routes.php';
|
||||
|
@ -71,7 +71,7 @@ class MockCache extends BaseHandler implements CacheInterface
|
||||
{
|
||||
$value = $this->get($key);
|
||||
|
||||
if (! is_null($value)) {
|
||||
if ($value !== null) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ class TestResponse extends TestCase
|
||||
{
|
||||
$this->assertArrayHasKey($key, $_SESSION, "'{$key}' is not in the current \$_SESSION");
|
||||
|
||||
if (is_null($value)) {
|
||||
if ($value === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -382,7 +382,7 @@ class TestResponse extends TestCase
|
||||
{
|
||||
$response = $this->response->getJSON();
|
||||
|
||||
if (is_null($response)) {
|
||||
if ($response === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ class FileRules
|
||||
*/
|
||||
public function __construct(RequestInterface $request = null)
|
||||
{
|
||||
if (is_null($request)) {
|
||||
if ($request === null) {
|
||||
$request = Services::request();
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ class FileRules
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (is_null($file)) {
|
||||
if ($file === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ class FileRules
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (is_null($file)) {
|
||||
if ($file === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ class FileRules
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (is_null($file)) {
|
||||
if ($file === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ class FileRules
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (is_null($file)) {
|
||||
if ($file === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ class FileRules
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (is_null($file)) {
|
||||
if ($file === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -265,7 +265,7 @@ class FileRules
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (is_null($file)) {
|
||||
if ($file === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ class Rules
|
||||
*/
|
||||
public function required_with($str = null, string $fields = null, array $data = []): bool
|
||||
{
|
||||
if (is_null($fields) || empty($data)) {
|
||||
if ($fields === null || empty($data)) {
|
||||
throw new InvalidArgumentException('You must supply the parameters: fields, data.');
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ class Rules
|
||||
*/
|
||||
public function required_without($str = null, string $fields = null, array $data = []): bool
|
||||
{
|
||||
if (is_null($fields) || empty($data)) {
|
||||
if ($fields === null || empty($data)) {
|
||||
throw new InvalidArgumentException('You must supply the parameters: fields, data.');
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ class Validation implements ValidationInterface
|
||||
*/
|
||||
protected function processRules(string $field, string $label = null, $value, $rules = null, array $data = null): bool
|
||||
{
|
||||
if (is_null($data)) {
|
||||
if ($data === null) {
|
||||
throw new InvalidArgumentException('You must supply the parameter: data.');
|
||||
}
|
||||
|
||||
@ -303,9 +303,7 @@ class Validation implements ValidationInterface
|
||||
$value = '[' . implode(', ', $value) . ']';
|
||||
}
|
||||
|
||||
$this->errors[$field] = is_null($error)
|
||||
? $this->getErrorMessage($rule, $field, $label, $param, $value)
|
||||
: $error; // @phpstan-ignore-line
|
||||
$this->errors[$field] = $error ?? $this->getErrorMessage($rule, $field, $label, $param, $value);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ class Parser extends View
|
||||
public function render(string $view, array $options = null, bool $saveData = null): string
|
||||
{
|
||||
$start = microtime(true);
|
||||
if (is_null($saveData)) {
|
||||
if ($saveData === null) {
|
||||
$saveData = $this->config->saveData;
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ class Parser extends View
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null($this->tempData)) {
|
||||
if ($this->tempData === null) {
|
||||
$this->tempData = $this->data;
|
||||
}
|
||||
|
||||
@ -158,11 +158,11 @@ class Parser extends View
|
||||
public function renderString(string $template, array $options = null, bool $saveData = null): string
|
||||
{
|
||||
$start = microtime(true);
|
||||
if (is_null($saveData)) {
|
||||
if ($saveData === null) {
|
||||
$saveData = $this->config->saveData;
|
||||
}
|
||||
|
||||
if (is_null($this->tempData)) {
|
||||
if ($this->tempData === null) {
|
||||
$this->tempData = $this->data;
|
||||
}
|
||||
|
||||
@ -488,7 +488,7 @@ class Parser extends View
|
||||
// Parse the PHP itself, or insert an error so they can debug
|
||||
ob_start();
|
||||
|
||||
if (is_null($this->tempData)) {
|
||||
if ($this->tempData === null) {
|
||||
$this->tempData = $this->data;
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ class View implements RendererInterface
|
||||
// When using layouts, the data has already been stored
|
||||
// in $this->sections, and no other valid output
|
||||
// is allowed in $output so we'll overwrite it.
|
||||
if (! is_null($this->layout) && $this->sectionStack === []) {
|
||||
if ($this->layout !== null && $this->sectionStack === []) {
|
||||
$layoutView = $this->layout;
|
||||
$this->layout = null;
|
||||
// Save current vars
|
||||
|
@ -54,7 +54,7 @@ final class ResponseTraitTest extends CIUnitTestCase
|
||||
$config->{$key} = $value;
|
||||
}
|
||||
|
||||
if (is_null($this->request)) {
|
||||
if ($this->request === null) {
|
||||
$this->request = new MockIncomingRequest((object) $config, new URI($uri), null, new UserAgent());
|
||||
$this->response = new MockResponse((object) $config);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ class Role implements FilterInterface
|
||||
{
|
||||
if (is_array($arguments)) {
|
||||
$response->setBody(implode(';', $arguments));
|
||||
} elseif (is_null($arguments)) {
|
||||
} elseif ($arguments === null) {
|
||||
$response->setBody('Is null');
|
||||
} else {
|
||||
$response->setBody('Something else');
|
||||
@ -26,7 +26,7 @@ class Role implements FilterInterface
|
||||
if (is_array($arguments)) {
|
||||
return implode(';', $arguments);
|
||||
}
|
||||
if (is_null($arguments)) {
|
||||
if ($arguments === null) {
|
||||
return 'Is null';
|
||||
}
|
||||
|
||||
|
@ -159,8 +159,11 @@ final class CodeIgniter4 extends AbstractRuleset
|
||||
'group_import' => false,
|
||||
'heredoc_indentation' => ['indentation' => 'start_plus_one'],
|
||||
'heredoc_to_nowdoc' => true,
|
||||
'implode_call' => true,
|
||||
'include' => true,
|
||||
'increment_style' => ['style' => 'post'],
|
||||
'indentation_type' => true,
|
||||
'is_null' => true,
|
||||
'lambda_not_used_import' => true,
|
||||
'line_ending' => true,
|
||||
'linebreak_after_opening_tag' => true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user