Merge branch 'develop' into 4.6

This commit is contained in:
John Paul E. Balandan, CPA 2024-12-29 00:21:53 +08:00
commit c7548a3771
No known key found for this signature in database
GPG Key ID: 697D84680E3738DA
96 changed files with 314 additions and 584 deletions

View File

@ -26,6 +26,7 @@ $finder = Finder::create()
'_support/View/Cells/multiplier.php',
'_support/View/Cells/colors.php',
'_support/View/Cells/addition.php',
'system/Database/Live/PreparedQueryTest.php',
])
->notName('#Foobar.php$#');

View File

@ -52,7 +52,7 @@ if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) {
$args = implode(', ', array_map(static fn ($value) => match (true) {
is_object($value) => 'Object(' . $value::class . ')',
is_array($value) => count($value) ? '[...]' : '[]',
is_array($value) => $value !== [] ? '[...]' : '[]',
$value === null => 'null', // return the lowercased version
default => var_export($value, true),
}, array_values($error['args'] ?? [])));

View File

@ -28,7 +28,7 @@
"phpunit/phpcov": "^9.0.2 || ^10.0",
"phpunit/phpunit": "^10.5.16 || ^11.2",
"predis/predis": "^1.1 || ^2.3",
"rector/rector": "2.0.3",
"rector/rector": "2.0.4",
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
},
"replace": {

View File

@ -37,7 +37,6 @@ use Rector\Php70\Rector\FuncCall\RandomFunctionRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector;
@ -55,11 +54,8 @@ use Utils\Rector\UnderscoreToCamelCaseVariableNameRector;
return RectorConfig::configure()
->withPhpSets(php81: true)
->withPreparedSets(deadCode: true)
->withSets([
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
PHPUnitSetList::PHPUNIT_100,
])
->withPreparedSets(deadCode: true, instanceOf: true, strictBooleans: true, phpunitCodeQuality: true)
->withComposerBased(phpunit: true)
->withParallel(120, 8, 10)
->withCache(
// Github action cache or local

View File

@ -639,7 +639,7 @@ abstract class BaseModel
$resultSet = $this->doFindColumn($columnName);
return $resultSet ? array_column($resultSet, $columnName) : null;
return $resultSet !== null ? array_column($resultSet, $columnName) : null;
}
/**
@ -1137,7 +1137,7 @@ abstract class BaseModel
throw new InvalidArgumentException('delete(): argument #1 ($id) should not be boolean.');
}
if ($id && (is_numeric($id) || is_string($id))) {
if (! in_array($id, [null, 0, '0'], true) && (is_numeric($id) || is_string($id))) {
$id = [$id];
}
@ -1250,7 +1250,7 @@ abstract class BaseModel
}
// Do we have validation errors?
if (! $forceDB && ! $this->skipValidation && ($errors = $this->validation->getErrors())) {
if (! $forceDB && ! $this->skipValidation && ($errors = $this->validation->getErrors()) !== []) {
return $errors;
}

View File

@ -225,12 +225,12 @@ class CLI
$extraOutput = '';
$default = '';
if ($validation && ! is_array($validation) && ! is_string($validation)) {
if (isset($validation) && ! is_array($validation) && ! is_string($validation)) {
throw new InvalidArgumentException('$rules can only be of type string|array');
}
if (! is_array($validation)) {
$validation = $validation ? explode('|', $validation) : [];
$validation = ($validation !== null) ? explode('|', $validation) : [];
}
if (is_string($options)) {
@ -348,7 +348,7 @@ class CLI
// return the prompt again if $input contain(s) non-numeric character, except a comma.
// And if max from $options less than max from input,
// it means user tried to access null value in $options
if (! $pattern || $maxOptions < $maxInput) {
if ($pattern === 0 || $maxOptions < $maxInput) {
static::error('Please select correctly.');
CLI::newLine();
@ -441,7 +441,7 @@ class CLI
*/
public static function print(string $text = '', ?string $foreground = null, ?string $background = null)
{
if ($foreground || $background) {
if ((string) $foreground !== '' || (string) $background !== '') {
$text = static::color($text, $foreground, $background);
}
@ -457,7 +457,7 @@ class CLI
*/
public static function write(string $text = '', ?string $foreground = null, ?string $background = null)
{
if ($foreground || $background) {
if ((string) $foreground !== '' || (string) $background !== '') {
$text = static::color($text, $foreground, $background);
}
@ -480,7 +480,7 @@ class CLI
$stdout = static::$isColored;
static::$isColored = static::hasColorSupport(STDERR);
if ($foreground || $background) {
if ($foreground !== '' || (string) $background !== '') {
$text = static::color($text, $foreground, $background);
}
@ -589,7 +589,7 @@ class CLI
throw CLIException::forInvalidColor('foreground', $foreground);
}
if ($background !== null && ! array_key_exists($background, static::$background_colors)) {
if ((string) $background !== '' && ! array_key_exists($background, static::$background_colors)) {
throw CLIException::forInvalidColor('background', $background);
}
@ -637,7 +637,7 @@ class CLI
{
$string = "\033[" . static::$foreground_colors[$foreground] . 'm';
if ($background !== null) {
if ((string) $background !== '') {
$string .= "\033[" . static::$background_colors[$background] . 'm';
}
@ -654,7 +654,7 @@ class CLI
*/
public static function strlen(?string $string): int
{
if ($string === null) {
if ((string) $string === '') {
return 0;
}
@ -768,7 +768,7 @@ class CLI
// Look for the next lines ending in ": <number>"
// Searching for "Columns:" or "Lines:" will fail on non-English locales
if ($return === 0 && $output && preg_match('/:\s*(\d+)\n[^:]+:\s*(\d+)\n/', implode("\n", $output), $matches)) {
if ($return === 0 && $output !== [] && preg_match('/:\s*(\d+)\n[^:]+:\s*(\d+)\n/', implode("\n", $output), $matches)) {
static::$height = (int) $matches[1];
static::$width = (int) $matches[2];
}
@ -835,7 +835,7 @@ class CLI
*/
public static function wrap(?string $string = null, int $max = 0, int $padLeft = 0): string
{
if ($string === null || $string === '') {
if ((string) $string === '') {
return '';
}

View File

@ -68,7 +68,7 @@ abstract class BaseHandler implements CacheInterface
}
$reserved = config(Cache::class)->reservedCharacters ?? self::RESERVED_CHARACTERS;
if ($reserved && strpbrk($key, $reserved) !== false) {
if ($reserved !== '' && strpbrk($key, $reserved) !== false) {
throw new InvalidArgumentException('Cache key contains reserved characters ' . $reserved);
}

View File

@ -308,7 +308,7 @@ class FileHandler extends BaseHandler
if ($filename !== '.' && $filename !== '..') {
if (is_dir($path . DIRECTORY_SEPARATOR . $filename) && $filename[0] !== '.') {
$this->deleteFiles($path . DIRECTORY_SEPARATOR . $filename, $delDir, $htdocs, $_level + 1);
} elseif (! $htdocs || ! preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename)) {
} elseif (! $htdocs || preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename) !== 1) {
@unlink($path . DIRECTORY_SEPARATOR . $filename);
}
}

View File

@ -19,6 +19,7 @@ use Config\Cache;
use Exception;
use Predis\Client;
use Predis\Collection\Iterator\Keyspace;
use Predis\Response\Status;
/**
* Predis cache handler
@ -121,7 +122,7 @@ class PredisHandler extends BaseHandler
return false;
}
if (! $this->redis->hmset($key, ['__ci_type' => $dataType, '__ci_value' => $value])) {
if (! $this->redis->hmset($key, ['__ci_type' => $dataType, '__ci_value' => $value]) instanceof Status) {
return false;
}

View File

@ -71,6 +71,8 @@ class ListCommands extends BaseCommand
/**
* Displays the help for the spark cli script itself.
*
* @return int
*/
public function run(array $params)
{
@ -78,7 +80,7 @@ class ListCommands extends BaseCommand
ksort($commands);
// Check for 'simple' format
return array_key_exists('simple', $params) || CLI::getOption('simple')
return array_key_exists('simple', $params) || CLI::getOption('simple') === true
? $this->listSimple($commands)
: $this->listFull($commands);
}
@ -86,7 +88,7 @@ class ListCommands extends BaseCommand
/**
* Lists the commands with accompanying info.
*
* @return void
* @return int
*/
protected function listFull(array $commands)
{
@ -124,17 +126,21 @@ class ListCommands extends BaseCommand
CLI::newLine();
}
}
return EXIT_SUCCESS;
}
/**
* Lists the commands only.
*
* @return void
* @return int
*/
protected function listSimple(array $commands)
{
foreach (array_keys($commands) as $title) {
CLI::write($title);
}
return EXIT_SUCCESS;
}
}

View File

@ -110,7 +110,7 @@ class Serve extends BaseCommand
// to ensure our environment is set and it simulates basic mod_rewrite.
passthru($php . ' -S ' . $host . ':' . $port . ' -t ' . $docroot . ' ' . $rewrite, $status);
if ($status && $this->portOffset < $this->tries) {
if ($status !== EXIT_SUCCESS && $this->portOffset < $this->tries) {
$this->portOffset++;
$this->run($params);

View File

@ -86,7 +86,7 @@ class Routes extends BaseCommand
$host = $params['host'] ?? null;
// Set HTTP_HOST
if ($host) {
if ($host !== null) {
$request = service('request');
$_SERVER = $request->getServer();
$_SERVER['HTTP_HOST'] = $host;
@ -96,7 +96,7 @@ class Routes extends BaseCommand
$collection = service('routes')->loadRoutes();
// Reset HTTP_HOST
if ($host) {
if ($host !== null) {
unset($_SERVER['HTTP_HOST']);
}
@ -139,7 +139,9 @@ class Routes extends BaseCommand
$autoRoutes = $autoRouteCollector->get();
// Check for Module Routes.
if ($routingConfig = config(Routing::class)) {
$routingConfig = config(Routing::class);
if ($routingConfig instanceof Routing) {
foreach ($routingConfig->moduleRoutes as $uri => $namespace) {
$autoRouteCollector = new AutoRouteCollectorImproved(
$namespace,
@ -188,7 +190,7 @@ class Routes extends BaseCommand
usort($tbody, static fn ($handler1, $handler2) => strcmp($handler1[3], $handler2[3]));
}
if ($host) {
if ($host !== null) {
CLI::write('Host: ' . $host);
}

View File

@ -221,7 +221,7 @@ final class ControllerMethodReader
if ($classShortname === $defaultController) {
$pattern = '#' . preg_quote(lcfirst($defaultController), '#') . '\z#';
$routeWithoutController = rtrim(preg_replace($pattern, '', $uriByClass), '/');
$routeWithoutController = $routeWithoutController ?: '/';
$routeWithoutController = $routeWithoutController !== '' && $routeWithoutController !== '0' ? $routeWithoutController : '/';
[$params, $routeParams] = $this->getParameters($method);

View File

@ -161,7 +161,7 @@ final class ControllerMethodReader
$pattern = '#' . preg_quote(lcfirst($defaultController), '#') . '\z#';
$routeWithoutController = rtrim(preg_replace($pattern, '', $uriByClass), '/');
$routeWithoutController = $routeWithoutController ?: '/';
$routeWithoutController = $routeWithoutController !== '' && $routeWithoutController !== '0' ? $routeWithoutController : '/';
return [[
'route' => $routeWithoutController,

View File

@ -443,7 +443,7 @@ if (! function_exists('esc')) {
$escaper = new Escaper($encoding);
}
if ($encoding && $escaper->getEncoding() !== $encoding) {
if ($encoding !== null && $escaper->getEncoding() !== $encoding) {
$escaper = new Escaper($encoding);
}
@ -741,13 +741,13 @@ if (! function_exists('lang')) {
// Get active locale
$activeLocale = $language->getLocale();
if ($locale && $locale !== $activeLocale) {
if ((string) $locale !== '' && $locale !== $activeLocale) {
$language->setLocale($locale);
}
$lines = $language->getLine($line, $args);
if ($locale && $locale !== $activeLocale) {
if ((string) $locale !== '' && $locale !== $activeLocale) {
// Reset to active locale
$language->setLocale($activeLocale);
}
@ -851,7 +851,7 @@ if (! function_exists('redirect')) {
{
$response = service('redirectresponse');
if ($route !== null) {
if ((string) $route !== '') {
return $response->route($route);
}

View File

@ -94,7 +94,7 @@ class DotEnv
*/
protected function setVariable(string $name, string $value = '')
{
if (! getenv($name, true)) {
if (getenv($name, true) === false) {
putenv("{$name}={$value}");
}

View File

@ -345,7 +345,7 @@ class Services extends BaseService
$config ??= config(Images::class);
assert($config instanceof Images);
$handler = $handler ?: $config->defaultHandler;
$handler = $handler !== null && $handler !== '' && $handler !== '0' ? $handler : $config->defaultHandler;
$class = $config->handlers[$handler];
return new $class($config);
@ -385,7 +385,7 @@ class Services extends BaseService
}
// Use '?:' for empty string check
$locale = $locale ?: $requestLocale;
$locale = $locale !== null && $locale !== '' && $locale !== '0' ? $locale : $requestLocale;
return new Language($locale);
}
@ -484,7 +484,7 @@ class Services extends BaseService
return static::getSharedInstance('parser', $viewPath, $config);
}
$viewPath = $viewPath ?: (new Paths())->viewDirectory;
$viewPath = $viewPath !== null && $viewPath !== '' && $viewPath !== '0' ? $viewPath : (new Paths())->viewDirectory;
$config ??= config(ViewConfig::class);
return new Parser($config, $viewPath, AppServices::get('locator'), CI_DEBUG, AppServices::get('logger'));
@ -503,7 +503,7 @@ class Services extends BaseService
return static::getSharedInstance('renderer', $viewPath, $config);
}
$viewPath = $viewPath ?: (new Paths())->viewDirectory;
$viewPath = $viewPath !== null && $viewPath !== '' && $viewPath !== '0' ? $viewPath : (new Paths())->viewDirectory;
$config ??= config(ViewConfig::class);
return new View($config, $viewPath, AppServices::get('locator'), CI_DEBUG, AppServices::get('logger'));

View File

@ -482,7 +482,7 @@ class Cookie implements ArrayAccess, CloneableCookieInterface
*/
public function withPath(?string $path)
{
$path = $path ?: self::$defaults['path'];
$path = $path !== null && $path !== '' && $path !== '0' ? $path : self::$defaults['path'];
$this->validatePrefix($this->prefix, $this->secure, $path, $this->domain);
$cookie = clone $this;

View File

@ -1741,7 +1741,7 @@ class BaseBuilder
// Restore the LIMIT setting
$this->QBLimit = $limit;
$row = ! $result instanceof ResultInterface ? null : $result->getRow();
$row = $result instanceof ResultInterface ? $result->getRow() : null;
if (empty($row)) {
return 0;
@ -3174,11 +3174,11 @@ class BaseBuilder
$op = $this->getOperator($condition);
if (
$op === false
|| ! preg_match(
|| preg_match(
'/^(\(?)(.*)(' . preg_quote($op, '/') . ')\s*(.*(?<!\)))?(\)?)$/i',
$condition,
$matches
)
) !== 1
) {
continue;
}

View File

@ -614,7 +614,7 @@ abstract class BaseConnection implements ConnectionInterface
*/
public function query(string $sql, $binds = null, bool $setEscapeFlags = true, string $queryClass = '')
{
$queryClass = $queryClass ?: $this->queryClass;
$queryClass = $queryClass !== '' && $queryClass !== '0' ? $queryClass : $this->queryClass;
if (empty($this->connID)) {
$this->initialize();

View File

@ -259,4 +259,12 @@ abstract class BasePreparedQuery implements PreparedQueryInterface
{
return $this->errorString;
}
/**
* Whether the input contain binary data.
*/
protected function isBinary(string $input): bool
{
return mb_detect_encoding($input, 'UTF-8', true) === false;
}
}

View File

@ -96,7 +96,7 @@ class Database
{
$dsn = parse_url($params['DSN']);
if (! $dsn) {
if ($dsn === 0 || $dsn === '' || $dsn === '0' || $dsn === [] || $dsn === false || $dsn === null) {
throw new InvalidArgumentException('Your DSN connection string is invalid.');
}

View File

@ -650,7 +650,7 @@ class Forge
return false;
}
if ($this->db->DBPrefix && str_starts_with($tableName, $this->db->DBPrefix)) {
if ($this->db->DBPrefix !== '' && str_starts_with($tableName, $this->db->DBPrefix)) {
$tableName = substr($tableName, strlen($this->db->DBPrefix));
}

View File

@ -389,7 +389,7 @@ class MigrationRunner
*/
public function findMigrations(): array
{
$namespaces = $this->namespace ? [$this->namespace] : array_keys(service('autoloader')->getNamespace());
$namespaces = $this->namespace !== null ? [$this->namespace] : array_keys(service('autoloader')->getNamespace());
$migrations = [];
foreach ($namespaces as $namespace) {
@ -450,7 +450,7 @@ class MigrationRunner
$filename = basename($path, '.php');
if (! preg_match($this->regex, $filename)) {
if (preg_match($this->regex, $filename) !== 1) {
return false;
}
@ -524,7 +524,7 @@ class MigrationRunner
{
preg_match($this->regex, $migration, $matches);
return count($matches) ? $matches[1] : '0';
return $matches !== [] ? $matches[1] : '0';
}
/**
@ -539,7 +539,7 @@ class MigrationRunner
{
preg_match($this->regex, $migration, $matches);
return count($matches) ? $matches[2] : '';
return $matches !== [] ? $matches[2] : '';
}
/**
@ -645,7 +645,7 @@ class MigrationRunner
}
// If a namespace was specified then use it
if ($this->namespace) {
if ($this->namespace !== null) {
$builder->where('namespace', $this->namespace);
}
@ -700,7 +700,7 @@ class MigrationRunner
->get()
->getResultObject();
$batch = is_array($batch) && count($batch)
$batch = is_array($batch) && $batch !== []
? end($batch)->batch
: 0;
@ -725,7 +725,7 @@ class MigrationRunner
->get()
->getResultObject();
return count($migration) ? $migration[0]->version : '0';
return $migration !== [] ? $migration[0]->version : '0';
}
/**

View File

@ -208,7 +208,7 @@ class Connection extends BaseConnection
$clientFlags
)) {
// Prior to version 5.7.3, MySQL silently downgrades to an unencrypted connection if SSL setup fails
if (($clientFlags & MYSQLI_CLIENT_SSL) && version_compare($this->mysqli->client_info, 'mysqlnd 5.7.3', '<=')
if (($clientFlags & MYSQLI_CLIENT_SSL) !== 0 && version_compare($this->mysqli->client_info, 'mysqlnd 5.7.3', '<=')
&& empty($this->mysqli->query("SHOW STATUS LIKE 'ssl_cipher'")->fetch_object()->Value)
) {
$this->mysqli->close();
@ -410,7 +410,7 @@ class Connection extends BaseConnection
{
$sql = 'SHOW TABLES FROM ' . $this->escapeIdentifier($this->database);
if ($tableName !== null) {
if ((string) $tableName !== '') {
return $sql . ' LIKE ' . $this->escape($tableName);
}
@ -486,7 +486,9 @@ class Connection extends BaseConnection
throw new DatabaseException(lang('Database.failGetIndexData'));
}
if (! $indexes = $query->getResultArray()) {
$indexes = $query->getResultArray();
if ($indexes === []) {
return [];
}

View File

@ -116,11 +116,11 @@ class Forge extends BaseForge
}
}
if ($this->db->charset !== '' && ! strpos($sql, 'CHARACTER SET') && ! strpos($sql, 'CHARSET')) {
if ($this->db->charset !== '' && ! str_contains($sql, 'CHARACTER SET') && ! str_contains($sql, 'CHARSET')) {
$sql .= ' DEFAULT CHARACTER SET = ' . $this->db->escapeString($this->db->charset);
}
if ($this->db->DBCollat !== '' && ! strpos($sql, 'COLLATE')) {
if ($this->db->DBCollat !== '' && ! str_contains($sql, 'COLLATE')) {
$sql .= ' COLLATE = ' . $this->db->escapeString($this->db->DBCollat);
}

View File

@ -66,15 +66,19 @@ class PreparedQuery extends BasePreparedQuery
throw new BadMethodCallException('You must call prepare before trying to execute a prepared statement.');
}
// First off -bind the parameters
$bindTypes = '';
// First off - bind the parameters
$bindTypes = '';
$binaryData = [];
// Determine the type string
foreach ($data as $item) {
foreach ($data as $key => $item) {
if (is_int($item)) {
$bindTypes .= 'i';
} elseif (is_numeric($item)) {
$bindTypes .= 'd';
} elseif (is_string($item) && $this->isBinary($item)) {
$bindTypes .= 'b';
$binaryData[$key] = $item;
} else {
$bindTypes .= 's';
}
@ -83,6 +87,11 @@ class PreparedQuery extends BasePreparedQuery
// Bind it
$this->statement->bind_param($bindTypes, ...$data);
// Stream binary data
foreach ($binaryData as $key => $value) {
$this->statement->send_long_data($key, $value);
}
try {
return $this->statement->execute();
} catch (mysqli_sql_exception $e) {

View File

@ -16,6 +16,7 @@ namespace CodeIgniter\Database\OCI8;
use CodeIgniter\Database\BasePreparedQuery;
use CodeIgniter\Database\Exceptions\DatabaseException;
use CodeIgniter\Exceptions\BadMethodCallException;
use OCILob;
/**
* Prepared query for OCI8
@ -73,12 +74,24 @@ class PreparedQuery extends BasePreparedQuery
throw new BadMethodCallException('You must call prepare before trying to execute a prepared statement.');
}
$binaryData = null;
foreach (array_keys($data) as $key) {
oci_bind_by_name($this->statement, ':' . $key, $data[$key]);
if (is_string($data[$key]) && $this->isBinary($data[$key])) {
$binaryData = oci_new_descriptor($this->db->connID, OCI_D_LOB);
$binaryData->writeTemporary($data[$key], OCI_TEMP_BLOB);
oci_bind_by_name($this->statement, ':' . $key, $binaryData, -1, OCI_B_BLOB);
} else {
oci_bind_by_name($this->statement, ':' . $key, $data[$key]);
}
}
$result = oci_execute($this->statement, $this->db->commitMode);
if ($binaryData instanceof OCILob) {
$binaryData->free();
}
if ($result && $this->lastInsertTableName !== '') {
$this->db->lastInsertedTableName = $this->lastInsertTableName;
}

View File

@ -471,7 +471,7 @@ class Connection extends BaseConnection
{
return [
'code' => '',
'message' => pg_last_error($this->connID) ?: '',
'message' => pg_last_error($this->connID),
];
}

View File

@ -173,6 +173,10 @@ class Forge extends BaseForge
$attributes['TYPE'] = 'TIMESTAMP';
break;
case 'BLOB':
$attributes['TYPE'] = 'BYTEA';
break;
default:
break;
}

View File

@ -87,6 +87,12 @@ class PreparedQuery extends BasePreparedQuery
throw new BadMethodCallException('You must call prepare before trying to execute a prepared statement.');
}
foreach ($data as &$item) {
if (is_string($item) && $this->isBinary($item)) {
$item = pg_escape_bytea($this->db->connID, $item);
}
}
$this->result = pg_execute($this->db->connID, $this->name, $data);
return (bool) $this->result;

View File

@ -377,7 +377,11 @@ class Connection extends BaseConnection
$retVal[$i]->max_length = $query[$i]->CHARACTER_MAXIMUM_LENGTH > 0
? $query[$i]->CHARACTER_MAXIMUM_LENGTH
: $query[$i]->NUMERIC_PRECISION;
: (
$query[$i]->CHARACTER_MAXIMUM_LENGTH === -1
? 'max'
: $query[$i]->NUMERIC_PRECISION
);
$retVal[$i]->nullable = $query[$i]->IS_NULLABLE !== 'NO';
$retVal[$i]->default = $query[$i]->COLUMN_DEFAULT;

View File

@ -397,6 +397,11 @@ class Forge extends BaseForge
$attributes['TYPE'] = 'BIT';
break;
case 'BLOB':
$attributes['TYPE'] = 'VARBINARY';
$attributes['CONSTRAINT'] ??= 'MAX';
break;
default:
break;
}

View File

@ -59,7 +59,7 @@ class PreparedQuery extends BasePreparedQuery
// Prepare parameters for the query
$queryString = $this->getQueryString();
$parameters = $this->parameterize($queryString);
$parameters = $this->parameterize($queryString, $options);
// Prepare the query
$this->statement = sqlsrv_prepare($this->db->connID, $sql, $parameters);
@ -120,8 +120,10 @@ class PreparedQuery extends BasePreparedQuery
/**
* Handle parameters.
*
* @param array<int, mixed> $options
*/
protected function parameterize(string $queryString): array
protected function parameterize(string $queryString, array $options): array
{
$numberOfVariables = substr_count($queryString, '?');
@ -129,7 +131,11 @@ class PreparedQuery extends BasePreparedQuery
for ($c = 0; $c < $numberOfVariables; $c++) {
$this->parameters[$c] = null;
$params[] = &$this->parameters[$c];
if (isset($options[$c])) {
$params[] = [&$this->parameters[$c], SQLSRV_PARAM_IN, $options[$c]];
} else {
$params[] = &$this->parameters[$c];
}
}
return $params;

View File

@ -107,7 +107,7 @@ class Connection extends BaseConnection
$this->database = WRITEPATH . $this->database;
}
$sqlite = (! $this->password)
$sqlite = (! isset($this->password) || $this->password !== '')
? new SQLite3($this->database)
: new SQLite3($this->database, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, $this->password);
@ -212,7 +212,7 @@ class Connection extends BaseConnection
*/
protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string
{
if ($tableName !== null) {
if ((string) $tableName !== '') {
return 'SELECT "NAME" FROM "SQLITE_MASTER" WHERE "TYPE" = \'table\''
. ' AND "NAME" NOT LIKE \'sqlite!_%\' ESCAPE \'!\''
. ' AND "NAME" LIKE ' . $this->escape($tableName);

View File

@ -75,6 +75,8 @@ class PreparedQuery extends BasePreparedQuery
$bindType = SQLITE3_INTEGER;
} elseif (is_float($item)) {
$bindType = SQLITE3_FLOAT;
} elseif (is_string($item) && $this->isBinary($item)) {
$bindType = SQLITE3_BLOB;
} else {
$bindType = SQLITE3_TEXT;
}

View File

@ -485,7 +485,7 @@ class Email
if ($this->validate) {
$this->validateEmail($this->stringToArray($from));
if ($returnPath) {
if ($returnPath !== null) {
$this->validateEmail($this->stringToArray($returnPath));
}
}
@ -495,7 +495,7 @@ class Email
if ($name !== '') {
// only use Q encoding if there are characters that would require it
if (! preg_match('/[\200-\377]/', $name)) {
if (preg_match('/[\200-\377]/', $name) !== 1) {
$name = '"' . addcslashes($name, "\0..\37\177'\"\\") . '"';
} else {
$name = $this->prepQEncoding($name);
@ -532,7 +532,7 @@ class Email
$this->tmpArchive['replyName'] = $name;
// only use Q encoding if there are characters that would require it
if (! preg_match('/[\200-\377]/', $name)) {
if (preg_match('/[\200-\377]/', $name) !== 1) {
$name = '"' . addcslashes($name, "\0..\37\177'\"\\") . '"';
} else {
$name = $this->prepQEncoding($name);
@ -1233,7 +1233,9 @@ class Email
$this->headerStr .= $hdr;
}
static::strlen($body) && $body .= $this->newline . $this->newline;
if (static::strlen($body) > 0) {
$body .= $this->newline . $this->newline;
}
$body .= $this->getMimeMessage() . $this->newline . $this->newline
. '--' . $lastBoundary . $this->newline

View File

@ -82,7 +82,7 @@ class OpenSSLHandler extends BaseHandler
public function encrypt($data, $params = null)
{
// Allow key override
if ($params) {
if ($params !== null) {
$this->key = is_array($params) && isset($params['key']) ? $params['key'] : $params;
}
@ -118,7 +118,7 @@ class OpenSSLHandler extends BaseHandler
public function decrypt($data, $params = null)
{
// Allow key override
if ($params) {
if ($params !== null) {
$this->key = is_array($params) && isset($params['key']) ? $params['key'] : $params;
}

View File

@ -653,7 +653,7 @@ class Filters
*/
public function getArguments(?string $key = null)
{
return $key === null ? $this->arguments : $this->arguments[$key];
return ((string) $key === '') ? $this->arguments : $this->arguments[$key];
}
// --------------------------------------------------------------------
@ -770,7 +770,7 @@ class Filters
*/
protected function processFilters(?string $uri = null)
{
if (! isset($this->config->filters) || ! $this->config->filters) {
if (! isset($this->config->filters) || $this->config->filters === []) {
return;
}

View File

@ -253,7 +253,7 @@ class FileCollection
{
$currentIndex = array_shift($index);
if (isset($currentIndex) && is_array($index) && $index && is_array($value[$currentIndex]) && $value[$currentIndex]) {
if (isset($currentIndex) && is_array($index) && $index !== [] && array_key_exists($currentIndex, $value) && is_array($value[$currentIndex])) {
return $this->getValueDotNotationSyntax($index, $value[$currentIndex]);
}

View File

@ -302,7 +302,9 @@ class UploadedFile extends File implements UploadedFileInterface
*/
public function getExtension(): string
{
return $this->guessExtension() ?: $this->getClientExtension();
$guessExtension = $this->guessExtension();
return $guessExtension !== '' ? $guessExtension : $this->getClientExtension();
}
/**

View File

@ -64,7 +64,7 @@ class OutgoingRequest extends Message implements OutgoingRequestInterface
{
$host = $uri->getHost();
return $host . ($uri->getPort() ? ':' . $uri->getPort() : '');
return $host . ($uri->getPort() > 0 ? ':' . $uri->getPort() : '');
}
/**

View File

@ -115,9 +115,8 @@ class RedirectResponse extends Response
{
$validation = service('validation');
if ($validation->getErrors()) {
$session = service('session');
$session->setFlashdata('_ci_validation_errors', $validation->getErrors());
if ($validation->getErrors() !== []) {
service('session')->setFlashdata('_ci_validation_errors', $validation->getErrors());
}
return $this;

View File

@ -59,7 +59,7 @@ trait RequestTrait
*/
public function getIPAddress(): string
{
if ($this->ipAddress) {
if ($this->ipAddress !== '') {
return $this->ipAddress;
}

View File

@ -123,18 +123,21 @@ trait ResponseTrait
*/
public function setLink(PagerInterface $pager)
{
$links = '';
$links = '';
$previous = $pager->getPreviousPageURI();
if ($previous = $pager->getPreviousPageURI()) {
if (is_string($previous) && $previous !== '') {
$links .= '<' . $pager->getPageURI($pager->getFirstPage()) . '>; rel="first",';
$links .= '<' . $previous . '>; rel="prev"';
}
if (($next = $pager->getNextPageURI()) && $previous) {
$next = $pager->getNextPageURI();
if (is_string($next) && $next !== '' && is_string($previous) && $previous !== '') {
$links .= ',';
}
if ($next) {
if (is_string($next) && $next !== '') {
$links .= '<' . $next . '>; rel="next",';
$links .= '<' . $pager->getPageURI($pager->getLastPage()) . '>; rel="last"';
}
@ -569,7 +572,7 @@ trait ResponseTrait
*/
public function hasCookie(string $name, ?string $value = null, string $prefix = ''): bool
{
$prefix = $prefix ?: Cookie::setDefaults()['prefix']; // to retain BC
$prefix = $prefix !== '' ? $prefix : Cookie::setDefaults()['prefix']; // to retain BC
return $this->cookieStore->has($name, $prefix, $value);
}
@ -589,7 +592,7 @@ trait ResponseTrait
}
try {
$prefix = $prefix ?: Cookie::setDefaults()['prefix']; // to retain BC
$prefix = $prefix !== '' ? $prefix : Cookie::setDefaults()['prefix']; // to retain BC
return $this->cookieStore->get($name, $prefix);
} catch (CookieException $e) {
@ -610,7 +613,7 @@ trait ResponseTrait
return $this;
}
$prefix = $prefix ?: Cookie::setDefaults()['prefix']; // to retain BC
$prefix = $prefix !== '' ? $prefix : Cookie::setDefaults()['prefix']; // to retain BC
$prefixed = $prefix . $name;
$store = $this->cookieStore;

View File

@ -421,7 +421,7 @@ class SiteURI extends URI
$relativePath = $this->stringifyRelativePath($relativePath);
// Check current host.
$host = ! $config instanceof App ? $this->getHost() : null;
$host = $config instanceof App ? null : $this->getHost();
$config ??= config(App::class);

View File

@ -125,7 +125,7 @@ class UserAgent implements Stringable
}
// No need to be specific, it's a browser
if ($key === null) {
if ((string) $key === '') {
return true;
}
@ -143,7 +143,7 @@ class UserAgent implements Stringable
}
// No need to be specific, it's a robot
if ($key === null) {
if ((string) $key === '') {
return true;
}
@ -161,7 +161,7 @@ class UserAgent implements Stringable
}
// No need to be specific, it's a mobile
if ($key === null) {
if ((string) $key === '') {
return true;
}
@ -289,7 +289,7 @@ class UserAgent implements Stringable
*/
protected function setPlatform(): bool
{
if (is_array($this->config->platforms) && $this->config->platforms) {
if (is_array($this->config->platforms) && $this->config->platforms !== []) {
foreach ($this->config->platforms as $key => $val) {
if (preg_match('|' . preg_quote($key, '|') . '|i', $this->agent)) {
$this->platform = $val;
@ -309,7 +309,7 @@ class UserAgent implements Stringable
*/
protected function setBrowser(): bool
{
if (is_array($this->config->browsers) && $this->config->browsers) {
if (is_array($this->config->browsers) && $this->config->browsers !== []) {
foreach ($this->config->browsers as $key => $val) {
if (preg_match('|' . $key . '.*?([0-9\.]+)|i', $this->agent, $match)) {
$this->isBrowser = true;
@ -330,7 +330,7 @@ class UserAgent implements Stringable
*/
protected function setRobot(): bool
{
if (is_array($this->config->robots) && $this->config->robots) {
if (is_array($this->config->robots) && $this->config->robots !== []) {
foreach ($this->config->robots as $key => $val) {
if (preg_match('|' . preg_quote($key, '|') . '|i', $this->agent)) {
$this->isRobot = true;
@ -350,7 +350,7 @@ class UserAgent implements Stringable
*/
protected function setMobile(): bool
{
if (is_array($this->config->mobiles) && $this->config->mobiles) {
if (is_array($this->config->mobiles) && $this->config->mobiles !== []) {
foreach ($this->config->mobiles as $key => $val) {
if (false !== (stripos($this->agent, $key))) {
$this->isMobile = true;

View File

@ -168,7 +168,7 @@ if (! function_exists('delete_files')) {
continue;
}
if (! $htdocs || ! preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename)) {
if (! $htdocs || preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename) !== 1) {
$isDir = $object->isDir();
if ($isDir && $delDir) {
rmdir($object->getPathname());

View File

@ -62,7 +62,7 @@ if (! function_exists('form_open')) {
// Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
$before = service('filters')->getFilters()['before'];
if ((in_array('csrf', $before, true) || array_key_exists('csrf', $before)) && str_contains($action, base_url()) && ! stripos($form, 'method="get"')) {
if ((in_array('csrf', $before, true) || array_key_exists('csrf', $before)) && str_contains($action, base_url()) && stripos($form, 'method="get"') === false) {
$form .= csrf_field($csrfId ?? null);
}
@ -788,7 +788,7 @@ if (! function_exists('parse_form_attributes')) {
if (! is_bool($val)) {
if ($key === 'value') {
$val = esc($val);
} elseif ($key === 'name' && ! strlen($default['name'])) {
} elseif ($key === 'name' && $default['name'] === '') {
continue;
}
$att .= $key . '="' . $val . '"' . ($key === array_key_last($default) ? '' : ' ');

View File

@ -112,7 +112,7 @@ if (! function_exists('img')) {
$img = '<img';
// Check for a relative URI
if (! preg_match('#^([a-z]+:)?//#i', $src['src']) && ! str_starts_with($src['src'], 'data:')) {
if (preg_match('#^([a-z]+:)?//#i', $src['src']) !== 1 && ! str_starts_with($src['src'], 'data:')) {
if ($indexPage) {
$img .= ' src="' . site_url($src['src']) . '"';
} else {
@ -206,7 +206,7 @@ if (! function_exists('script_tag')) {
}
foreach ($src as $k => $v) {
if ($k === 'src' && ! preg_match('#^([a-z]+:)?//#i', $v)) {
if ($k === 'src' && preg_match('#^([a-z]+:)?//#i', $v) !== 1) {
if ($indexPage) {
$script .= 'src="' . site_url($v) . '" ';
} else {
@ -252,7 +252,7 @@ if (! function_exists('link_tag')) {
$href = $href['href'] ?? '';
}
if (! preg_match('#^([a-z]+:)?//#i', $href)) {
if (preg_match('#^([a-z]+:)?//#i', $href) !== 1) {
$attributes['href'] = $indexPage ? site_url($href) : slash_item('baseURL') . $href;
} else {
$attributes['href'] = $href;

View File

@ -742,7 +742,7 @@ if (! function_exists('excerpt')) {
$count = ++$count + strlen($s);
}
$ellPre = $phrase ? $ellipsis : '';
$ellPre = $phrase !== null ? $ellipsis : '';
return str_replace(' ', ' ', $ellPre . $prev . $phrase . $post . $ellipsis);
}

View File

@ -37,7 +37,7 @@ final class HotReloader
$appHash = $hasher->hash();
while (true) {
if (connection_status() !== CONNECTION_NORMAL || connection_aborted()) {
if (connection_status() !== CONNECTION_NORMAL || connection_aborted() === 1) {
break;
}
@ -50,6 +50,7 @@ final class HotReloader
$this->sendEvent('reload', ['time' => date('Y-m-d H:i:s')]);
break;
}
if (mt_rand(1, 10) > 8) {
$this->sendEvent('ping', ['time' => date('Y-m-d H:i:s')]);
}

View File

@ -73,7 +73,7 @@ trait TimeTrait
*/
public function __construct(?string $time = null, $timezone = null, ?string $locale = null)
{
$this->locale = $locale ?: Locale::getDefault();
$this->locale = $locale !== null && $locale !== '' && $locale !== '0' ? $locale : Locale::getDefault();
$time ??= '';
@ -940,7 +940,7 @@ trait TimeTrait
if ($testTime instanceof DateTimeInterface) {
$testTime = $testTime->format('Y-m-d H:i:s.u O');
} elseif (is_string($testTime)) {
$timezone = $timezone ?: $this->timezone;
$timezone = $timezone !== null && $timezone !== '' && $timezone !== '0' ? $timezone : $this->timezone;
$timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone);
$testTime = new DateTime($testTime, $timezone);
$testTime = $testTime->format('Y-m-d H:i:s.u O');
@ -1102,7 +1102,7 @@ trait TimeTrait
if ($time instanceof static) {
$time = $time->toDateTime();
} elseif (is_string($time)) {
$timezone = $timezone ?: $this->timezone;
$timezone = $timezone !== null && $timezone !== '' && $timezone !== '0' ? $timezone : $this->timezone;
$timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone);
$time = new DateTime($time, $timezone);
}

View File

@ -102,8 +102,9 @@ class Image extends File
public function getProperties(bool $return = false)
{
$path = $this->getPathname();
$vals = getimagesize($path);
if (! $vals = getimagesize($path)) {
if ($vals === false) {
throw ImageException::forFileNotSupported();
}

View File

@ -317,13 +317,13 @@ class Model extends BaseModel
if ($this->tempUseSoftDeletes) {
$builder->where($this->table . '.' . $this->deletedField, null);
} elseif ($this->useSoftDeletes && ($builder->QBGroupBy === []) && $this->primaryKey) {
} elseif ($this->useSoftDeletes && ($builder->QBGroupBy === []) && $this->primaryKey !== '') {
$builder->groupBy($this->table . '.' . $this->primaryKey);
}
// Some databases, like PostgreSQL, need order
// information to consistently return correct results.
if ($builder->QBGroupBy && ($builder->QBOrderBy === []) && $this->primaryKey) {
if ($builder->QBGroupBy !== [] && ($builder->QBOrderBy === []) && $this->primaryKey !== '') {
$builder->orderBy($this->table . '.' . $this->primaryKey, 'asc');
}
@ -443,7 +443,7 @@ class Model extends BaseModel
$builder = $this->builder();
if ($id) {
if (! in_array($id, [null, '', 0, '0', []], true)) {
$builder = $builder->whereIn($this->table . '.' . $this->primaryKey, $id);
}
@ -496,7 +496,7 @@ class Model extends BaseModel
$set = [];
$builder = $this->builder();
if ($id) {
if (! in_array($id, [null, '', 0, '0', []], true)) {
$builder = $builder->whereIn($this->primaryKey, $id);
}
@ -690,7 +690,7 @@ class Model extends BaseModel
// Check for an existing Builder
if ($this->builder instanceof BaseBuilder) {
// Make sure the requested table matches the builder
if ($table && $this->builder->getTable() !== $table) {
if ((string) $table !== '' && $this->builder->getTable() !== $table) {
return $this->db->table($table);
}
@ -704,7 +704,7 @@ class Model extends BaseModel
throw ModelException::forNoPrimaryKey(static::class);
}
$table = ($table === null || $table === '') ? $this->table : $table;
$table = ((string) $table === '') ? $this->table : $table;
// Ensure we have a good db connection
if (! $this->db instanceof BaseConnection) {

View File

@ -61,7 +61,7 @@ abstract class BaseResource extends Controller
*/
public function setModel($which = null)
{
if ($which) {
if ($which !== null) {
$this->model = is_object($which) ? $which : null;
$this->modelName = is_object($which) ? null : $which;
}

View File

@ -105,7 +105,7 @@ final class AutoRouter implements AutoRouterInterface
if ($httpVerb !== 'CLI') {
$controller = '\\' . $this->defaultNamespace;
$controller .= $this->directory ? str_replace('/', '\\', $this->directory) : '';
$controller .= $this->directory !== null ? str_replace('/', '\\', $this->directory) : '';
$controller .= $controllerName;
$controller = strtolower($controller);
@ -244,7 +244,7 @@ final class AutoRouter implements AutoRouterInterface
*/
public function setDirectory(?string $dir = null, bool $append = false, bool $validate = true)
{
if ($dir === null || $dir === '') {
if ((string) $dir === '') {
$this->directory = null;
return;
@ -260,7 +260,7 @@ final class AutoRouter implements AutoRouterInterface
}
}
if (! $append || ($this->directory === null || $this->directory === '')) {
if (! $append || ((string) $this->directory === '')) {
$this->directory = trim($dir, '/') . '/';
} else {
$this->directory .= trim($dir, '/') . '/';
@ -275,7 +275,7 @@ final class AutoRouter implements AutoRouterInterface
*/
public function directory(): string
{
return ($this->directory !== null && $this->directory !== '') ? $this->directory : '';
return ((string) $this->directory !== '') ? $this->directory : '';
}
private function controllerName(): string

View File

@ -560,7 +560,7 @@ class RouteCollection implements RouteCollectionInterface
*/
public function getRoutes(?string $verb = null, bool $includeWildcard = true): array
{
if ($verb === null || $verb === '') {
if ((string) $verb === '') {
$verb = $this->getHTTPVerb();
}
@ -609,7 +609,7 @@ class RouteCollection implements RouteCollectionInterface
{
$options = $this->loadRoutesOptions($verb);
return $from ? $options[$from] ?? [] : $options;
return ((string) $from !== '') ? $options[$from] ?? [] : $options;
}
/**
@ -779,7 +779,7 @@ class RouteCollection implements RouteCollectionInterface
$callback = array_pop($params);
if ($params && is_array($params[0])) {
if ($params !== [] && is_array($params[0])) {
$options = array_shift($params);
if (isset($options['filter'])) {
@ -1329,7 +1329,7 @@ class RouteCollection implements RouteCollectionInterface
$patterns = $matches[0];
foreach ($patterns as $index => $pattern) {
if (! preg_match('#^' . $pattern . '$#u', $params[$index])) {
if (preg_match('#^' . $pattern . '$#u', $params[$index]) !== 1) {
throw RouterException::forInvalidParameterType();
}
@ -1391,7 +1391,7 @@ class RouteCollection implements RouteCollectionInterface
// or maybe $placeholder is not a placeholder, but a regex.
$pattern = $this->placeholders[$placeholderName] ?? $placeholder;
if (! preg_match('#^' . $pattern . '$#u', (string) $params[$index])) {
if (preg_match('#^' . $pattern . '$#u', (string) $params[$index]) !== 1) {
throw RouterException::forInvalidParameterType();
}
@ -1416,14 +1416,14 @@ class RouteCollection implements RouteCollectionInterface
}
// Check invalid locale
if ($locale !== null) {
if ((string) $locale !== '') {
$config = config(App::class);
if (! in_array($locale, $config->supportedLocales, true)) {
$locale = null;
}
}
if ($locale === null) {
if ((string) $locale === '') {
$locale = service('request')->getLocale();
}

View File

@ -75,7 +75,7 @@ class PostgreHandler extends DatabaseHandler
protected function lockSession(string $sessionID): bool
{
$arg = "hashtext('{$sessionID}')" . ($this->matchIP ? ", hashtext('{$this->ipAddress}')" : '');
if ($this->db->simpleQuery("SELECT pg_advisory_lock({$arg})")) {
if ($this->db->simpleQuery("SELECT pg_advisory_lock({$arg})") !== false) {
$this->lock = $arg;
return true;
@ -93,7 +93,7 @@ class PostgreHandler extends DatabaseHandler
return true;
}
if ($this->db->simpleQuery("SELECT pg_advisory_unlock({$this->lock})")) {
if ($this->db->simpleQuery("SELECT pg_advisory_unlock({$this->lock})") !== false) {
$this->lock = false;
return true;

View File

@ -290,7 +290,7 @@ class FileHandler extends BaseHandler
while (($file = readdir($directory)) !== false) {
// If the filename doesn't match this pattern, it's either not a session file or is not ours
if (! preg_match($pattern, $file)
if (preg_match($pattern, $file) !== 1
|| ! is_file($this->savePath . DIRECTORY_SEPARATOR . $file)
|| ($mtime = filemtime($this->savePath . DIRECTORY_SEPARATOR . $file)) === false
|| $mtime > $ts

View File

@ -93,12 +93,12 @@ class MemcachedHandler extends BaseHandler
}
if (
! preg_match_all(
preg_match_all(
'#,?([^,:]+)\:(\d{1,5})(?:\:(\d+))?#',
$this->savePath,
$matches,
PREG_SET_ORDER
)
) === 0
) {
$this->memcached = null;
$this->logger->error('Session: Invalid Memcached save path format: ' . $this->savePath);
@ -267,7 +267,7 @@ class MemcachedHandler extends BaseHandler
$attempt = 0;
do {
if ($this->memcached->get($lockKey)) {
if ($this->memcached->get($lockKey) !== false) {
sleep(1);
continue;

View File

@ -234,7 +234,7 @@ class Session implements SessionInterface
// Sanitize the cookie, because apparently PHP doesn't do that for userspace handlers
if (isset($_COOKIE[$this->config->cookieName])
&& (! is_string($_COOKIE[$this->config->cookieName]) || ! preg_match('#\A' . $this->sidRegexp . '\z#', $_COOKIE[$this->config->cookieName]))
&& (! is_string($_COOKIE[$this->config->cookieName]) || preg_match('#\A' . $this->sidRegexp . '\z#', $_COOKIE[$this->config->cookieName]) !== 1)
) {
unset($_COOKIE[$this->config->cookieName]);
}

View File

@ -238,7 +238,7 @@ abstract class CIUnitTestCase extends TestCase
{
parent::setUp();
if (! $this->app) {
if (! $this->app instanceof CodeIgniter) {
$this->app = $this->createApplication();
}
@ -374,7 +374,7 @@ abstract class CIUnitTestCase extends TestCase
{
$this->assertTrue(
TestLogger::didLog($level, $logMessage, false),
$message ?: sprintf(
$message !== '' ? $message : sprintf(
'Failed asserting that logs have a record of message containing "%s" with level "%s".',
$logMessage,
$level

View File

@ -189,7 +189,9 @@ trait FeatureTestTrait
$request = $this->setRequestBody($request, $params);
// Initialize the RouteCollection
if (! $routes = $this->routes) {
$routes = $this->routes;
if ($routes !== []) {
$routes = service('routes')->loadRoutes();
}

View File

@ -221,7 +221,9 @@ trait FilterTestTrait
$this->filters->reset();
if ($routeFilters = $this->collection->getFiltersForRoute($route)) {
$routeFilters = $this->collection->getFiltersForRoute($route);
if ($routeFilters !== []) {
$this->filters->enableFilters($routeFilters, $position);
}

View File

@ -29,9 +29,9 @@ trait ConditionalTrait
*/
public function when($condition, callable $callback, ?callable $defaultCallback = null): self
{
if ($condition) {
if ($condition !== '' && $condition !== false && $condition !== null) {
$callback($this, $condition);
} elseif ($defaultCallback) {
} elseif ($defaultCallback !== null) {
$defaultCallback($this);
}
@ -52,9 +52,9 @@ trait ConditionalTrait
*/
public function whenNot($condition, callable $callback, ?callable $defaultCallback = null): self
{
if (! $condition) {
if ($condition === '' || $condition === null || $condition === false || $condition === '0') {
$callback($this, $condition);
} elseif ($defaultCallback) {
} elseif ($defaultCallback !== null) {
$defaultCallback($this);
}

View File

@ -171,7 +171,7 @@ class Typography
}
// No opening block level tag? Add it if needed.
if (! preg_match('/^\s*<(?:' . $this->blockElements . ')/i', $str)) {
if (preg_match('/^\s*<(?:' . $this->blockElements . ')/i', $str) !== 1) {
$str = preg_replace('/^(.*?)<(' . $this->blockElements . ')/i', '<p>$1</p><$2', $str);
}

View File

@ -124,7 +124,7 @@ class Rules
if (
$whereField !== null && $whereField !== ''
&& $whereValue !== null && $whereValue !== ''
&& ! preg_match('/^\{(\w+)\}$/', $whereValue)
&& preg_match('/^\{(\w+)\}$/', $whereValue) !== 1
) {
$builder = $builder->where($whereField, $whereValue);
}
@ -167,7 +167,7 @@ class Rules
if (
$ignoreField !== null && $ignoreField !== ''
&& $ignoreValue !== null && $ignoreValue !== ''
&& ! preg_match('/^\{(\w+)\}$/', $ignoreValue)
&& preg_match('/^\{(\w+)\}$/', $ignoreValue) !== 1
) {
$builder = $builder->where("{$ignoreField} !=", $ignoreValue);
}

View File

@ -180,7 +180,7 @@ class Validation implements ValidationInterface
);
// if keys not found
$values = $values ?: [$field => null];
$values = $values !== [] ? $values : [$field => null];
} else {
$values = dot_array_search($field, $data);
}

View File

@ -613,7 +613,7 @@ class Parser extends View
$escape = false;
}
// If no `esc` filter is found, then we'll need to add one.
elseif (! preg_match('/\s+esc/u', $key)) {
elseif (preg_match('/\s+esc/u', $key) !== 1) {
$escape = 'html';
}
@ -691,7 +691,7 @@ class Parser extends View
* $matches[1] = all parameters string in opening tag
* $matches[2] = content between the tags to send to the plugin.
*/
if (! preg_match_all($pattern, $template, $matches, PREG_SET_ORDER)) {
if (preg_match_all($pattern, $template, $matches, PREG_SET_ORDER) === 0) {
continue;
}

View File

@ -333,7 +333,7 @@ class Table
$out = $this->template['table_open'] . $this->newline;
// Add any caption here
if ($this->caption) {
if (isset($this->caption) && $this->caption !== '') {
$out .= '<caption>' . $this->caption . '</caption>' . $this->newline;
}

View File

@ -99,8 +99,7 @@ class Migration_Create_test_tables extends Migration
unset(
$dataTypeFields['type_set'],
$dataTypeFields['type_mediumtext'],
$dataTypeFields['type_double'],
$dataTypeFields['type_blob']
$dataTypeFields['type_double']
);
}

View File

@ -26,7 +26,7 @@ use LogicException;
* @property string $name
* @property Time|null $updated_at
*/
class CustomUser
final class CustomUser
{
private function __construct(
private readonly int $id,
@ -40,7 +40,7 @@ class CustomUser
public static function reconstruct(array $data): static
{
return new static(
return new self(
$data['id'],
$data['name'],
$data['email'],

View File

@ -104,8 +104,8 @@ abstract class AbstractGetFieldDataTestCase extends CIUnitTestCase
$this->forge->dropTable($this->table, true);
// missing types:
// TINYINT,MEDIUMINT,BIT,YEAR,BINARY,VARBINARY,TINYTEXT,LONGTEXT,
// JSON,Spatial data types
// TINYINT,MEDIUMINT,BIT,YEAR,BINARY,VARBINARY (BLOB more or less handles these two),
// TINYTEXT,LONGTEXT,JSON,Spatial data types
// `id` must be INTEGER else SQLite3 error on not null for autoincrement field.
$fields = [
'id' => ['type' => 'INTEGER', 'constraint' => 20, 'auto_increment' => true],
@ -138,8 +138,7 @@ abstract class AbstractGetFieldDataTestCase extends CIUnitTestCase
$fields['type_enum'],
$fields['type_set'],
$fields['type_mediumtext'],
$fields['type_double'],
$fields['type_blob']
$fields['type_double']
);
}
@ -147,8 +146,7 @@ abstract class AbstractGetFieldDataTestCase extends CIUnitTestCase
unset(
$fields['type_set'],
$fields['type_mediumtext'],
$fields['type_double'],
$fields['type_blob']
$fields['type_double']
);
}

View File

@ -212,6 +212,13 @@ final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase
'default' => null,
],
15 => (object) [
'name' => 'type_blob',
'type' => 'bytea',
'max_length' => null,
'nullable' => true,
'default' => null,
],
16 => (object) [
'name' => 'type_boolean',
'type' => 'boolean',
'max_length' => null,

View File

@ -269,4 +269,39 @@ final class PreparedQueryTest extends CIUnitTestCase
$this->query->close();
}
public function testInsertBinaryData(): void
{
$params = [];
if ($this->db->DBDriver === 'SQLSRV') {
$params = [0 => SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY)];
}
$this->query = $this->db->prepare(static fn ($db) => $db->table('type_test')->insert([
'type_blob' => 'binary',
]), $params);
$fileContent = file_get_contents(TESTPATH . '_support/Images/EXIFsamples/landscape_0.jpg');
$this->assertTrue($this->query->execute($fileContent));
$id = $this->db->DBDriver === 'SQLSRV'
// It seems like INSERT for a prepared statement is run in the
// separate execution context even though it's part of the same session
? (int) ($this->db->query('SELECT @@IDENTITY AS insert_id')->getRow()->insert_id ?? 0)
: $this->db->insertID();
$builder = $this->db->table('type_test');
if ($this->db->DBDriver === 'Postgre') {
$file = $builder->select("ENCODE(type_blob, 'base64') AS type_blob")->where('id', $id)->get()->getRow();
$file = base64_decode($file->type_blob, true);
} elseif ($this->db->DBDriver === 'OCI8') {
$file = $builder->select('type_blob')->where('id', $id)->get()->getRow();
$file = $file->type_blob->load();
} else {
$file = $builder->select('type_blob')->where('id', $id)->get()->getRow();
$file = $file->type_blob;
}
$this->assertSame(strlen($fileContent), strlen($file));
}
}

View File

@ -219,6 +219,13 @@ final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase
'default' => null,
],
16 => (object) [
'name' => 'type_blob',
'type' => 'varbinary',
'max_length' => 'max',
'nullable' => true,
'default' => null,
],
17 => (object) [
'name' => 'type_boolean',
'type' => 'bit',
'max_length' => null,

View File

@ -44,7 +44,7 @@ final class EmailTest extends CIUnitTestCase
}
/**
* @param mixed $autoClear
* @param bool $autoClear
*/
#[DataProvider('provideEmailSendWithClearance')]
public function testEmailSendWithClearance($autoClear): void

View File

@ -20,6 +20,8 @@ use CodeIgniter\Log\Exceptions\LogException;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\Mock\MockLogger as LoggerConfig;
use PHPUnit\Framework\Attributes\Group;
use ReflectionMethod;
use ReflectionNamedType;
use Tests\Support\Log\Handlers\TestHandler;
use TypeError;
@ -67,7 +69,10 @@ final class LoggerTest extends CIUnitTestCase
$logger = new Logger($config);
$this->assertNull($logger->log('debug', ''));
$refMethod = new ReflectionMethod($logger, 'log');
$this->assertTrue($refMethod->hasReturnType());
$this->assertInstanceOf(ReflectionNamedType::class, $refMethod->getReturnType());
$this->assertSame('void', $refMethod->getReturnType()->getName());
}
public function testLogActuallyLogs(): void

View File

@ -180,8 +180,8 @@ final class FindModelTest extends LiveModelTestCase
}
/**
* @param mixed $groupBy
* @param mixed $total
* @param bool $groupBy
* @param int $total
*/
#[DataProvider('provideFirstAggregate')]
public function testFirstAggregate($groupBy, $total): void
@ -215,8 +215,8 @@ final class FindModelTest extends LiveModelTestCase
}
/**
* @param mixed $aggregate
* @param mixed $groupBy
* @param bool $aggregate
* @param bool $groupBy
*/
#[DataProvider('provideAggregateAndGroupBy')]
public function testFirstRespectsSoftDeletes($aggregate, $groupBy): void
@ -260,8 +260,8 @@ final class FindModelTest extends LiveModelTestCase
}
/**
* @param mixed $aggregate
* @param mixed $groupBy
* @param bool $aggregate
* @param bool $groupBy
*/
#[DataProvider('provideAggregateAndGroupBy')]
public function testFirstRecoverTempUseSoftDeletes($aggregate, $groupBy): void

View File

@ -41,7 +41,8 @@ Bugs Fixed
- **Validation:** Fixed a bug where complex language strings were not properly handled.
- **CURLRequest:** Added support for handling proxy responses using HTTP versions other than 1.1.
- **Database:** Fixed a bug that caused ``Postgre\Connection::reconnect()`` method to throw an error when the connection had not yet been established.
- **Model** Fixed a bug that caused the ``Model::getIdValue()`` method to not correctly recognize the primary key in the ``Entity`` object if a data mapping for the primary key was used.
- **Model:** Fixed a bug that caused the ``Model::getIdValue()`` method to not correctly recognize the primary key in the ``Entity`` object if a data mapping for the primary key was used.
- **Database:** Fixed a bug in prepared statement to correctly handle binary data.
See the repo's
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_

View File

@ -246,6 +246,8 @@ array through in the second parameter:
.. literalinclude:: queries/018.php
.. note:: Currently, the only database that actually uses the array of option is SQLSRV.
Executing the Query
===================

View File

@ -1,63 +0,0 @@
# total 12 errors
parameters:
ignoreErrors:
-
message: '#^Only booleans are allowed in &&, array\|int\|string\|null given on the left side\.$#'
count: 1
path: ../../system/BaseModel.php
-
message: '#^Only booleans are allowed in &&, array\|string\|null given on the left side\.$#'
count: 1
path: ../../system/CLI/CLI.php
-
message: '#^Only booleans are allowed in &&, string given on the left side\.$#'
count: 1
path: ../../system/Cache/Handlers/BaseHandler.php
-
message: '#^Only booleans are allowed in &&, int given on the left side\.$#'
count: 1
path: ../../system/Commands/Server/Serve.php
-
message: '#^Only booleans are allowed in &&, string\|null given on the left side\.$#'
count: 3
path: ../../system/Common.php
-
message: '#^Only booleans are allowed in &&, string given on the left side\.$#'
count: 1
path: ../../system/Database/Forge.php
-
message: '#^Only booleans are allowed in &&, int given on the left side\.$#'
count: 1
path: ../../system/Database/MySQLi/Connection.php
-
message: '#^Only booleans are allowed in &&, int given on the left side\.$#'
count: 1
path: ../../system/Email/Email.php
-
message: '#^Only booleans are allowed in &&, string\|null given on the left side\.$#'
count: 1
path: ../../system/HTTP/Response.php
-
message: '#^Only booleans are allowed in &&, array given on the left side\.$#'
count: 1
path: ../../system/Model.php
-
message: '#^Only booleans are allowed in &&, string\|null given on the left side\.$#'
count: 1
path: ../../system/Model.php
-
message: '#^Only booleans are allowed in &&, array\<int\|string, array\|\(callable\)\> given on the left side\.$#'
count: 1
path: ../../system/Router/RouteCollection.php

View File

@ -1,43 +0,0 @@
# total 8 errors
parameters:
ignoreErrors:
-
message: '#^Only booleans are allowed in &&, array\<string, string\> given on the right side\.$#'
count: 1
path: ../../system/BaseModel.php
-
message: '#^Only booleans are allowed in &&, list\<string\> given on the right side\.$#'
count: 1
path: ../../system/CLI/CLI.php
-
message: '#^Only booleans are allowed in &&, int\<0, max\> given on the right side\.$#'
count: 1
path: ../../system/Database/MigrationRunner.php
-
message: '#^Only booleans are allowed in &&, string given on the right side\.$#'
count: 1
path: ../../system/Email/Email.php
-
message: '#^Only booleans are allowed in &&, array\<mixed, mixed\> given on the right side\.$#'
count: 2
path: ../../system/HTTP/Files/FileCollection.php
-
message: '#^Only booleans are allowed in &&, string\|null given on the right side\.$#'
count: 1
path: ../../system/HTTP/Response.php
-
message: '#^Only booleans are allowed in &&, array\<string, string\> given on the right side\.$#'
count: 4
path: ../../system/HTTP/UserAgent.php
-
message: '#^Only booleans are allowed in &&, string given on the right side\.$#'
count: 2
path: ../../system/Model.php

View File

@ -1,63 +0,0 @@
# total 12 errors
parameters:
ignoreErrors:
-
message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#'
count: 1
path: ../../system/Cache/Handlers/PredisHandler.php
-
message: '#^Only booleans are allowed in a negated boolean, TWhenNot given\.$#'
count: 1
path: ../../system/Database/BaseBuilder.php
-
message: '#^Only booleans are allowed in a negated boolean, array given\.$#'
count: 1
path: ../../system/Database/MySQLi/Connection.php
-
message: '#^Only booleans are allowed in a negated boolean, string given\.$#'
count: 1
path: ../../system/Database/SQLite3/Connection.php
-
message: '#^Only booleans are allowed in a negated boolean, array\<string, array\<string, list\<string\>\>\> given\.$#'
count: 1
path: ../../system/Filters/Filters.php
-
message: '#^Only booleans are allowed in a negated boolean, int\<0, max\> given\.$#'
count: 1
path: ../../system/Helpers/form_helper.php
-
message: '#^Only booleans are allowed in a negated boolean, CodeIgniter\\CodeIgniter given\.$#'
count: 1
path: ../../system/Test/CIUnitTestCase.php
-
message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#'
count: 1
path: ../../tests/system/Email/EmailTest.php
-
message: '#^Only booleans are allowed in a negated boolean, CodeIgniter\\Router\\RouteCollection\|null given\.$#'
count: 1
path: ../../tests/system/HomeTest.php
-
message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#'
count: 2
path: ../../tests/system/Models/FindModelTest.php
-
message: '#^Only booleans are allowed in a negated boolean, CodeIgniter\\Router\\RouteCollection\|null given\.$#'
count: 1
path: ../../tests/system/Test/FeatureTestAutoRoutingImprovedTest.php
-
message: '#^Only booleans are allowed in a negated boolean, CodeIgniter\\Router\\RouteCollection\|null given\.$#'
count: 1
path: ../../tests/system/Test/FeatureTestTraitTest.php

View File

@ -1,13 +0,0 @@
# total 2 errors
parameters:
ignoreErrors:
-
message: '#^Only booleans are allowed in \|\|, string given on the left side\.$#'
count: 1
path: ../../system/CLI/CLI.php
-
message: '#^Only booleans are allowed in \|\|, string\|null given on the left side\.$#'
count: 2
path: ../../system/CLI/CLI.php

View File

@ -1,18 +0,0 @@
# total 3 errors
parameters:
ignoreErrors:
-
message: '#^Only booleans are allowed in \|\|, string\|null given on the right side\.$#'
count: 3
path: ../../system/CLI/CLI.php
-
message: '#^Only booleans are allowed in \|\|, int given on the right side\.$#'
count: 1
path: ../../system/HotReloader/HotReloader.php
-
message: '#^Only booleans are allowed in \|\|, mixed given on the right side\.$#'
count: 1
path: ../../tests/system/Models/FindModelTest.php

View File

@ -3,7 +3,7 @@
parameters:
ignoreErrors:
-
message: '#^Assigning non\-falsy\-string directly on offset ''HTTP_HOST'' of \$_SERVER is discouraged\.$#'
message: '#^Assigning string directly on offset ''HTTP_HOST'' of \$_SERVER is discouraged\.$#'
count: 1
path: ../../system/Commands/Utilities/Routes.php

View File

@ -1,8 +0,0 @@
# total 1 error
parameters:
ignoreErrors:
-
message: '#^Only booleans are allowed in an elseif condition, \(callable\)\|null given\.$#'
count: 2
path: ../../system/Database/BaseBuilder.php

View File

@ -1,4 +1,4 @@
# total 17 errors
# total 1 error
parameters:
ignoreErrors:
@ -6,83 +6,3 @@ parameters:
message: '#^Only booleans are allowed in an if condition, mixed given\.$#'
count: 1
path: ../../system/CLI/CLI.php
-
message: '#^Only booleans are allowed in an if condition, Config\\Routing given\.$#'
count: 1
path: ../../system/Commands/Utilities/Routes.php
-
message: '#^Only booleans are allowed in an if condition, string\|null given\.$#'
count: 3
path: ../../system/Commands/Utilities/Routes.php
-
message: '#^Only booleans are allowed in an if condition, TWhen given\.$#'
count: 1
path: ../../system/Database/BaseBuilder.php
-
message: '#^Only booleans are allowed in an if condition, string\|null given\.$#'
count: 1
path: ../../system/Database/MigrationRunner.php
-
message: '#^Only booleans are allowed in an if condition, string\|null given\.$#'
count: 1
path: ../../system/Email/Email.php
-
message: '#^Only booleans are allowed in an if condition, array\|string\|null given\.$#'
count: 2
path: ../../system/Encryption/Handlers/OpenSSLHandler.php
-
message: '#^Only booleans are allowed in an if condition, array\<string, string\> given\.$#'
count: 1
path: ../../system/HTTP/RedirectResponse.php
-
message: '#^Only booleans are allowed in an if condition, string given\.$#'
count: 1
path: ../../system/HTTP/Request.php
-
message: '#^Only booleans are allowed in an if condition, string\|null given\.$#'
count: 2
path: ../../system/HTTP/Response.php
-
message: '#^Only booleans are allowed in an if condition, array\|int\|string\|null given\.$#'
count: 2
path: ../../system/Model.php
-
message: '#^Only booleans are allowed in an if condition, object\|string\|null given\.$#'
count: 1
path: ../../system/RESTful/BaseResource.php
-
message: '#^Only booleans are allowed in an if condition, mixed given\.$#'
count: 2
path: ../../system/Session/Handlers/Database/PostgreHandler.php
-
message: '#^Only booleans are allowed in an if condition, mixed given\.$#'
count: 1
path: ../../system/Session/Handlers/MemcachedHandler.php
-
message: '#^Only booleans are allowed in an if condition, string\|null given\.$#'
count: 1
path: ../../system/View/Table.php
-
message: '#^Only booleans are allowed in an if condition, mixed given\.$#'
count: 5
path: ../../tests/system/Models/FindModelTest.php
-
message: '#^Only booleans are allowed in an if condition, list\<string\> given\.$#'
count: 1
path: ../../tests/system/Test/FilterTestTraitTest.php

View File

@ -1,12 +1,7 @@
includes:
- argument.type.neon
- assign.propertyType.neon
- booleanAnd.leftNotBoolean.neon
- booleanAnd.rightAlwaysTrue.neon
- booleanAnd.rightNotBoolean.neon
- booleanNot.exprNotBoolean.neon
- booleanOr.leftNotBoolean.neon
- booleanOr.rightNotBoolean.neon
- class.notFound.neon
- codeigniter.cacheHandlerInstance.neon
- codeigniter.configArgumentInstanceof.neon
@ -18,7 +13,6 @@ includes:
- codeigniter.superglobalAccessAssign.neon
- codeigniter.unknownServiceMethod.neon
- deadCode.unreachable.neon
- elseif.condNotBoolean.neon
- empty.notAllowed.neon
- empty.property.neon
- expr.resultUnused.neon
@ -37,13 +31,11 @@ includes:
- method.impossibleType.neon
- method.notFound.neon
- method.unused.neon
- method.void.neon
- missingType.callable.neon
- missingType.iterableValue.neon
- missingType.parameter.neon
- missingType.property.neon
- missingType.return.neon
- new.static.neon
- notIdentical.alwaysTrue.neon
- nullCoalesce.expr.neon
- nullCoalesce.property.neon
@ -62,7 +54,6 @@ includes:
- return.type.neon
- return.unusedType.neon
- staticMethod.notFound.neon
- ternary.condNotBoolean.neon
- ternary.shortNotAllowed.neon
- unset.offset.neon
- varTag.type.neon

View File

@ -1,18 +0,0 @@
# total 3 errors
parameters:
ignoreErrors:
-
message: '#^Result of method CodeIgniter\\Commands\\ListCommands\:\:listFull\(\) \(void\) is used\.$#'
count: 1
path: ../../system/Commands/ListCommands.php
-
message: '#^Result of method CodeIgniter\\Commands\\ListCommands\:\:listSimple\(\) \(void\) is used\.$#'
count: 1
path: ../../system/Commands/ListCommands.php
-
message: '#^Result of method CodeIgniter\\Log\\Logger\:\:log\(\) \(void\) is used\.$#'
count: 1
path: ../../tests/system/Log/LoggerTest.php

View File

@ -1,8 +0,0 @@
# total 1 error
parameters:
ignoreErrors:
-
message: '#^Unsafe usage of new static\(\)\.$#'
count: 1
path: ../../tests/_support/Entity/CustomUser.php

View File

@ -1,43 +0,0 @@
# total 8 errors
parameters:
ignoreErrors:
-
message: '#^Only booleans are allowed in a ternary operator condition, array\|null given\.$#'
count: 1
path: ../../system/BaseModel.php
-
message: '#^Only booleans are allowed in a ternary operator condition, string\|null given\.$#'
count: 1
path: ../../system/CLI/CLI.php
-
message: '#^Only booleans are allowed in a ternary operator condition, int\<0, max\> given\.$#'
count: 3
path: ../../system/Database/MigrationRunner.php
-
message: '#^Only booleans are allowed in a ternary operator condition, string\|null given\.$#'
count: 1
path: ../../system/Database/MigrationRunner.php
-
message: '#^Only booleans are allowed in a ternary operator condition, int\|null given\.$#'
count: 1
path: ../../system/HTTP/OutgoingRequest.php
-
message: '#^Only booleans are allowed in a ternary operator condition, string\|null given\.$#'
count: 1
path: ../../system/Helpers/text_helper.php
-
message: '#^Only booleans are allowed in a ternary operator condition, string\|null given\.$#'
count: 1
path: ../../system/Router/AutoRouter.php
-
message: '#^Only booleans are allowed in a ternary operator condition, string\|null given\.$#'
count: 1
path: ../../system/Router/RouteCollection.php

View File

@ -1,4 +1,4 @@
# total 34 errors
# total 27 errors
parameters:
ignoreErrors:
@ -17,16 +17,6 @@ parameters:
count: 1
path: ../../system/Commands/Utilities/Namespaces.php
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 1
path: ../../system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReader.php
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 1
path: ../../system/Commands/Utilities/Routes/ControllerMethodReader.php
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 2
@ -35,23 +25,8 @@ parameters:
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 4
path: ../../system/Config/Services.php
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 5
path: ../../system/Cookie/Cookie.php
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 1
path: ../../system/Database/BaseConnection.php
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 1
path: ../../system/Database/Postgre/Connection.php
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 1
@ -79,12 +54,7 @@ parameters:
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 1
path: ../../system/HTTP/Files/UploadedFile.php
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 5
count: 2
path: ../../system/HTTP/Response.php
-
@ -94,12 +64,12 @@ parameters:
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 4
count: 1
path: ../../system/I18n/Time.php
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 4
count: 1
path: ../../system/I18n/TimeLegacy.php
-
@ -117,11 +87,6 @@ parameters:
count: 1
path: ../../system/Session/Session.php
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 1
path: ../../system/Test/CIUnitTestCase.php
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 2
@ -129,7 +94,7 @@ parameters:
-
message: '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
count: 2
count: 1
path: ../../system/Validation/Validation.php
-

View File

@ -178,7 +178,7 @@ final class UnderscoreToCamelCaseVariableNameRector extends AbstractRector
return;
}
if (! preg_match(sprintf(self::PARAM_NAME_REGEX, $variableName), $docCommentText)) {
if (preg_match(sprintf(self::PARAM_NAME_REGEX, $variableName), $docCommentText) !== 1) {
return;
}