Skip to content

Commit 37445bc

Browse files
committed
Merge branch 'develop' into 4.7
2 parents 4046b8d + 327c7e1 commit 37445bc

Some content is hidden

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

65 files changed

+343
-459
lines changed

app/Config/Cookie.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Cookie extends BaseConfig
8585
* (empty string) means default SameSite attribute set by browsers (`Lax`)
8686
* will be set on cookies. If set to `None`, `$secure` must also be set.
8787
*
88-
* @phpstan-var 'None'|'Lax'|'Strict'|''
88+
* @var ''|'Lax'|'None'|'Strict'
8989
*/
9090
public string $samesite = 'Lax';
9191

psalm_autoload.php

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,40 @@
44

55
require __DIR__ . '/system/util_bootstrap.php';
66

7-
$helperDirs = [
7+
$directories = [
88
'system/Helpers',
9-
];
10-
11-
foreach ($helperDirs as $dir) {
12-
$dir = __DIR__ . '/' . $dir;
13-
if (! is_dir($dir)) {
14-
continue;
15-
}
16-
17-
chdir($dir);
18-
19-
foreach (glob('*_helper.php') as $filename) {
20-
$filePath = realpath($dir . '/' . $filename);
21-
22-
require_once $filePath;
23-
}
24-
}
25-
26-
$dirs = [
27-
'tests/_support/Controllers',
28-
'tests/_support/_controller',
9+
'tests/_support',
2910
'tests/system/Config/fixtures',
3011
];
12+
$excludeDirs = [
13+
'tests/_support/Config',
14+
'tests/_support/View/Cells',
15+
'tests/_support/View/Views',
16+
];
3117

32-
foreach ($dirs as $dir) {
33-
$dir = __DIR__ . '/' . $dir;
34-
if (! is_dir($dir)) {
35-
continue;
36-
}
37-
38-
chdir($dir);
39-
40-
foreach (glob('*.php') as $filename) {
41-
$filePath = realpath($dir . '/' . $filename);
42-
43-
require_once $filePath;
18+
foreach ($directories as $directory) {
19+
$iterator = new RecursiveIteratorIterator(
20+
new RecursiveDirectoryIterator(
21+
$directory,
22+
RecursiveDirectoryIterator::UNIX_PATHS | RecursiveDirectoryIterator::CURRENT_AS_FILEINFO,
23+
),
24+
RecursiveIteratorIterator::CHILD_FIRST,
25+
);
26+
27+
/** @var SplFileInfo $file */
28+
foreach ($iterator as $file) {
29+
if (! $file->isFile()) {
30+
continue;
31+
}
32+
33+
if (in_array($file->getPath(), $excludeDirs, true)) {
34+
continue;
35+
}
36+
37+
if ($file->getExtension() !== 'php') {
38+
continue;
39+
}
40+
41+
require_once $file->getPathname();
4442
}
4543
}
46-
47-
chdir(__DIR__);

system/API/ResponseTrait.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ trait ResponseTrait
6969
* Either 'json' or 'xml'. If null is set, it will be determined through
7070
* content negotiation.
7171
*
72-
* @var string|null
73-
* @phpstan-var 'html'|'json'|'xml'|null
72+
* @var 'html'|'json'|'xml'|null
7473
*/
7574
protected $format = 'json';
7675

@@ -348,8 +347,7 @@ protected function format($data = null)
348347
/**
349348
* Sets the format the response should be in.
350349
*
351-
* @param string|null $format Response format
352-
* @phpstan-param 'json'|'xml' $format
350+
* @param 'json'|'xml' $format Response format
353351
*
354352
* @return $this
355353
*/

system/Autoloader/Autoloader.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ public function addNamespace($namespace, ?string $path = null)
219219
*
220220
* If a prefix param is set, returns only paths to the given prefix.
221221
*
222-
* @return array<string, list<string>>|list<string>
223-
* @phpstan-return ($prefix is null ? array<string, list<string>> : list<string>)
222+
* @return ($prefix is null ? array<string, list<string>> : list<string>)
224223
*/
225224
public function getNamespace(?string $prefix = null)
226225
{

system/BaseModel.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -793,8 +793,7 @@ public function getInsertID()
793793
* @phpstan-param row_array|object|null $row
794794
* @param bool $returnID Whether insert ID should be returned or not.
795795
*
796-
* @return bool|int|string insert ID or true on success. false on failure.
797-
* @phpstan-return ($returnID is true ? int|string|false : bool)
796+
* @return ($returnID is true ? false|int|string : bool)
798797
*
799798
* @throws ReflectionException
800799
*/
@@ -1094,9 +1093,7 @@ public function updateBatch(?array $set = null, ?string $index = null, int $batc
10941093
$row = $this->doProtectFields($row);
10951094

10961095
// Restore updateIndex value in case it was wiped out
1097-
if ($updateIndex !== null) {
1098-
$row[$index] = $updateIndex;
1099-
}
1096+
$row[$index] = $updateIndex;
11001097

11011098
$row = $this->setUpdatedField($row, $this->setDate());
11021099
}

system/CodeIgniter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class CodeIgniter
141141
* web: Invoked by HTTP request
142142
* php-cli: Invoked by CLI via `php public/index.php`
143143
*
144-
* @phpstan-var 'php-cli'|'web'
144+
* @var 'php-cli'|'web'|null
145145
*/
146146
protected ?string $context = null;
147147

@@ -1128,7 +1128,7 @@ protected function callExit($code)
11281128
/**
11291129
* Sets the app context.
11301130
*
1131-
* @phpstan-param 'php-cli'|'web' $context
1131+
* @param 'php-cli'|'web' $context
11321132
*
11331133
* @return $this
11341134
*/

system/Commands/Translation/LocalizationFinder.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,7 @@ private function isSubDirectory(string $directory, string $rootDirectory): bool
361361
/**
362362
* @param list<SplFileInfo> $files
363363
*
364-
* @return array<string, array|int>
365-
* @phpstan-return array{'foundLanguageKeys': array<string, array<string, string>>, 'badLanguageKeys': array<int, array<int, string>>, 'countFiles': int}
364+
* @return array{'foundLanguageKeys': array<string, array<string, string>>, 'badLanguageKeys': array<int, array<int, string>>, 'countFiles': int}
366365
*/
367366
private function findLanguageKeysInFiles(array $files): array
368367
{

system/Common.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ function app_timezone(): string
6969
* cache()->save('foo', 'bar');
7070
* $foo = cache('bar');
7171
*
72-
* @return array|bool|CacheInterface|float|int|object|string|null
73-
* @phpstan-return ($key is null ? CacheInterface : array|bool|float|int|object|string|null)
72+
* @return ($key is null ? CacheInterface : mixed)
7473
*/
7574
function cache(?string $key = null)
7675
{
@@ -201,8 +200,7 @@ function command(string $command)
201200
*
202201
* @param class-string<ConfigTemplate>|string $name
203202
*
204-
* @return ConfigTemplate|null
205-
* @phpstan-return ($name is class-string<ConfigTemplate> ? ConfigTemplate : object|null)
203+
* @return ($name is class-string<ConfigTemplate> ? ConfigTemplate : object|null)
206204
*/
207205
function config(string $name, bool $getShared = true)
208206
{
@@ -404,11 +402,11 @@ function env(string $key, $default = null)
404402
* If $data is an array, then it loops over it, escaping each
405403
* 'value' of the key/value pairs.
406404
*
407-
* @param array|string $data
408-
* @phpstan-param 'html'|'js'|'css'|'url'|'attr'|'raw' $context
409-
* @param string|null $encoding Current encoding for escaping.
410-
* If not UTF-8, we convert strings from this encoding
411-
* pre-escaping and back to this encoding post-escaping.
405+
* @param array|string $data
406+
* @param 'attr'|'css'|'html'|'js'|'raw'|'url' $context
407+
* @param string|null $encoding Current encoding for escaping.
408+
* If not UTF-8, we convert strings from this encoding
409+
* pre-escaping and back to this encoding post-escaping.
412410
*
413411
* @return array|string
414412
*
@@ -796,8 +794,7 @@ function log_message(string $level, string $message, array $context = []): void
796794
*
797795
* @param class-string<ModelTemplate>|string $name
798796
*
799-
* @return ModelTemplate|null
800-
* @phpstan-return ($name is class-string<ModelTemplate> ? ModelTemplate : object|null)
797+
* @return ($name is class-string<ModelTemplate> ? ModelTemplate : object|null)
801798
*/
802799
function model(string $name, bool $getShared = true, ?ConnectionInterface &$conn = null)
803800
{
@@ -810,9 +807,8 @@ function model(string $name, bool $getShared = true, ?ConnectionInterface &$conn
810807
* Provides access to "old input" that was set in the session
811808
* during a redirect()->withInput().
812809
*
813-
* @param string|null $default
814-
* @param false|string $escape
815-
* @phpstan-param false|'attr'|'css'|'html'|'js'|'raw'|'url' $escape
810+
* @param string|null $default
811+
* @param 'attr'|'css'|'html'|'js'|'raw'|'url'|false $escape
816812
*
817813
* @return array|string|null
818814
*/
@@ -965,8 +961,7 @@ function route_to(string $method, ...$params)
965961
* session()->set('foo', 'bar');
966962
* $foo = session('bar');
967963
*
968-
* @return array|bool|float|int|object|Session|string|null
969-
* @phpstan-return ($val is null ? Session : array|bool|float|int|object|string|null)
964+
* @return ($val is null ? Session : mixed)
970965
*/
971966
function session(?string $val = null)
972967
{
@@ -1123,8 +1118,7 @@ function stringify_attributes($attributes, bool $js = false): string
11231118
* @param non-empty-string|null $name
11241119
* @param (callable(): mixed)|null $callable
11251120
*
1126-
* @return mixed|Timer
1127-
* @phpstan-return ($name is null ? Timer : ($callable is (callable(): mixed) ? mixed : Timer))
1121+
* @return ($name is null ? Timer : ($callable is (callable(): mixed) ? mixed : Timer))
11281122
*/
11291123
function timer(?string $name = null, ?callable $callable = null)
11301124
{

system/Config/Services.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,11 @@ public static function session(?SessionConfig $config = null, bool $getShared =
683683
$driverName = MySQLiHandler::class;
684684
} elseif ($driverPlatform === 'Postgre') {
685685
$driverName = PostgreHandler::class;
686+
} else {
687+
throw new InvalidArgumentException(sprintf(
688+
'Invalid session database handler "%s" provided. Only "MySQLi" and "Postgre" are supported.',
689+
$driverPlatform,
690+
));
686691
}
687692
}
688693

system/DataCaster/DataCaster.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,9 @@ public function setTypes(array $types): static
113113
* Add ? at the beginning of the type (i.e. ?string) to get `null`
114114
* instead of casting $value when $value is null.
115115
*
116-
* @param mixed $value The value to convert
117-
* @param string $field The field name
118-
* @param string $method Allowed to "get" and "set"
119-
* @phpstan-param 'get'|'set' $method
116+
* @param mixed $value The value to convert
117+
* @param string $field The field name
118+
* @param 'get'|'set' $method Allowed to "get" and "set"
120119
*/
121120
public function castAs(mixed $value, string $field, string $method = 'get'): mixed
122121
{

system/DataConverter/DataConverter.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
/**
2121
* PHP data <==> DataSource data converter
2222
*
23-
* @see \CodeIgniter\DataConverter\DataConverterTest
24-
*
2523
* @template TEntity of object
24+
*
25+
* @see \CodeIgniter\DataConverter\DataConverterTest
2626
*/
2727
final class DataConverter
2828
{
@@ -52,14 +52,14 @@ public function __construct(
5252
* Static reconstruct method name or closure to reconstruct an object.
5353
* Used by reconstruct().
5454
*
55-
* @phpstan-var (Closure(array<string, mixed>): TEntity)|string|null
55+
* @var (Closure(array<string, mixed>): TEntity)|string|null
5656
*/
5757
private readonly Closure|string|null $reconstructor = 'reconstruct',
5858
/**
5959
* Extract method name or closure to extract data from an object.
6060
* Used by extract().
6161
*
62-
* @phpstan-var (Closure(TEntity, bool, bool): array<string, mixed>)|string|null
62+
* @var (Closure(TEntity, bool, bool): array<string, mixed>)|string|null
6363
*/
6464
private readonly Closure|string|null $extractor = null,
6565
) {
@@ -105,11 +105,10 @@ public function toDataSource(array $phpData): array
105105
/**
106106
* Takes database data array and creates a specified type object.
107107
*
108-
* @param class-string $classname
109-
* @phpstan-param class-string<TEntity> $classname
110-
* @param array<string, mixed> $row Raw data from database
108+
* @param class-string<TEntity> $classname
109+
* @param array<string, mixed> $row Raw data from database
111110
*
112-
* @phpstan-return TEntity
111+
* @return TEntity
113112
*
114113
* @internal
115114
*/

0 commit comments

Comments
 (0)