From 23a34dfd43eb53c791b4d0ffa4117e341e2f9236 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 6 Feb 2024 10:53:22 +0900 Subject: [PATCH 1/2] chore: allow to use @property-read and @property-write --- .php-cs-fixer.dist.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 3653cf1349c2..6a86ebe205e5 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -43,7 +43,35 @@ __DIR__ . '/spark', ]); -$overrides = []; +$overrides = [ + 'phpdoc_no_alias_tag' => [ + 'replacements' => [ + 'type' => 'var', + 'link' => 'see', + ], + ], + 'phpdoc_align' => [ + 'align' => 'vertical', + 'spacing' => 1, + 'tags' => [ + 'method', + 'param', + 'phpstan-assert', + 'phpstan-assert-if-true', + 'phpstan-assert-if-false', + 'phpstan-param', + 'phpstan-property', + 'phpstan-return', + 'property', + 'property-read', + 'property-write', + 'return', + 'throws', + 'type', + 'var', + ], + ], +]; $options = [ 'cacheFile' => 'build/.php-cs-fixer.cache', From 1ed7245a41feae39cd2b50d05a7d3b35b1f75a0b Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 6 Feb 2024 10:54:03 +0900 Subject: [PATCH 2/2] docs: add/update @property --- phpstan-baseline.php | 10 ----- system/Database/BaseConnection.php | 54 ++++++++++++------------- system/Database/ConnectionInterface.php | 3 ++ 3 files changed, 30 insertions(+), 37 deletions(-) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index cc669afb1e74..3b79f9639943 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -1026,16 +1026,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/Config.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Access to an undefined property CodeIgniter\\\\Database\\\\ConnectionInterface\\:\\:\\$DBDriver\\.$#', - 'count' => 2, - 'path' => __DIR__ . '/system/Database/Database.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Access to an undefined property CodeIgniter\\\\Database\\\\ConnectionInterface\\:\\:\\$connID\\.$#', - 'count' => 2, - 'path' => __DIR__ . '/system/Database/Database.php', -]; $ignoreErrors[] = [ 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', 'count' => 2, diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index a024d938f386..4e34e0fdb699 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -18,33 +18,33 @@ use Throwable; /** - * @property array $aliasedTables - * @property string $charset - * @property bool $compress - * @property float $connectDuration - * @property float $connectTime - * @property string $database - * @property string $DBCollat - * @property bool $DBDebug - * @property string $DBDriver - * @property string $DBPrefix - * @property string $DSN - * @property array|bool $encrypt - * @property array $failover - * @property string $hostname - * @property Query $lastQuery - * @property string $password - * @property bool $pConnect - * @property int|string $port - * @property bool $pretend - * @property string $queryClass - * @property array $reservedIdentifiers - * @property bool $strictOn - * @property string $subdriver - * @property string $swapPre - * @property int $transDepth - * @property bool $transFailure - * @property bool $transStatus + * @property-read array $aliasedTables + * @property-read string $charset + * @property-read bool $compress + * @property-read float $connectDuration + * @property-read float $connectTime + * @property-read string $database + * @property-read string $DBCollat + * @property-read bool $DBDebug + * @property-read string $DBDriver + * @property-read string $DBPrefix + * @property-read string $DSN + * @property-read array|bool $encrypt + * @property-read array $failover + * @property-read string $hostname + * @property-read Query $lastQuery + * @property-read string $password + * @property-read bool $pConnect + * @property-read int|string $port + * @property-read bool $pretend + * @property-read string $queryClass + * @property-read array $reservedIdentifiers + * @property-read bool $strictOn + * @property-read string $subdriver + * @property-read string $swapPre + * @property-read int $transDepth + * @property-read bool $transFailure + * @property-read bool $transStatus * * @template TConnection * @template TResult diff --git a/system/Database/ConnectionInterface.php b/system/Database/ConnectionInterface.php index a8493f897ec7..ed45933734a2 100644 --- a/system/Database/ConnectionInterface.php +++ b/system/Database/ConnectionInterface.php @@ -14,6 +14,9 @@ /** * @template TConnection * @template TResult + * + * @property false|object|resource $connID + * @property-read string $DBDriver */ interface ConnectionInterface {