Skip to content

Commit 7d8e085

Browse files
committed
Merge branch 'develop' into 4.7
2 parents 8fbdbd4 + 77ec9e5 commit 7d8e085

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

+172
-956
lines changed

phpstan.neon.dist

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
11
includes:
2-
- utils/phpstan-baseline/loader.neon
2+
- utils/phpstan-baseline/loader.neon
33

44
parameters:
5-
phpVersion: 80100
6-
tmpDir: build/phpstan
7-
level: 6
8-
bootstrapFiles:
9-
- phpstan-bootstrap.php
10-
paths:
11-
- admin/starter/tests
12-
- app
13-
- system
14-
- tests
15-
excludePaths:
16-
- app/Views/errors/cli/*
17-
- app/Views/errors/html/*
18-
- system/Commands/Generators/Views/*
19-
- system/Debug/Toolbar/Views/toolbar.tpl.php
20-
- system/Images/Handlers/GDHandler.php
21-
- system/Test/Filters/CITestStreamFilter.php
22-
- system/ThirdParty/*
23-
- system/Validation/Views/single.php
24-
- tests/system/View/Views/*
25-
scanDirectories:
26-
- system/Helpers
27-
ignoreErrors:
28-
-
29-
identifier: missingType.generics
30-
checkMissingCallableSignature: true
31-
treatPhpDocTypesAsCertain: false
32-
strictRules:
33-
allRules: false
34-
disallowedLooseComparison: true
35-
booleansInConditions: true
36-
disallowedBacktick: true
37-
disallowedEmpty: true
38-
disallowedImplicitArrayCreation: true
39-
disallowedShortTernary: true
40-
matchingInheritedMethodNames: true
41-
codeigniter:
42-
additionalServices:
43-
- AfterAutoloadModule\Config\Services
44-
checkArgumentTypeOfModel: false
45-
shipmonkBaselinePerIdentifier:
46-
directory: %currentWorkingDirectory%
5+
phpVersion: 80100
6+
tmpDir: build/phpstan
7+
level: 6
8+
bootstrapFiles:
9+
- phpstan-bootstrap.php
10+
paths:
11+
- admin/starter/tests
12+
- app
13+
- system
14+
- tests
15+
excludePaths:
16+
analyseAndScan:
17+
- app/Views/errors/cli/*
18+
- app/Views/errors/html/*
19+
- system/Commands/Generators/Views/*
20+
- system/Debug/Toolbar/Views/toolbar.tpl.php
21+
- system/Images/Handlers/GDHandler.php
22+
- system/ThirdParty/*
23+
- system/Validation/Views/single.php
24+
- tests/system/View/Views/*
25+
analyse:
26+
- tests/_support/*
27+
scanDirectories:
28+
- system/Helpers
29+
ignoreErrors:
30+
-
31+
identifier: missingType.generics
32+
checkMissingCallableSignature: true
33+
treatPhpDocTypesAsCertain: false
34+
strictRules:
35+
allRules: false
36+
disallowedLooseComparison: true
37+
booleansInConditions: true
38+
disallowedBacktick: true
39+
disallowedEmpty: true
40+
disallowedImplicitArrayCreation: true
41+
disallowedShortTernary: true
42+
matchingInheritedMethodNames: true
43+
codeigniter:
44+
additionalServices:
45+
- AfterAutoloadModule\Config\Services
46+
checkArgumentTypeOfModel: false
47+
shipmonkBaselinePerIdentifier:
48+
directory: %currentWorkingDirectory%

system/Cache/Handlers/FileHandler.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public function __construct(Cache $config)
6363

6464
$this->mode = $config->file['mode'] ?? 0640;
6565
$this->prefix = $config->prefix;
66+
67+
helper('filesystem');
6668
}
6769

6870
/**
@@ -96,7 +98,7 @@ public function save(string $key, $value, int $ttl = 60)
9698
'data' => $value,
9799
];
98100

99-
if ($this->writeFile($this->path . $key, serialize($contents))) {
101+
if (write_file($this->path . $key, serialize($contents))) {
100102
try {
101103
chmod($this->path . $key, $this->mode);
102104

@@ -176,15 +178,15 @@ public function decrement(string $key, int $offset = 1)
176178
*/
177179
public function clean()
178180
{
179-
return $this->deleteFiles($this->path, false, true);
181+
return delete_files($this->path, false, true);
180182
}
181183

182184
/**
183185
* {@inheritDoc}
184186
*/
185187
public function getCacheInfo()
186188
{
187-
return $this->getDirFileInfo($this->path);
189+
return get_dir_file_info($this->path);
188190
}
189191

190192
/**
@@ -251,6 +253,8 @@ protected function getItem(string $filename)
251253
/**
252254
* Writes a file to disk, or returns false if not successful.
253255
*
256+
* @deprecated 4.6.1 Use `write_file()` instead.
257+
*
254258
* @param string $path
255259
* @param string $data
256260
* @param string $mode
@@ -265,7 +269,9 @@ protected function writeFile($path, $data, $mode = 'wb')
265269

266270
flock($fp, LOCK_EX);
267271

268-
for ($result = $written = 0, $length = strlen($data); $written < $length; $written += $result) {
272+
$result = 0;
273+
274+
for ($written = 0, $length = strlen($data); $written < $length; $written += $result) {
269275
if (($result = fwrite($fp, substr($data, $written))) === false) {
270276
break;
271277
}
@@ -283,6 +289,8 @@ protected function writeFile($path, $data, $mode = 'wb')
283289
* If the second parameter is set to TRUE, any directories contained
284290
* within the supplied base directory will be nuked as well.
285291
*
292+
* @deprecated 4.6.1 Use `delete_files()` instead.
293+
*
286294
* @param string $path File path
287295
* @param bool $delDir Whether to delete any directories found in the path
288296
* @param bool $htdocs Whether to skip deleting .htaccess and index page files
@@ -318,6 +326,8 @@ protected function deleteFiles(string $path, bool $delDir = false, bool $htdocs
318326
*
319327
* Any sub-folders contained within the specified path are read as well.
320328
*
329+
* @deprecated 4.6.1 Use `get_dir_file_info()` instead.
330+
*
321331
* @param string $sourceDir Path to source
322332
* @param bool $topLevelOnly Look only at the top level directory specified?
323333
* @param bool $_recursion Internal variable to determine recursion status - do not use in calls
@@ -360,6 +370,8 @@ protected function getDirFileInfo(string $sourceDir, bool $topLevelOnly = true,
360370
* Options are: name, server_path, size, date, readable, writable, executable, fileperms
361371
* Returns FALSE if the file cannot be found.
362372
*
373+
* @deprecated 4.6.1 Use `get_file_info()` instead.
374+
*
363375
* @param string $file Path to file
364376
* @param array|string $returnedValues Array or comma separated string of information returned
365377
*

system/Commands/Utilities/ConfigCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ final class ConfigCheck extends BaseCommand
7373
protected $options = [];
7474

7575
/**
76-
* {@inheritDoc}
76+
* @return int
7777
*/
7878
public function run(array $params)
7979
{

system/Commands/Utilities/Environment.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ final class Environment extends BaseCommand
8080
];
8181

8282
/**
83-
* {@inheritDoc}
83+
* @return int
8484
*/
8585
public function run(array $params)
8686
{
8787
if ($params === []) {
8888
CLI::write(sprintf('Your environment is currently set as %s.', CLI::color($_SERVER['CI_ENVIRONMENT'] ?? ENVIRONMENT, 'green')));
8989
CLI::newLine();
9090

91-
return;
91+
return EXIT_ERROR;
9292
}
9393

9494
$env = strtolower(array_shift($params));
@@ -98,21 +98,21 @@ public function run(array $params)
9898
CLI::error('You will not be able to run spark under a "testing" environment.', 'light_gray', 'red');
9999
CLI::newLine();
100100

101-
return;
101+
return EXIT_ERROR;
102102
}
103103

104104
if (! in_array($env, self::$knownTypes, true)) {
105105
CLI::error(sprintf('Invalid environment type "%s". Expected one of "%s".', $env, implode('" and "', self::$knownTypes)), 'light_gray', 'red');
106106
CLI::newLine();
107107

108-
return;
108+
return EXIT_ERROR;
109109
}
110110

111111
if (! $this->writeNewEnvironmentToEnvFile($env)) {
112112
CLI::error('Error in writing new environment to .env file.', 'light_gray', 'red');
113113
CLI::newLine();
114114

115-
return;
115+
return EXIT_ERROR;
116116
}
117117

118118
// force DotEnv to reload the new environment
@@ -124,6 +124,8 @@ public function run(array $params)
124124
CLI::write(sprintf('Environment is successfully changed to "%s".', $env), 'green');
125125
CLI::write('The ENVIRONMENT constant will be changed in the next script execution.');
126126
CLI::newLine();
127+
128+
return EXIT_SUCCESS;
127129
}
128130

129131
/**

system/Commands/Utilities/Optimize.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ final class Optimize extends BaseCommand
5555
protected $usage = 'optimize';
5656

5757
/**
58-
* {@inheritDoc}
58+
* @return int
5959
*/
6060
public function run(array $params)
6161
{
6262
try {
6363
$this->enableCaching();
6464
$this->clearCache();
6565
$this->removeDevPackages();
66+
67+
return EXIT_SUCCESS;
6668
} catch (RuntimeException) {
6769
CLI::error('The "spark optimize" failed.');
6870

6971
return EXIT_ERROR;
7072
}
71-
72-
return EXIT_SUCCESS;
7373
}
7474

7575
private function clearCache(): void

system/Commands/Utilities/PhpIniCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ final class PhpIniCheck extends BaseCommand
6868
protected $options = [];
6969

7070
/**
71-
* {@inheritDoc}
71+
* @return int
7272
*/
7373
public function run(array $params)
7474
{

system/Database/BaseBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3407,7 +3407,7 @@ protected function resetSelect()
34073407
'QBUnion' => [],
34083408
]);
34093409

3410-
if (! empty($this->db)) {
3410+
if ($this->db instanceof BaseConnection) {
34113411
$this->db->setAliasedTables([]);
34123412
}
34133413

system/Encryption/Encryption.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
* This class determines the driver, cipher, and mode to use, and then
2424
* initializes the appropriate encryption handler.
2525
*
26+
* @property-read string $digest
27+
* @property-read string $driver
28+
* @property-read list<string> $drivers
29+
* @property-read string $key
30+
*
2631
* @see \CodeIgniter\Encryption\EncryptionTest
2732
*/
2833
class Encryption

system/HTTP/Files/FileCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ protected function getValueDotNotationSyntax(array $index, array $value)
253253
{
254254
$currentIndex = array_shift($index);
255255

256-
if (isset($currentIndex) && is_array($index) && $index !== [] && array_key_exists($currentIndex, $value) && is_array($value[$currentIndex])) {
256+
if (isset($currentIndex) && $index !== [] && array_key_exists($currentIndex, $value) && is_array($value[$currentIndex])) {
257257
return $this->getValueDotNotationSyntax($index, $value[$currentIndex]);
258258
}
259259

system/Helpers/filesystem_helper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ function write_file(string $path, string $data, string $mode = 'wb'): bool
123123

124124
flock($fp, LOCK_EX);
125125

126-
for ($result = $written = 0, $length = strlen($data); $written < $length; $written += $result) {
126+
$result = 0;
127+
128+
for ($written = 0, $length = strlen($data); $written < $length; $written += $result) {
127129
if (($result = fwrite($fp, substr($data, $written))) === false) {
128130
break;
129131
}

system/I18n/TimeDifference.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717
use IntlCalendar;
1818

1919
/**
20-
* Class TimeDifference
20+
* @property-read float|int $days
21+
* @property-read float|int $hours
22+
* @property-read float|int $minutes
23+
* @property-read float|int $months
24+
* @property-read int $seconds
25+
* @property-read float|int $weeks
26+
* @property-read float|int $years
2127
*
2228
* @see \CodeIgniter\I18n\TimeDifferenceTest
2329
*/

system/Images/Handlers/BaseHandler.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ abstract class BaseHandler implements ImageHandlerInterface
3434
/**
3535
* The image/file instance
3636
*
37-
* @var Image
37+
* @var Image|null
3838
*/
3939
protected $image;
4040

@@ -138,6 +138,8 @@ public function __construct($config = null)
138138
* Sets another image for this handler to work on.
139139
* Keeps us from needing to continually instantiate the handler.
140140
*
141+
* @phpstan-assert Image $this->image
142+
*
141143
* @return $this
142144
*/
143145
public function withFile(string $path)
@@ -176,7 +178,7 @@ public function getFile()
176178
/**
177179
* Verifies that a file has been supplied and it is an image.
178180
*
179-
* @return Image The image instance
181+
* @phpstan-assert Image $this->image
180182
*
181183
* @throws ImageException
182184
*/
@@ -187,7 +189,7 @@ protected function image(): Image
187189
}
188190

189191
// Verify withFile has been called
190-
if (empty($this->image)) {
192+
if ($this->image === null) {
191193
throw ImageException::forMissingImage();
192194
}
193195

system/Session/Handlers/FileHandler.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ public function write($id, $data): bool
201201
if (($length = strlen($data)) > 0) {
202202
$result = null;
203203

204-
for ($written = 0; $written < $length; $written += $result) {
204+
$written = 0;
205+
206+
for (; $written < $length; $written += $result) {
205207
if (($result = fwrite($this->fileHandle, substr($data, $written))) === false) {
206208
break;
207209
}

0 commit comments

Comments
 (0)