Skip to content

Commit c84d322

Browse files
committed
Release v4.4.2
1 parent 844616e commit c84d322

File tree

154 files changed

+568
-202
lines changed

Some content is hidden

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

154 files changed

+568
-202
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ writable/uploads/*
6161
!writable/uploads/index.html
6262

6363
writable/debugbar/*
64+
!writable/debugbar/.gitkeep
6465

6566
php_errors.log
6667

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ PHP version 7.4 or higher is required, with the following extensions installed:
4747
- [intl](http://php.net/manual/en/intl.requirements.php)
4848
- [mbstring](http://php.net/manual/en/mbstring.installation.php)
4949

50+
> **Warning**
51+
> The end of life date for PHP 7.4 was November 28, 2022. If you are
52+
> still using PHP 7.4, you should upgrade immediately. The end of life date
53+
> for PHP 8.0 will be November 26, 2023.
54+
5055
Additionally, make sure that the following extensions are enabled in your PHP:
5156

5257
- json (enabled by default - don't turn it off)

app/Config/Migrations.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ class Migrations extends BaseConfig
2525
*
2626
* This is the name of the table that will store the current migrations state.
2727
* When migrations runs it will store in a database table which migration
28-
* level the system is at. It then compares the migration level in this
29-
* table to the $config['migration_version'] if they are not the same it
30-
* will migrate up. This must be set.
28+
* files have already been run.
3129
*/
3230
public string $table = 'migrations';
3331

app/Config/View.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
use CodeIgniter\Config\View as BaseView;
66
use CodeIgniter\View\ViewDecoratorInterface;
77

8+
/**
9+
* @phpstan-type ParserCallable (callable(mixed): mixed)
10+
* @phpstan-type ParserCallableString (callable(mixed): mixed)&string
11+
*/
812
class View extends BaseView
913
{
1014
/**
@@ -30,7 +34,8 @@ class View extends BaseView
3034
* { title|esc(js) }
3135
* { created_on|date(Y-m-d)|esc(attr) }
3236
*
33-
* @var array
37+
* @var array<string, string>
38+
* @phpstan-var array<string, ParserCallableString>
3439
*/
3540
public $filters = [];
3641

@@ -39,7 +44,8 @@ class View extends BaseView
3944
* by the core Parser by creating aliases that will be replaced with
4045
* any callable. Can be single or tag pair.
4146
*
42-
* @var array
47+
* @var array<string, array<string>|callable|string>
48+
* @phpstan-var array<string, array<ParserCallableString>|ParserCallableString|ParserCallable>
4349
*/
4450
public $plugins = [];
4551

system/Autoloader/Autoloader.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
* // register the autoloader
5454
* $loader->register();
5555
* ```
56+
*
57+
* @see \CodeIgniter\Autoloader\AutoloaderTest
5658
*/
5759
class Autoloader
5860
{
@@ -122,17 +124,21 @@ public function initialize(Autoload $config, Modules $modules)
122124
}
123125

124126
if (is_file(COMPOSER_PATH)) {
125-
$this->loadComposerInfo($modules);
127+
$this->loadComposerAutoloader($modules);
126128
}
127129

128130
return $this;
129131
}
130132

131-
private function loadComposerInfo(Modules $modules): void
133+
private function loadComposerAutoloader(Modules $modules): void
132134
{
133-
/**
134-
* @var ClassLoader $composer
135-
*/
135+
// The path to the vendor directory.
136+
// We do not want to enforce this, so set the constant if Composer was used.
137+
if (! defined('VENDORPATH')) {
138+
define('VENDORPATH', dirname(COMPOSER_PATH) . DIRECTORY_SEPARATOR);
139+
}
140+
141+
/** @var ClassLoader $composer */
136142
$composer = include COMPOSER_PATH;
137143

138144
$this->loadComposerClassmap($composer);

system/Autoloader/FileLocator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
/**
1515
* Allows loading non-class files in a namespaced manner.
1616
* Works with Helpers, Views, etc.
17+
*
18+
* @see \CodeIgniter\Autoloader\FileLocatorTest
1719
*/
1820
class FileLocator
1921
{
@@ -203,7 +205,7 @@ public function search(string $path, string $ext = 'php', bool $prioritizeApp =
203205
*/
204206
protected function ensureExt(string $path, string $ext): string
205207
{
206-
if ($ext) {
208+
if ($ext !== '') {
207209
$ext = '.' . $ext;
208210

209211
if (substr($path, -strlen($ext)) !== $ext) {

system/BaseModel.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ public function paginate(?int $perPage = null, string $group = 'default', ?int $
11941194
// Since multiple models may use the Pager, the Pager must be shared.
11951195
$pager = Services::pager();
11961196

1197-
if ($segment) {
1197+
if ($segment !== 0) {
11981198
$pager->setSegment($segment, $group);
11991199
}
12001200

@@ -1439,8 +1439,8 @@ public function setValidationRule(string $field, $fieldRules)
14391439
if (is_string($rules)) {
14401440
[$rules, $customErrors] = $this->validation->loadRuleGroup($rules);
14411441

1442-
$this->validationRules = $rules;
1443-
$this->validationMessages = $this->validationMessages + $customErrors;
1442+
$this->validationRules = $rules;
1443+
$this->validationMessages += $customErrors;
14441444
}
14451445

14461446
$this->validationRules[$field] = $fieldRules;
@@ -1510,7 +1510,7 @@ public function getValidationRules(array $options = []): array
15101510
if (is_string($rules)) {
15111511
[$rules, $customErrors] = $this->validation->loadRuleGroup($rules);
15121512

1513-
$this->validationMessages = $this->validationMessages + $customErrors;
1513+
$this->validationMessages += $customErrors;
15141514
}
15151515

15161516
if (isset($options['except'])) {
@@ -1656,8 +1656,10 @@ protected function objectToArray($data, bool $onlyChanged = true, bool $recursiv
16561656
{
16571657
$properties = $this->objectToRawArray($data, $onlyChanged, $recursive);
16581658

1659+
assert(is_array($properties));
1660+
16591661
// Convert any Time instances to appropriate $dateFormat
1660-
if ($properties) {
1662+
if ($properties !== []) {
16611663
$properties = array_map(function ($value) {
16621664
if ($value instanceof Time) {
16631665
return $this->timeToDate($value);

system/CLI/CLI.php

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,28 @@
3333
* The wait() method is mostly testable, as long as you don't give it
3434
* an argument of "0".
3535
* These have been flagged to ignore for code coverage purposes.
36+
*
37+
* @see \CodeIgniter\CLI\CLITest
3638
*/
3739
class CLI
3840
{
3941
/**
4042
* Is the readline library on the system?
4143
*
4244
* @var bool
45+
*
46+
* @deprecated 4.4.2 Should be protected.
47+
* @TODO Fix to camelCase in the next major version.
4348
*/
4449
public static $readline_support = false;
4550

4651
/**
4752
* The message displayed at prompts.
4853
*
4954
* @var string
55+
*
56+
* @deprecated 4.4.2 Should be protected.
57+
* @TODO Fix to camelCase in the next major version.
5058
*/
5159
public static $wait_msg = 'Press any key to continue...';
5260

@@ -61,6 +69,8 @@ class CLI
6169
* Foreground color list
6270
*
6371
* @var array<string, string>
72+
*
73+
* @TODO Fix to camelCase in the next major version.
6474
*/
6575
protected static $foreground_colors = [
6676
'black' => '0;30',
@@ -86,6 +96,8 @@ class CLI
8696
* Background color list
8797
*
8898
* @var array<string, string>
99+
*
100+
* @TODO Fix to camelCase in the next major version.
89101
*/
90102
protected static $background_colors = [
91103
'black' => '40',
@@ -177,7 +189,7 @@ public static function init()
177189
* Named options must be in the following formats:
178190
* php index.php user -v --v -name=John --name=John
179191
*
180-
* @param string $prefix You may specify a string with which to prompt the user.
192+
* @param string|null $prefix You may specify a string with which to prompt the user.
181193
*/
182194
public static function input(?string $prefix = null): string
183195
{
@@ -208,9 +220,9 @@ public static function input(?string $prefix = null): string
208220
* // Do not provide options but requires a valid email
209221
* $email = CLI::prompt('What is your email?', null, 'required|valid_email');
210222
*
211-
* @param string $field Output "field" question
212-
* @param array|string $options String to a default value, array to a list of options (the first option will be the default value)
213-
* @param array|string $validation Validation rules
223+
* @param string $field Output "field" question
224+
* @param array|string $options String to a default value, array to a list of options (the first option will be the default value)
225+
* @param array|string|null $validation Validation rules
214226
*
215227
* @return string The user input
216228
*
@@ -255,8 +267,8 @@ public static function prompt(string $field, $options = null, $validation = null
255267
// Read the input from keyboard.
256268
$input = trim(static::input()) ?: $default;
257269

258-
if ($validation) {
259-
while (! static::validate(trim($field), $input, $validation)) {
270+
if ($validation !== []) {
271+
while (! static::validate('"' . trim($field) . '"', $input, $validation)) {
260272
$input = static::prompt($field, $options, $validation);
261273
}
262274
}
@@ -446,7 +458,7 @@ public static function print(string $text = '', ?string $foreground = null, ?str
446458
}
447459

448460
/**
449-
* Outputs a string to the cli on it's own line.
461+
* Outputs a string to the cli on its own line.
450462
*
451463
* @return void
452464
*/
@@ -572,10 +584,10 @@ public static function clearScreen()
572584
* Returns the given text with the correct color codes for a foreground and
573585
* optionally a background color.
574586
*
575-
* @param string $text The text to color
576-
* @param string $foreground The foreground color
577-
* @param string $background The background color
578-
* @param string $format Other formatting to apply. Currently only 'underline' is understood
587+
* @param string $text The text to color
588+
* @param string $foreground The foreground color
589+
* @param string|null $background The background color
590+
* @param string|null $format Other formatting to apply. Currently only 'underline' is understood
579591
*
580592
* @return string The color coded string
581593
*/
@@ -832,7 +844,7 @@ public static function showProgress($thisStep = 1, int $totalSteps = 10)
832844
* width.
833845
*
834846
* If an int is passed into $pad_left, then all strings after the first
835-
* will padded with that many spaces to the left. Useful when printing
847+
* will pad with that many spaces to the left. Useful when printing
836848
* short descriptions that need to start on an existing line.
837849
*/
838850
public static function wrap(?string $string = null, int $max = 0, int $padLeft = 0): string
@@ -849,7 +861,7 @@ public static function wrap(?string $string = null, int $max = 0, int $padLeft =
849861
$max = self::getWidth();
850862
}
851863

852-
$max = $max - $padLeft;
864+
$max -= $padLeft;
853865

854866
$lines = wordwrap($string, $max, PHP_EOL);
855867

@@ -1076,8 +1088,8 @@ public static function table(array $tbody, array $thead = [])
10761088
foreach ($tableRows[$row] as $col) {
10771089
$diff = $maxColsLengths[$column] - static::strlen($col);
10781090

1079-
if ($diff) {
1080-
$tableRows[$row][$column] = $tableRows[$row][$column] . str_repeat(' ', $diff);
1091+
if ($diff !== 0) {
1092+
$tableRows[$row][$column] .= str_repeat(' ', $diff);
10811093
}
10821094

10831095
$column++;

system/CLI/Commands.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ public function verifyCommand(string $command, array $commands): bool
146146

147147
$message = lang('CLI.commandNotFound', [$command]);
148148

149-
if ($alternatives = $this->getCommandAlternatives($command, $commands)) {
149+
$alternatives = $this->getCommandAlternatives($command, $commands);
150+
if ($alternatives !== []) {
150151
if (count($alternatives) === 1) {
151152
$message .= "\n\n" . lang('CLI.altCommandSingular') . "\n ";
152153
} else {

system/CLI/Console.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
namespace CodeIgniter\CLI;
1313

1414
use CodeIgniter\CodeIgniter;
15+
use Config\App;
1516
use Config\Services;
1617
use Exception;
1718

1819
/**
1920
* Console
21+
*
22+
* @see \CodeIgniter\CLI\ConsoleTest
2023
*/
2124
class Console
2225
{
@@ -29,6 +32,12 @@ class Console
2932
*/
3033
public function run()
3134
{
35+
// Create CLIRequest
36+
$appConfig = config(App::class);
37+
Services::createRequest($appConfig, true);
38+
// Load Routes
39+
Services::routes()->loadRoutes();
40+
3241
$runner = Services::commands();
3342
$params = array_merge(CLI::getSegments(), CLI::getOptions());
3443
$params = $this->parseParamsForHelpOption($params);

0 commit comments

Comments
 (0)