Skip to content

Commit a850820

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.7
2 parents b8a036d + 90edae6 commit a850820

31 files changed

+307
-197
lines changed

.github/workflows/test-psalm.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@ jobs:
6666
restore-keys: ${{ runner.os }}-psalm-
6767

6868
- name: Install dependencies
69-
run: |
70-
if [ -f composer.lock ]; then
71-
composer install --no-progress
72-
else
73-
composer update --no-progress
74-
fi
69+
run: composer update --ansi --no-interaction
7570

7671
- name: Run Psalm analysis
7772
run: utils/vendor/bin/psalm

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"phpunit/phpcov": "^9.0.2 || ^10.0",
2929
"phpunit/phpunit": "^10.5.16 || ^11.2",
3030
"predis/predis": "^3.0",
31-
"rector/rector": "2.1.0",
31+
"rector/rector": "2.1.2",
3232
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
3333
},
3434
"replace": {
@@ -89,7 +89,7 @@
8989
"CodeIgniter\\ComposerScripts::postUpdate"
9090
],
9191
"post-autoload-dump": [
92-
"@composer update --working-dir=utils --ignore-platform-req=php"
92+
"@composer update --ansi --working-dir=utils"
9393
],
9494
"analyze": [
9595
"Composer\\Config::disableProcessTimeout",
File renamed without changes.

psalm-baseline.xml

Lines changed: 64 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.22.2@d768d914152dbbf3486c36398802f74e80cfde48">
2+
<files psalm-version="6.12.1@e71404b0465be25cf7f8a631b298c01c5ddd864f">
33
<file src="app/Config/View.php">
44
<UndefinedDocblockClass>
55
<code><![CDATA[array<string, list<parser_callable_string>|parser_callable_string|parser_callable>]]></code>
@@ -10,40 +10,13 @@
1010
<code><![CDATA[public $plugins = [];]]></code>
1111
</UndefinedDocblockClass>
1212
</file>
13-
<file src="system/Cache/Handlers/MemcachedHandler.php">
14-
<UndefinedClass>
15-
<code><![CDATA[Memcache]]></code>
16-
<code><![CDATA[Memcache]]></code>
17-
<code><![CDATA[Memcache]]></code>
18-
</UndefinedClass>
19-
<UndefinedDocblockClass>
20-
<code><![CDATA[$this->memcached]]></code>
21-
<code><![CDATA[$this->memcached]]></code>
22-
<code><![CDATA[$this->memcached]]></code>
23-
<code><![CDATA[$this->memcached]]></code>
24-
<code><![CDATA[$this->memcached]]></code>
25-
<code><![CDATA[$this->memcached]]></code>
26-
<code><![CDATA[Memcache|Memcached]]></code>
27-
</UndefinedDocblockClass>
28-
</file>
29-
<file src="system/Commands/Utilities/Routes/ControllerMethodReader.php">
30-
<DuplicateArrayKey>
31-
<code><![CDATA[$routeWithoutController]]></code>
32-
<code><![CDATA[$routeWithoutController]]></code>
33-
</DuplicateArrayKey>
34-
</file>
3513
<file src="system/Config/View.php">
3614
<UndefinedDocblockClass>
3715
<code><![CDATA[array<string, array<parser_callable_string>|parser_callable_string|parser_callable>]]></code>
3816
<code><![CDATA[array<string, array<parser_callable_string>|parser_callable_string|parser_callable>]]></code>
3917
<code><![CDATA[array<string, parser_callable_string>]]></code>
4018
</UndefinedDocblockClass>
4119
</file>
42-
<file src="system/Database/BasePreparedQuery.php">
43-
<InaccessibleProperty>
44-
<code><![CDATA[$this->db->transStatus]]></code>
45-
</InaccessibleProperty>
46-
</file>
4720
<file src="system/Database/OCI8/Connection.php">
4821
<UndefinedConstant>
4922
<code><![CDATA[OCI_COMMIT_ON_SUCCESS]]></code>
@@ -53,6 +26,17 @@
5326
<code><![CDATA[SQLT_CHR]]></code>
5427
</UndefinedConstant>
5528
</file>
29+
<file src="system/Database/OCI8/PreparedQuery.php">
30+
<UndefinedClass>
31+
<code><![CDATA[$binaryData]]></code>
32+
<code><![CDATA[OCILob]]></code>
33+
</UndefinedClass>
34+
<UndefinedConstant>
35+
<code><![CDATA[OCI_B_BLOB]]></code>
36+
<code><![CDATA[OCI_D_LOB]]></code>
37+
<code><![CDATA[OCI_TEMP_BLOB]]></code>
38+
</UndefinedConstant>
39+
</file>
5640
<file src="system/Debug/Toolbar/Views/toolbar.tpl.php">
5741
<InaccessibleMethod>
5842
<code><![CDATA[renderTimeline]]></code>
@@ -82,7 +66,6 @@
8266
<MissingImmutableAnnotation>
8367
<code><![CDATA[#[ReturnTypeWillChange]]]></code>
8468
<code><![CDATA[#[ReturnTypeWillChange]]]></code>
85-
<code><![CDATA[#[ReturnTypeWillChange]]]></code>
8669
</MissingImmutableAnnotation>
8770
</file>
8871
<file src="system/View/Parser.php">
@@ -112,11 +95,6 @@
11295
<code><![CDATA[$this]]></code>
11396
</InvalidScope>
11497
</file>
115-
<file src="tests/system/CLI/ConsoleTest.php">
116-
<DuplicateArrayKey>
117-
<code><![CDATA[$command]]></code>
118-
</DuplicateArrayKey>
119-
</file>
12098
<file src="tests/system/CommonFunctionsTest.php">
12199
<UndefinedClass>
122100
<code><![CDATA[UnexsistenceClass]]></code>
@@ -140,12 +118,64 @@
140118
<EmptyArrayAccess>
141119
<code><![CDATA[$current[$key]]]></code>
142120
</EmptyArrayAccess>
121+
<InaccessibleProperty>
122+
<code><![CDATA[$entity->attributes]]></code>
123+
<code><![CDATA[$entity->casts]]></code>
124+
<code><![CDATA[$entity->casts]]></code>
125+
<code><![CDATA[$entity->casts]]></code>
126+
<code><![CDATA[$entity->casts]]></code>
127+
</InaccessibleProperty>
143128
</file>
144129
<file src="tests/system/HTTP/RedirectResponseTest.php">
145130
<EmptyArrayAccess>
146131
<code><![CDATA[$_SESSION['_ci_old_input']]]></code>
147132
</EmptyArrayAccess>
148133
</file>
134+
<file src="tests/system/Models/InsertModelTest.php">
135+
<InaccessibleProperty>
136+
<code><![CDATA[$entity->country]]></code>
137+
<code><![CDATA[$entity->created_at]]></code>
138+
<code><![CDATA[$entity->deleted]]></code>
139+
<code><![CDATA[$entity->email]]></code>
140+
<code><![CDATA[$entity->name]]></code>
141+
<code><![CDATA[$entityTwo->country]]></code>
142+
<code><![CDATA[$entityTwo->created_at]]></code>
143+
<code><![CDATA[$entityTwo->deleted]]></code>
144+
<code><![CDATA[$entityTwo->email]]></code>
145+
<code><![CDATA[$entityTwo->name]]></code>
146+
</InaccessibleProperty>
147+
</file>
148+
<file src="tests/system/Models/SaveModelTest.php">
149+
<InaccessibleProperty>
150+
<code><![CDATA[$entity->country]]></code>
151+
<code><![CDATA[$entity->created_at]]></code>
152+
<code><![CDATA[$entity->created_at]]></code>
153+
<code><![CDATA[$entity->deleted]]></code>
154+
<code><![CDATA[$entity->email]]></code>
155+
<code><![CDATA[$entity->name]]></code>
156+
<code><![CDATA[$entity->name]]></code>
157+
<code><![CDATA[$entity->name]]></code>
158+
<code><![CDATA[$entity->name]]></code>
159+
</InaccessibleProperty>
160+
</file>
161+
<file src="tests/system/Models/UpdateModelTest.php">
162+
<InaccessibleProperty>
163+
<code><![CDATA[$entity->country]]></code>
164+
<code><![CDATA[$entity->deleted]]></code>
165+
<code><![CDATA[$entity->email]]></code>
166+
<code><![CDATA[$entity->id]]></code>
167+
<code><![CDATA[$entity->name]]></code>
168+
<code><![CDATA[$entity1->country]]></code>
169+
<code><![CDATA[$entity1->country]]></code>
170+
<code><![CDATA[$entity1->deleted]]></code>
171+
<code><![CDATA[$entity1->id]]></code>
172+
<code><![CDATA[$entity1->name]]></code>
173+
<code><![CDATA[$entity2->country]]></code>
174+
<code><![CDATA[$entity2->deleted]]></code>
175+
<code><![CDATA[$entity2->id]]></code>
176+
<code><![CDATA[$entity2->name]]></code>
177+
</InaccessibleProperty>
178+
</file>
149179
<file src="tests/system/Test/ControllerTestTraitTest.php">
150180
<UndefinedClass>
151181
<code><![CDATA[NeverHeardOfIt]]></code>

psalm.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
66
xmlns="https://getpsalm.org/schema/config"
77
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8-
autoloader="psalm_autoload.php"
8+
autoloader="psalm-autoload.php"
99
cacheDirectory="build/psalm/"
1010
errorBaseline="psalm-baseline.xml"
11+
ensureOverrideAttribute="false"
1112
findUnusedBaselineEntry="false"
1213
findUnusedCode="false"
1314
>

system/CLI/GeneratorTrait.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,22 +282,21 @@ protected function qualifyClassName(): string
282282
return $namespace . $directoryString . str_replace('/', '\\', $class);
283283
}
284284

285-
/**
286-
* Normalize input classname.
287-
*/
288285
private function normalizeInputClassName(): string
289286
{
290287
// Gets the class name from input.
291288
$class = $this->params[0] ?? CLI::getSegment(2);
292289

293290
if ($class === null && $this->hasClassName) {
294-
// @codeCoverageIgnoreStart
295-
$nameLang = $this->classNameLang !== ''
291+
$nameField = $this->classNameLang !== ''
296292
? $this->classNameLang
297293
: 'CLI.generator.className.default';
298-
$class = CLI::prompt(lang($nameLang), null, 'required');
294+
$class = CLI::prompt(lang($nameField), null, 'required');
295+
296+
// Reassign the class name to the params array in case
297+
// the class name is requested again
298+
$this->params[0] = $class;
299299
CLI::newLine();
300-
// @codeCoverageIgnoreEnd
301300
}
302301

303302
helper('inflector');

system/Commands/Generators/TestGenerator.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ class TestGenerator extends BaseCommand
7676
*/
7777
public function run(array $params)
7878
{
79+
// Ensure tests are always suffixed with 'Test'
80+
$params['suffix'] = null;
81+
7982
$this->component = 'Test';
8083
$this->template = 'test.tpl.php';
8184

@@ -173,20 +176,17 @@ protected function buildPath(string $class): string
173176
/**
174177
* Returns test file path for the namespace.
175178
*/
176-
private function searchTestFilePath(string $namespace): ?string
179+
private function searchTestFilePath(string $testNamespace): ?string
177180
{
178-
$bases = service('autoloader')->getNamespace($namespace);
179-
180-
$base = null;
181-
182-
foreach ($bases as $candidate) {
183-
if (str_contains($candidate, '/tests/')) {
184-
$base = $candidate;
181+
/** @var list<non-empty-string> $testPaths */
182+
$testPaths = service('autoloader')->getNamespace($testNamespace);
185183

186-
break;
184+
foreach ($testPaths as $candidate) {
185+
if (str_contains($candidate, DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR)) {
186+
return $candidate;
187187
}
188188
}
189189

190-
return $base;
190+
return null;
191191
}
192192
}

system/HTTP/DownloadResponse.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,22 +182,21 @@ private function getDownloadFileName(): string
182182
}
183183

184184
/**
185-
* get Content-Disposition Header string.
185+
* Get Content-Disposition Header string.
186186
*/
187-
private function getContentDisposition(): string
187+
private function getContentDisposition(bool $inline = false): string
188188
{
189-
$downloadFilename = $this->getDownloadFileName();
190-
191-
$utf8Filename = $downloadFilename;
189+
$downloadFilename = $utf8Filename = $this->getDownloadFileName();
190+
$disposition = $inline ? 'inline' : 'attachment';
192191

193192
if (strtoupper($this->charset) !== 'UTF-8') {
194193
$utf8Filename = mb_convert_encoding($downloadFilename, 'UTF-8', $this->charset);
195194
}
196195

197-
$result = sprintf('attachment; filename="%s"', $downloadFilename);
196+
$result = sprintf('%s; filename="%s"', $disposition, addslashes($downloadFilename));
198197

199198
if ($utf8Filename !== '') {
200-
$result .= '; filename*=UTF-8\'\'' . rawurlencode($utf8Filename);
199+
$result .= sprintf('; filename*=UTF-8\'\'%s', rawurlencode($utf8Filename));
201200
}
202201

203202
return $result;
@@ -341,7 +340,7 @@ private function sendBodyByBinary()
341340
*/
342341
public function inline()
343342
{
344-
$this->setHeader('Content-Disposition', 'inline');
343+
$this->setHeader('Content-Disposition', $this->getContentDisposition(true));
345344

346345
return $this;
347346
}

0 commit comments

Comments
 (0)