Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions app/Config/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@

use CodeIgniter\Router\RouteCollection;

/**
* @var RouteCollection $routes
*/
/** @var RouteCollection $routes */
$routes->get('/', 'Home::index');
10 changes: 2 additions & 8 deletions app/Config/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
use CodeIgniter\Config\View as BaseView;
use CodeIgniter\View\ViewDecoratorInterface;

/**
* @phpstan-type parser_callable (callable(mixed): mixed)
* @phpstan-type parser_callable_string (callable(mixed): mixed)&string
*/
class View extends BaseView
{
/**
Expand All @@ -34,8 +30,7 @@ class View extends BaseView
* { title|esc(js) }
* { created_on|date(Y-m-d)|esc(attr) }
*
* @var array<string, string>
* @phpstan-var array<string, parser_callable_string>
* @var array<string, (callable(mixed): mixed)&string>
*/
public $filters = [];

Expand All @@ -44,8 +39,7 @@ class View extends BaseView
* by the core Parser by creating aliases that will be replaced with
* any callable. Can be single or tag pair.
*
* @var array<string, callable|list<string>|string>
* @phpstan-var array<string, list<parser_callable_string>|parser_callable_string|parser_callable>
* @var array<string, (callable(mixed): mixed)|((callable(mixed): mixed)&string)|list<(callable(mixed): mixed)&string>>
*/
public $plugins = [];

Expand Down
72 changes: 1 addition & 71 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="6.14.3@d0b040a91f280f071c1abcb1b77ce3822058725a">
<file src="app/Config/View.php">
<UndefinedDocblockClass>
<code><![CDATA[array<string, list<parser_callable_string>|parser_callable_string|parser_callable>]]></code>
<code><![CDATA[array<string, list<parser_callable_string>|parser_callable_string|parser_callable>]]></code>
<code><![CDATA[array<string, parser_callable_string>]]></code>
<code><![CDATA[public $filters = [];]]></code>
<code><![CDATA[public $plugins = [];]]></code>
<code><![CDATA[public $plugins = [];]]></code>
</UndefinedDocblockClass>
</file>
<file src="system/Config/View.php">
<UndefinedDocblockClass>
<code><![CDATA[array<string, array<parser_callable_string>|parser_callable_string|parser_callable>]]></code>
<code><![CDATA[array<string, array<parser_callable_string>|parser_callable_string|parser_callable>]]></code>
<code><![CDATA[array<string, parser_callable_string>]]></code>
</UndefinedDocblockClass>
</file>
<files psalm-version="6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac">
<file src="system/Database/OCI8/Connection.php">
<UndefinedConstant>
<code><![CDATA[OCI_COMMIT_ON_SUCCESS]]></code>
Expand Down Expand Up @@ -73,14 +56,6 @@
<code><![CDATA[$message]]></code>
</NoValue>
</file>
<file src="system/View/Parser.php">
<UndefinedDocblockClass>
<code><![CDATA[array<string, array<parser_callable_string>|parser_callable_string|parser_callable>]]></code>
<code><![CDATA[array<string, array<parser_callable_string>|parser_callable_string|parser_callable>]]></code>
<code><![CDATA[protected $plugins = [];]]></code>
<code><![CDATA[protected $plugins = [];]]></code>
</UndefinedDocblockClass>
</file>
<file src="tests/_support/Config/Filters.php">
<UndefinedGlobalVariable>
<code><![CDATA[$filters]]></code>
Expand Down Expand Up @@ -136,51 +111,6 @@
<code><![CDATA[$_SESSION['_ci_old_input']]]></code>
</EmptyArrayAccess>
</file>
<file src="tests/system/Models/InsertModelTest.php">
<InaccessibleProperty>
<code><![CDATA[$entity->country]]></code>
<code><![CDATA[$entity->created_at]]></code>
<code><![CDATA[$entity->deleted]]></code>
<code><![CDATA[$entity->email]]></code>
<code><![CDATA[$entity->name]]></code>
<code><![CDATA[$entityTwo->country]]></code>
<code><![CDATA[$entityTwo->created_at]]></code>
<code><![CDATA[$entityTwo->deleted]]></code>
<code><![CDATA[$entityTwo->email]]></code>
<code><![CDATA[$entityTwo->name]]></code>
</InaccessibleProperty>
</file>
<file src="tests/system/Models/SaveModelTest.php">
<InaccessibleProperty>
<code><![CDATA[$entity->country]]></code>
<code><![CDATA[$entity->created_at]]></code>
<code><![CDATA[$entity->created_at]]></code>
<code><![CDATA[$entity->deleted]]></code>
<code><![CDATA[$entity->email]]></code>
<code><![CDATA[$entity->name]]></code>
<code><![CDATA[$entity->name]]></code>
<code><![CDATA[$entity->name]]></code>
<code><![CDATA[$entity->name]]></code>
</InaccessibleProperty>
</file>
<file src="tests/system/Models/UpdateModelTest.php">
<InaccessibleProperty>
<code><![CDATA[$entity->country]]></code>
<code><![CDATA[$entity->deleted]]></code>
<code><![CDATA[$entity->email]]></code>
<code><![CDATA[$entity->id]]></code>
<code><![CDATA[$entity->name]]></code>
<code><![CDATA[$entity1->country]]></code>
<code><![CDATA[$entity1->country]]></code>
<code><![CDATA[$entity1->deleted]]></code>
<code><![CDATA[$entity1->id]]></code>
<code><![CDATA[$entity1->name]]></code>
<code><![CDATA[$entity2->country]]></code>
<code><![CDATA[$entity2->deleted]]></code>
<code><![CDATA[$entity2->id]]></code>
<code><![CDATA[$entity2->name]]></code>
</InaccessibleProperty>
</file>
<file src="tests/system/Test/ControllerTestTraitTest.php">
<UndefinedClass>
<code><![CDATA[NeverHeardOfIt]]></code>
Expand Down
4 changes: 1 addition & 3 deletions system/Autoloader/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,7 @@ protected function discoverComposerNamespaces()
return;
}

/**
* @var ClassLoader $composer
*/
/** @var ClassLoader $composer */
$composer = include $this->composerPath;
$paths = $composer->getPrefixesPsr4();
$classes = $composer->getClassMap();
Expand Down
4 changes: 1 addition & 3 deletions system/CLI/GeneratorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,7 @@ private function normalizeInputClassName(): string

$component = singular($this->component);

/**
* @see https://regex101.com/r/a5KNCR/2
*/
/** @see https://regex101.com/r/a5KNCR/2 */
$pattern = sprintf('/([a-z][a-z0-9_\/\\\\]+)(%s)$/i', $component);

if (preg_match($pattern, $class, $matches) === 1) {
Expand Down
7 changes: 3 additions & 4 deletions system/Cache/Handlers/PredisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ public function get(string $key): mixed
}

return match ($data['__ci_type']) {
'array', 'object' => unserialize($data['__ci_value']),
// Yes, 'double' is returned and NOT 'float'
'array', 'object' => unserialize($data['__ci_value']),
'boolean', 'integer', 'double', 'string', 'NULL' => settype($data['__ci_value'], $data['__ci_type']) ? $data['__ci_value'] : null,
default => null,
default => null,
};
}

Expand All @@ -111,7 +110,7 @@ public function save(string $key, mixed $value, int $ttl = 60): bool

case 'boolean':
case 'integer':
case 'double': // Yes, 'double' is returned and NOT 'float'
case 'double':
case 'string':
case 'NULL':
break;
Expand Down
7 changes: 3 additions & 4 deletions system/Cache/Handlers/RedisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,9 @@ public function get(string $key): mixed
}

return match ($data['__ci_type']) {
'array', 'object' => unserialize($data['__ci_value']),
// Yes, 'double' is returned and NOT 'float'
'array', 'object' => unserialize($data['__ci_value']),
'boolean', 'integer', 'double', 'string', 'NULL' => settype($data['__ci_value'], $data['__ci_type']) ? $data['__ci_value'] : null,
default => null,
default => null,
};
}

Expand All @@ -127,7 +126,7 @@ public function save(string $key, mixed $value, int $ttl = 60): bool

case 'boolean':
case 'integer':
case 'double': // Yes, 'double' is returned and NOT 'float'
case 'double':
case 'string':
case 'NULL':
break;
Expand Down
4 changes: 1 addition & 3 deletions system/Commands/Translation/LocalizationSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ private function process(string $originalLocale, string $targetLocale): int
),
);

/**
* @var array<non-empty-string, SplFileInfo> $files
*/
/** @var array<non-empty-string, SplFileInfo> $files */
$files = iterator_to_array($iterator, true);
ksort($files);

Expand Down
24 changes: 6 additions & 18 deletions system/Config/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@
use CodeIgniter\View\ViewDecoratorInterface;

/**
* View configuration
*
* @phpstan-type parser_callable (callable(mixed): mixed)
* @phpstan-type parser_callable_string (callable(mixed): mixed)&string
* View configuration.
*/
class View extends BaseConfig
{
/**
* When false, the view method will clear the data between each
* call.
* When false, the view method will clear the data between each call.
*
* @var bool
*/
Expand All @@ -41,8 +37,7 @@ class View extends BaseConfig
*
* @psalm-suppress UndefinedDocblockClass
*
* @var array<string, string>
* @phpstan-var array<string, parser_callable_string>
* @var array<string, (callable(mixed): mixed)&string>
*/
public $filters = [];

Expand All @@ -53,18 +48,14 @@ class View extends BaseConfig
*
* @psalm-suppress UndefinedDocblockClass
*
* @var array<string, callable|list<string>|string>
* @phpstan-var array<string, list<parser_callable_string>|parser_callable_string|parser_callable>
* @var array<string, (callable(mixed): mixed)|((callable(mixed): mixed)&string)|list<(callable(mixed): mixed)&string>>
*/
public $plugins = [];

/**
* Built-in View filters.
*
* @psalm-suppress UndefinedDocblockClass
*
* @var array<string, string>
* @phpstan-var array<string, parser_callable_string>
* @var array<string, (callable(mixed): mixed)&string>
*/
protected $coreFilters = [
'abs' => '\abs',
Expand Down Expand Up @@ -93,10 +84,7 @@ class View extends BaseConfig
/**
* Built-in View plugins.
*
* @psalm-suppress UndefinedDocblockClass
*
* @var array<string, callable|list<string>|string>
* @phpstan-var array<string, array<parser_callable_string>|parser_callable_string|parser_callable>
* @var array<string, (callable(mixed): mixed)|((callable(mixed): mixed)&string)|list<(callable(mixed): mixed)&string>>
*/
protected $corePlugins = [
'csp_script_nonce' => '\CodeIgniter\View\Plugins::cspScriptNonce',
Expand Down
4 changes: 1 addition & 3 deletions system/Cookie/CookieStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ class CookieStore implements Countable, IteratorAggregate
*/
public static function fromCookieHeaders(array $headers, bool $raw = false)
{
/**
* @var list<Cookie> $cookies
*/
/** @var list<Cookie> $cookies */
$cookies = array_filter(array_map(static function (string $header) use ($raw) {
try {
return Cookie::fromHeaderString($header, $raw);
Expand Down
4 changes: 1 addition & 3 deletions system/DataCaster/Cast/DatetimeCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ public static function get(
throw new InvalidArgumentException($message);
}

/**
* @see https://www.php.net/manual/en/datetimeimmutable.createfromformat.php#datetimeimmutable.createfromformat.parameters
*/
/** @see https://www.php.net/manual/en/datetimeimmutable.createfromformat.php#datetimeimmutable.createfromformat.parameters */
$format = self::getDateTimeFormat($params, $helper);

return Time::createFromFormat($format, $value);
Expand Down
4 changes: 1 addition & 3 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,7 @@ public function __construct($tableName, ConnectionInterface $db, ?array $options
throw new DatabaseException('A table must be specified when creating a new Query Builder.');
}

/**
* @var BaseConnection $db
*/
/** @var BaseConnection $db */
$this->db = $db;

if ($tableName instanceof TableName) {
Expand Down
4 changes: 1 addition & 3 deletions system/Database/BaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -795,9 +795,7 @@ public function query(string $sql, $binds = null, bool $setEscapeFlags = true, s
$this->initialize();
}

/**
* @var Query $query
*/
/** @var Query $query */
$query = new $queryClass($this);

$query->setQuery($sql, $binds, $setEscapeFlags);
Expand Down
4 changes: 1 addition & 3 deletions system/Debug/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,7 @@ protected function roundTo(float $number, int $increments = 5): float
*/
public function prepare(?RequestInterface $request = null, ?ResponseInterface $response = null): void
{
/**
* @var IncomingRequest|null $request
*/
/** @var IncomingRequest|null $request */
if (CI_DEBUG && ! is_cli()) {
if ($this->hasNativeHeaderConflict()) {
return;
Expand Down
4 changes: 1 addition & 3 deletions system/Helpers/filesystem_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ function directory_mirror(string $originDir, string $targetDir, bool $overwrite

$dirLen = strlen($originDir);

/**
* @var SplFileInfo $file
*/
/** @var SplFileInfo $file */
foreach (new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($originDir, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST,
Expand Down
6 changes: 1 addition & 5 deletions system/Helpers/kint_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,14 @@ function d(...$vars)
/**
* Provides a backtrace to the current execution point, from Kint.
*/
/**
* trace function
*/
function trace(): void
{
Kint::$aliases[] = 'trace';
Kint::trace();
}
} else {
// In case that Kint is not loaded.
/**
* trace function
* Generic trace function in case that Kint is not loaded.
*
* @return int
*/
Expand Down
4 changes: 1 addition & 3 deletions system/Pager/Pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,7 @@ public function getPageURI(?int $page = null, string $group = 'default', bool $r
{
$this->ensureGroup($group);

/**
* @var URI $uri
*/
/** @var URI $uri */
$uri = $this->groups[$group]['uri'];

$segment = $this->segment[$group] ?? 0;
Expand Down
6 changes: 1 addition & 5 deletions system/View/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
/**
* Class for parsing pseudo-vars
*
* @phpstan-type parser_callable (callable(mixed): mixed)
* @phpstan-type parser_callable_string (callable(mixed): mixed)&string
*
* @see \CodeIgniter\View\ParserTest
*/
class Parser extends View
Expand Down Expand Up @@ -63,8 +60,7 @@ class Parser extends View
/**
* Stores any plugins registered at run-time.
*
* @var array<string, callable|list<string>|string>
* @phpstan-var array<string, array<parser_callable_string>|parser_callable_string|parser_callable>
* @var array<string, (callable(mixed): mixed)|((callable(mixed): mixed)&string)|list<(callable(mixed): mixed)&string>>
*/
protected $plugins = [];

Expand Down
4 changes: 1 addition & 3 deletions tests/_support/Config/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
use Tests\Support\Filters\Customfilter;
use Tests\Support\Filters\RedirectFilter;

/**
* @psalm-suppress UndefinedGlobalVariable
*/
/** @psalm-suppress UndefinedGlobalVariable */
$filters->aliases['test-customfilter'] = Customfilter::class;
$filters->aliases['test-redirectfilter'] = RedirectFilter::class;
Loading