Skip to content

Commit 339d527

Browse files
committed
Use native PHPDocs instead of @phpstan-
1 parent 94e13a4 commit 339d527

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+94
-148
lines changed

app/Config/App.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ class App extends BaseConfig
2727
* 'http://accounts.example.com/':
2828
* ['media.example.com', 'accounts.example.com']
2929
*
30-
* @var string[]
31-
* @phpstan-var list<string>
30+
* @var list<string>
3231
*/
3332
public array $allowedHostnames = [];
3433

app/Config/Autoload.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ class Autoload extends AutoloadConfig
4141
* 'App' => APPPATH
4242
* ];
4343
*
44-
* @var array<string, array<int, string>|string>
45-
* @phpstan-var array<string, string|list<string>>
44+
* @var array<string, list<string>|string>
4645
*/
4746
public $psr4 = [
4847
APP_NAMESPACE => APPPATH, // For custom app namespace
@@ -81,8 +80,7 @@ class Autoload extends AutoloadConfig
8180
* '/path/to/my/file.php',
8281
* ];
8382
*
84-
* @var string[]
85-
* @phpstan-var list<string>
83+
* @var list<string>
8684
*/
8785
public $files = [];
8886

@@ -95,8 +93,7 @@ class Autoload extends AutoloadConfig
9593
* 'form',
9694
* ];
9795
*
98-
* @var string[]
99-
* @phpstan-var list<string>
96+
* @var list<string>
10097
*/
10198
public $helpers = [];
10299
}

app/Config/Cache.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ class Cache extends BaseConfig
158158
* This is an array of cache engine alias' and class names. Only engines
159159
* that are listed here are allowed to be used.
160160
*
161-
* @var array<string, string>
162-
* @phpstan-var array<string, class-string<CacheInterface>>
161+
* @var array<string, class-string<CacheInterface>>
163162
*/
164163
public array $validHandlers = [
165164
'dummy' => DummyHandler::class,

app/Config/Filters.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ class Filters extends BaseConfig
1515
* Configures aliases for Filter classes to
1616
* make reading things nicer and simpler.
1717
*
18-
* @var array<string, array<int, string>|string> [filter_name => classname]
19-
* or [filter_name => [classname1, classname2, ...]]
20-
* @phpstan-var array<string, class-string|list<class-string>>
18+
* @var array<string, class-string|list<class-string>> [filter_name => classname]
19+
* or [filter_name => [classname1, classname2, ...]]
2120
*/
2221
public array $aliases = [
2322
'csrf' => CSRF::class,
@@ -31,8 +30,7 @@ class Filters extends BaseConfig
3130
* List of filter aliases that are always
3231
* applied before and after every request.
3332
*
34-
* @var array<string, array<string, array<string, string>>>|array<string, array<string>>
35-
* @phpstan-var array<string, list<string>>|array<string, array<string, array<string, string>>>
33+
* @var array<string, array<string, array<string, string>>>|array<string, list<string>>
3634
*/
3735
public array $globals = [
3836
'before' => [

app/Config/Kint.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ class Kint extends BaseConfig
2727
*/
2828

2929
/**
30-
* @var array<int, ConstructablePluginInterface|string>
31-
* @phpstan-var list<class-string<ConstructablePluginInterface>|ConstructablePluginInterface>
30+
* @var list<class-string<ConstructablePluginInterface>|ConstructablePluginInterface>
3231
*/
3332
public $plugins;
3433

@@ -46,14 +45,12 @@ class Kint extends BaseConfig
4645
public int $richSort = AbstractRenderer::SORT_FULL;
4746

4847
/**
49-
* @var array<string, string>
50-
* @phpstan-var array<string, class-string<ValuePluginInterface>>
48+
* @var array<string, class-string<ValuePluginInterface>>
5149
*/
5250
public $richObjectPlugins;
5351

5452
/**
55-
* @var array<string, string>
56-
* @phpstan-var array<string, class-string<TabPluginInterface>>
53+
* @var array<string, class-string<TabPluginInterface>>
5754
*/
5855
public $richTabPlugins;
5956

app/Config/Session.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Session extends BaseConfig
1919
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
2020
* - `CodeIgniter\Session\Handlers\RedisHandler`
2121
*
22-
* @phpstan-var class-string<BaseHandler>
22+
* @var class-string<BaseHandler>
2323
*/
2424
public string $driver = FileHandler::class;
2525

phpstan-baseline.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
'count' => 1,
1717
'path' => __DIR__ . '/system/Autoloader/Autoloader.php',
1818
];
19+
$ignoreErrors[] = [
20+
'message' => '#^Property Config\\\\Autoload\\:\\:\\$helpers \\(array\\<int, string\\>\\) in isset\\(\\) is not nullable\\.$#',
21+
'count' => 1,
22+
'path' => __DIR__ . '/system/Autoloader/Autoloader.php',
23+
];
1924
$ignoreErrors[] = [
2025
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2126
'count' => 13,

system/Autoloader/Autoloader.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,15 @@ class Autoloader
7575
/**
7676
* Stores files as a list.
7777
*
78-
* @var string[]
79-
* @phpstan-var list<string>
78+
* @var list<string>
8079
*/
8180
protected $files = [];
8281

8382
/**
8483
* Stores helper list.
8584
* Always load the URL helper, it should be used in most apps.
8685
*
87-
* @var string[]
88-
* @phpstan-var list<string>
86+
* @var list<string>
8987
*/
9088
protected $helpers = ['url'];
9189

@@ -119,7 +117,7 @@ public function initialize(Autoload $config, Modules $modules)
119117
$this->files = $config->files;
120118
}
121119

122-
if (isset($config->helpers)) { // @phpstan-ignore-line
120+
if (isset($config->helpers)) {
123121
$this->helpers = [...$this->helpers, ...$config->helpers];
124122
}
125123

@@ -185,8 +183,7 @@ public function unregister(): void
185183
/**
186184
* Registers namespaces with the autoloader.
187185
*
188-
* @param array<string, array<int, string>|string>|string $namespace
189-
* @phpstan-param array<string, list<string>|string>|string $namespace
186+
* @param array<string, list<string>|string>|string $namespace
190187
*
191188
* @return $this
192189
*/

system/BaseModel.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ abstract class BaseModel
6363
* The Database connection group that
6464
* should be instantiated.
6565
*
66-
* @var string|null
67-
* @phpstan-var non-empty-string|null
66+
* @var non-empty-string|null
6867
*/
6968
protected $DBGroup;
7069

system/Cache/Handlers/BaseHandler.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,9 @@ public static function validateKey($key, $prefix = ''): string
7676
/**
7777
* Get an item from the cache, or execute the given Closure and store the result.
7878
*
79-
* @param string $key Cache item name
80-
* @param int $ttl Time to live
81-
* @param Closure $callback Callback return value
82-
* @phpstan-param Closure(): mixed $callback
79+
* @param string $key Cache item name
80+
* @param int $ttl Time to live
81+
* @param Closure(): mixed $callback Callback return value
8382
*
8483
* @return array|bool|float|int|object|string|null
8584
*/

system/Cache/Handlers/FileHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,7 @@ public function isSupported(): bool
222222
* Does the heavy lifting of actually retrieving the file and
223223
* verifying it's age.
224224
*
225-
* @return array<string, mixed>|false
226-
* @phpstan-return array{data: mixed, ttl: int, time: int}|false
225+
* @return array{data: mixed, ttl: int, time: int}|false
227226
*/
228227
protected function getItem(string $filename)
229228
{

system/Commands/Database/ShowTableInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class ShowTableInfo extends BaseCommand
8484
];
8585

8686
/**
87-
* @phpstan-var list<list<string|int>> Table Data.
87+
* @var list<list<int|string>> Table Data.
8888
*/
8989
private array $tbody;
9090

system/Commands/Utilities/Routes/AutoRouteCollector.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ public function __construct(string $namespace, string $defaultController, string
3737
}
3838

3939
/**
40-
* @return array<int, array<int, string>>
41-
* @phpstan-return list<list<string>>
40+
* @return list<list<string>>
4241
*/
4342
public function get(): array
4443
{

system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public function __construct(
6262
}
6363

6464
/**
65-
* @return array<int, array<int, string>>
66-
* @phpstan-return list<list<string>>
65+
* @return list<list<string>>
6766
*/
6867
public function get(): array
6968
{

system/Commands/Utilities/Routes/AutoRouterImproved/ControllerMethodReader.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ final class ControllerMethodReader
2727
private string $namespace;
2828

2929
/**
30-
* @var array<int, string>
31-
* @phpstan-var list<string>
30+
* @var list<string>
3231
*/
3332
private array $httpMethods;
3433

@@ -44,10 +43,9 @@ public function __construct(string $namespace, array $httpMethods)
4443
/**
4544
* Returns found route info in the controller.
4645
*
47-
* @phpstan-param class-string $class
46+
* @param class-string $class
4847
*
49-
* @return array<int, array<string, array|string>>
50-
* @phpstan-return list<array<string, string|array>>
48+
* @return list<array<string, array|string>>
5149
*/
5250
public function read(string $class, string $defaultController = 'Home', string $defaultMethod = 'index'): array
5351
{
@@ -154,7 +152,7 @@ private function getParameters(ReflectionMethod $method): array
154152
}
155153

156154
/**
157-
* @phpstan-param class-string $classname
155+
* @param class-string $classname
158156
*
159157
* @return string URI path part from the folder(s) and controller
160158
*/
@@ -179,7 +177,7 @@ private function getUriByClass(string $classname): string
179177
/**
180178
* Gets a route for the default controller.
181179
*
182-
* @phpstan-return list<array>
180+
* @return list<array>
183181
*/
184182
private function getRouteForDefaultController(
185183
string $classShortname,

system/Commands/Utilities/Routes/ControllerFinder.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public function __construct(string $namespace)
3838
}
3939

4040
/**
41-
* @return string[]
42-
* @phpstan-return class-string[]
41+
* @return class-string[]
4342
*/
4443
public function find(): array
4544
{
@@ -66,7 +65,7 @@ public function find(): array
6665
$classnameOrEmpty = $this->locator->getClassname($file);
6766

6867
if ($classnameOrEmpty !== '') {
69-
/** @phpstan-var class-string $classname */
68+
/** @var class-string $classname */
7069
$classname = $classnameOrEmpty;
7170

7271
$classes[] = $classname;

system/Commands/Utilities/Routes/ControllerMethodReader.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ public function __construct(string $namespace)
3535
}
3636

3737
/**
38-
* @phpstan-param class-string $class
38+
* @param class-string $class
3939
*
40-
* @return array<int, array{route: string, handler: string}>
41-
* @phpstan-return list<array{route: string, handler: string}>
40+
* @return list<array{route: string, handler: string}>
4241
*/
4342
public function read(string $class, string $defaultController = 'Home', string $defaultMethod = 'index'): array
4443
{
@@ -128,7 +127,7 @@ private function hasRemap(ReflectionClass $class): bool
128127
}
129128

130129
/**
131-
* @phpstan-param class-string $classname
130+
* @param class-string $classname
132131
*
133132
* @return string URI path part from the folder(s) and controller
134133
*/

system/Common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ function stringify_attributes($attributes, bool $js = false): string
11391139
* returns its return value if any.
11401140
* Otherwise will start or stop the timer intelligently.
11411141
*
1142-
* @phpstan-param (callable(): mixed)|null $callable
1142+
* @param (callable(): mixed)|null $callable
11431143
*
11441144
* @return Timer
11451145
*/

system/Config/AutoloadConfig.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ class AutoloadConfig
4545
* but this should be done prior to creating any namespaced classes,
4646
* else you will need to modify all of those classes for this to work.
4747
*
48-
* @var array<string, array<int, string>|string>
49-
* @phpstan-var array<string, string|list<string>>
48+
* @var array<string, list<string>|string>
5049
*/
5150
public $psr4 = [];
5251

@@ -72,8 +71,7 @@ class AutoloadConfig
7271
* that will be autoloaded. This can be useful for bootstrap operations
7372
* or for loading functions.
7473
*
75-
* @var array<int, string>
76-
* @phpstan-var list<string>
74+
* @var list<string>
7775
*/
7876
public $files = [];
7977

system/Config/Factories.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ class Factories
6262
*
6363
* [component => [alias => FQCN]]
6464
*
65-
* @var array<string, array<string, string>>
66-
* @phpstan-var array<string, array<string, class-string>>
65+
* @var array<string, array<string, class-string>>
6766
*/
6867
protected static $aliases = [];
6968

@@ -76,8 +75,7 @@ class Factories
7675
*
7776
* [component => [FQCN => instance]]
7877
*
79-
* @var array<string, array<string, object>>
80-
* @phpstan-var array<string, array<class-string, object>>
78+
* @var array<string, array<class-string, object>>
8179
*/
8280
protected static $instances = [];
8381

@@ -93,10 +91,9 @@ class Factories
9391
/**
9492
* Define the class to load. You can *override* the concrete class.
9593
*
96-
* @param string $component Lowercase, plural component name
97-
* @param string $alias Class alias. See the $aliases property.
98-
* @param string $classname FQCN to be loaded
99-
* @phpstan-param class-string $classname FQCN to be loaded
94+
* @param string $component Lowercase, plural component name
95+
* @param string $alias Class alias. See the $aliases property.
96+
* @param class-string $classname FQCN to be loaded
10097
*/
10198
public static function define(string $component, string $alias, string $classname): void
10299
{

0 commit comments

Comments
 (0)