Skip to content

Commit 0e4ce5a

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.3
Conflicts: phpstan-baseline.neon.dist system/Commands/Utilities/Namespaces.php
2 parents 849a415 + 8e60c03 commit 0e4ce5a

14 files changed

Lines changed: 79 additions & 71 deletions

File tree

app/Config/Autoload.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class Autoload extends AutoloadConfig
3636
* 'App' => APPPATH
3737
* ];
3838
*
39-
* @var array<string, string>
39+
* @var array<string, array<int, string>|string>
40+
* @phpstan-var array<string, string|list<string>>
4041
*/
4142
public $psr4 = [
4243
APP_NAMESPACE => APPPATH, // For custom app namespace

phpstan-baseline.neon.dist

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,6 @@ parameters:
1010
count: 1
1111
path: system/Autoloader/Autoloader.php
1212

13-
-
14-
message: "#^Property Config\\\\Autoload\\:\\:\\$classmap \\(array\\<string, string\\>\\) in isset\\(\\) is not nullable\\.$#"
15-
count: 1
16-
path: system/Autoloader/Autoloader.php
17-
18-
-
19-
message: "#^Property Config\\\\Autoload\\:\\:\\$files \\(array\\<int, string\\>\\) in isset\\(\\) is not nullable\\.$#"
20-
count: 1
21-
path: system/Autoloader/Autoloader.php
22-
23-
-
24-
message: "#^Property Config\\\\Autoload\\:\\:\\$psr4 \\(array\\<string, string\\>\\) in isset\\(\\) is not nullable\\.$#"
25-
count: 1
26-
path: system/Autoloader/Autoloader.php
27-
2813
-
2914
message: "#^Comparison operation \"\\>\" between int and \\(array\\|float\\|int\\) results in an error\\.$#"
3015
count: 1

system/Autoloader/Autoloader.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@ public function initialize(Autoload $config, Modules $modules)
101101

102102
// We have to have one or the other, though we don't enforce the need
103103
// to have both present in order to work.
104-
if (empty($config->psr4) && empty($config->classmap)) {
104+
if ($config->psr4 === [] && $config->classmap === []) {
105105
throw new InvalidArgumentException('Config array must contain either the \'psr4\' key or the \'classmap\' key.');
106106
}
107107

108-
if (isset($config->psr4)) {
108+
if ($config->psr4 !== []) {
109109
$this->addNamespace($config->psr4);
110110
}
111111

112-
if (isset($config->classmap)) {
112+
if ($config->classmap !== []) {
113113
$this->classmap = $config->classmap;
114114
}
115115

116-
if (isset($config->files)) {
116+
if ($config->files !== []) {
117117
$this->files = $config->files;
118118
}
119119

@@ -177,7 +177,8 @@ public function unregister(): void
177177
/**
178178
* Registers namespaces with the autoloader.
179179
*
180-
* @param array|string $namespace
180+
* @param array<string, array<int, string>|string>|string $namespace
181+
* @phpstan-param array<string, list<string>|string>|string $namespace
181182
*
182183
* @return $this
183184
*/

system/CLI/CLI.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ public static function table(array $tbody, array $thead = [])
10771077
$table .= '| ' . implode(' | ', $tableRows[$row]) . ' |' . PHP_EOL;
10781078

10791079
// Set the thead and table borders-bottom
1080-
if (isset($cols) && (($row === 0 && ! empty($thead)) || ($row + 1 === $totalRows))) {
1080+
if (($row === 0 && ! empty($thead)) || ($row + 1 === $totalRows)) {
10811081
$table .= $cols . PHP_EOL;
10821082
}
10831083
}

system/Commands/Server/rewrite.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,18 @@
2929
// All request handle by index.php file.
3030
$_SERVER['SCRIPT_NAME'] = '/index.php';
3131

32-
// Front Controller path - expected to be in the default folder
33-
$fcpath = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR;
34-
3532
// Full path
36-
$path = $fcpath . ltrim($uri, '/');
33+
$path = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . ltrim($uri, '/');
3734

3835
// If $path is an existing file or folder within the public folder
3936
// then let the request handle it like normal.
4037
if ($uri !== '/' && (is_file($path) || is_dir($path))) {
4138
return false;
4239
}
4340

41+
unset($uri, $path);
42+
4443
// Otherwise, we'll load the index file and let
4544
// the framework handle the request from here.
46-
require_once $fcpath . 'index.php';
45+
require_once $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'index.php';
4746
// @codeCoverageIgnoreEnd

system/Commands/Utilities/Namespaces.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,22 @@ private function outputCINamespaces(array $params): array
134134

135135
$tbody = [];
136136

137-
foreach ($config->psr4 as $ns => $path) {
137+
foreach ($config->psr4 as $ns => $paths) {
138138
if (array_key_exists('r', $params)) {
139-
$pathOutput = $this->truncate($path, $maxLength);
139+
$pathOutput = $this->truncate($paths, $maxLength);
140140
} else {
141-
$pathOutput = $this->truncate(clean_path($path), $maxLength);
141+
$pathOutput = $this->truncate(clean_path($paths), $maxLength);
142142
}
143143

144-
$tbody[] = [
145-
$ns,
146-
$pathOutput,
147-
is_dir($path) ? 'Yes' : 'MISSING',
148-
];
144+
foreach ((array) $paths as $path) {
145+
$path = realpath($path) ?: $path;
146+
147+
$tbody[] = [
148+
$ns,
149+
$pathOutput,
150+
is_dir($path) ? 'Yes' : 'MISSING',
151+
];
152+
}
149153
}
150154

151155
return $tbody;

system/Config/AutoloadConfig.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ 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, string>
48+
* @var array<string, array<int, string>|string>
49+
* @phpstan-var array<string, string|list<string>>
4950
*/
5051
public $psr4 = [];
5152

@@ -72,6 +73,7 @@ class AutoloadConfig
7273
* or for loading functions.
7374
*
7475
* @var array<int, string>
76+
* @phpstan-var list<string>
7577
*/
7678
public $files = [];
7779

system/Session/Handlers/RedisHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function open($path, $name): bool
119119

120120
$redis = new Redis();
121121

122-
if (! $redis->connect($this->savePath['host'], $this->savePath['port'], $this->savePath['timeout'])) {
122+
if (! $redis->connect($this->savePath['host'], ($this->savePath['host'][0] === '/' ? 0 : $this->savePath['port']), $this->savePath['timeout'])) {
123123
$this->logger->error('Session: Unable to connect to Redis with the configured settings.');
124124
} elseif (isset($this->savePath['password']) && ! $redis->auth($this->savePath['password'])) {
125125
$this->logger->error('Session: Unable to authenticate to Redis instance.');

tests/system/Models/InsertModelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ public function testInsertWithSetAndEscape(): void
332332
$this->assertGreaterThan(0, $this->model->getInsertID());
333333
$result = $this->model->where('name', 'Scott')->where('country', '2')->where('email', '2+2')->first();
334334

335-
$this->assertCloseEnough(time(), strtotime($result->created_at));
335+
$this->assertNotNull($result->created_at);
336336
}
337337

338338
/**

user_guide_src/source/changelogs/v4.2.11.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ Bugs Fixed
1313
**********
1414

1515
- Fixed a ``FileLocator::locateFile()`` bug where a similar namespace name could be replaced by another, causing a failure to find a file that exists.
16+
- Fixed a ``RedisHandler`` session class to use the correct config when used with a socket connection.
1617

1718
See the repo's `CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_ for a complete list of bugs fixed.

0 commit comments

Comments
 (0)