Skip to content

Commit

Permalink
Release v4.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Oct 19, 2023
1 parent 844616e commit c84d322
Show file tree
Hide file tree
Showing 154 changed files with 568 additions and 202 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 61,7 @@ writable/uploads/*
!writable/uploads/index.html

writable/debugbar/*
!writable/debugbar/.gitkeep

php_errors.log

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 47,11 @@ PHP version 7.4 or higher is required, with the following extensions installed:
- [intl](http://php.net/manual/en/intl.requirements.php)
- [mbstring](http://php.net/manual/en/mbstring.installation.php)

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

- json (enabled by default - don't turn it off)
Expand Down
4 changes: 1 addition & 3 deletions app/Config/Migrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 25,7 @@ class Migrations extends BaseConfig
*
* This is the name of the table that will store the current migrations state.
* When migrations runs it will store in a database table which migration
* level the system is at. It then compares the migration level in this
* table to the $config['migration_version'] if they are not the same it
* will migrate up. This must be set.
* files have already been run.
*/
public string $table = 'migrations';

Expand Down
10 changes: 8 additions & 2 deletions app/Config/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 5,10 @@
use CodeIgniter\Config\View as BaseView;
use CodeIgniter\View\ViewDecoratorInterface;

/**
* @phpstan-type ParserCallable (callable(mixed): mixed)
* @phpstan-type ParserCallableString (callable(mixed): mixed)&string
*/
class View extends BaseView
{
/**
Expand All @@ -30,7 34,8 @@ class View extends BaseView
* { title|esc(js) }
* { created_on|date(Y-m-d)|esc(attr) }
*
* @var array
* @var array<string, string>
* @phpstan-var array<string, ParserCallableString>
*/
public $filters = [];

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

Expand Down
16 changes: 11 additions & 5 deletions system/Autoloader/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 53,8 @@
* // register the autoloader
* $loader->register();
* ```
*
* @see \CodeIgniter\Autoloader\AutoloaderTest
*/
class Autoloader
{
Expand Down Expand Up @@ -122,17 124,21 @@ public function initialize(Autoload $config, Modules $modules)
}

if (is_file(COMPOSER_PATH)) {
$this->loadComposerInfo($modules);
$this->loadComposerAutoloader($modules);
}

return $this;
}

private function loadComposerInfo(Modules $modules): void
private function loadComposerAutoloader(Modules $modules): void
{
/**
* @var ClassLoader $composer
*/
// The path to the vendor directory.
// We do not want to enforce this, so set the constant if Composer was used.
if (! defined('VENDORPATH')) {
define('VENDORPATH', dirname(COMPOSER_PATH) . DIRECTORY_SEPARATOR);
}

/** @var ClassLoader $composer */
$composer = include COMPOSER_PATH;

$this->loadComposerClassmap($composer);
Expand Down
4 changes: 3 additions & 1 deletion system/Autoloader/FileLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 14,8 @@
/**
* Allows loading non-class files in a namespaced manner.
* Works with Helpers, Views, etc.
*
* @see \CodeIgniter\Autoloader\FileLocatorTest
*/
class FileLocator
{
Expand Down Expand Up @@ -203,7 205,7 @@ public function search(string $path, string $ext = 'php', bool $prioritizeApp =
*/
protected function ensureExt(string $path, string $ext): string
{
if ($ext) {
if ($ext !== '') {
$ext = '.' . $ext;

if (substr($path, -strlen($ext)) !== $ext) {
Expand Down
12 changes: 7 additions & 5 deletions system/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 1194,7 @@ public function paginate(?int $perPage = null, string $group = 'default', ?int $
// Since multiple models may use the Pager, the Pager must be shared.
$pager = Services::pager();

if ($segment) {
if ($segment !== 0) {
$pager->setSegment($segment, $group);
}

Expand Down Expand Up @@ -1439,8 1439,8 @@ public function setValidationRule(string $field, $fieldRules)
if (is_string($rules)) {
[$rules, $customErrors] = $this->validation->loadRuleGroup($rules);

$this->validationRules = $rules;
$this->validationMessages = $this->validationMessages $customErrors;
$this->validationRules = $rules;
$this->validationMessages = $customErrors;
}

$this->validationRules[$field] = $fieldRules;
Expand Down Expand Up @@ -1510,7 1510,7 @@ public function getValidationRules(array $options = []): array
if (is_string($rules)) {
[$rules, $customErrors] = $this->validation->loadRuleGroup($rules);

$this->validationMessages = $this->validationMessages $customErrors;
$this->validationMessages = $customErrors;
}

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

assert(is_array($properties));

// Convert any Time instances to appropriate $dateFormat
if ($properties) {
if ($properties !== []) {
$properties = array_map(function ($value) {
if ($value instanceof Time) {
return $this->timeToDate($value);
Expand Down
42 changes: 27 additions & 15 deletions system/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 33,28 @@
* The wait() method is mostly testable, as long as you don't give it
* an argument of "0".
* These have been flagged to ignore for code coverage purposes.
*
* @see \CodeIgniter\CLI\CLITest
*/
class CLI
{
/**
* Is the readline library on the system?
*
* @var bool
*
* @deprecated 4.4.2 Should be protected.
* @TODO Fix to camelCase in the next major version.
*/
public static $readline_support = false;

/**
* The message displayed at prompts.
*
* @var string
*
* @deprecated 4.4.2 Should be protected.
* @TODO Fix to camelCase in the next major version.
*/
public static $wait_msg = 'Press any key to continue...';

Expand All @@ -61,6 69,8 @@ class CLI
* Foreground color list
*
* @var array<string, string>
*
* @TODO Fix to camelCase in the next major version.
*/
protected static $foreground_colors = [
'black' => '0;30',
Expand All @@ -86,6 96,8 @@ class CLI
* Background color list
*
* @var array<string, string>
*
* @TODO Fix to camelCase in the next major version.
*/
protected static $background_colors = [
'black' => '40',
Expand Down Expand Up @@ -177,7 189,7 @@ public static function init()
* Named options must be in the following formats:
* php index.php user -v --v -name=John --name=John
*
* @param string $prefix You may specify a string with which to prompt the user.
* @param string|null $prefix You may specify a string with which to prompt the user.
*/
public static function input(?string $prefix = null): string
{
Expand Down Expand Up @@ -208,9 220,9 @@ public static function input(?string $prefix = null): string
* // Do not provide options but requires a valid email
* $email = CLI::prompt('What is your email?', null, 'required|valid_email');
*
* @param string $field Output "field" question
* @param array|string $options String to a default value, array to a list of options (the first option will be the default value)
* @param array|string $validation Validation rules
* @param string $field Output "field" question
* @param array|string $options String to a default value, array to a list of options (the first option will be the default value)
* @param array|string|null $validation Validation rules
*
* @return string The user input
*
Expand Down Expand Up @@ -255,8 267,8 @@ public static function prompt(string $field, $options = null, $validation = null
// Read the input from keyboard.
$input = trim(static::input()) ?: $default;

if ($validation) {
while (! static::validate(trim($field), $input, $validation)) {
if ($validation !== []) {
while (! static::validate('"' . trim($field) . '"', $input, $validation)) {
$input = static::prompt($field, $options, $validation);
}
}
Expand Down Expand Up @@ -446,7 458,7 @@ public static function print(string $text = '', ?string $foreground = null, ?str
}

/**
* Outputs a string to the cli on it's own line.
* Outputs a string to the cli on its own line.
*
* @return void
*/
Expand Down Expand Up @@ -572,10 584,10 @@ public static function clearScreen()
* Returns the given text with the correct color codes for a foreground and
* optionally a background color.
*
* @param string $text The text to color
* @param string $foreground The foreground color
* @param string $background The background color
* @param string $format Other formatting to apply. Currently only 'underline' is understood
* @param string $text The text to color
* @param string $foreground The foreground color
* @param string|null $background The background color
* @param string|null $format Other formatting to apply. Currently only 'underline' is understood
*
* @return string The color coded string
*/
Expand Down Expand Up @@ -832,7 844,7 @@ public static function showProgress($thisStep = 1, int $totalSteps = 10)
* width.
*
* If an int is passed into $pad_left, then all strings after the first
* will padded with that many spaces to the left. Useful when printing
* will pad with that many spaces to the left. Useful when printing
* short descriptions that need to start on an existing line.
*/
public static function wrap(?string $string = null, int $max = 0, int $padLeft = 0): string
Expand All @@ -849,7 861,7 @@ public static function wrap(?string $string = null, int $max = 0, int $padLeft =
$max = self::getWidth();
}

$max = $max - $padLeft;
$max -= $padLeft;

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

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

if ($diff) {
$tableRows[$row][$column] = $tableRows[$row][$column] . str_repeat(' ', $diff);
if ($diff !== 0) {
$tableRows[$row][$column] .= str_repeat(' ', $diff);
}

$column ;
Expand Down
3 changes: 2 additions & 1 deletion system/CLI/Commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 146,8 @@ public function verifyCommand(string $command, array $commands): bool

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

if ($alternatives = $this->getCommandAlternatives($command, $commands)) {
$alternatives = $this->getCommandAlternatives($command, $commands);
if ($alternatives !== []) {
if (count($alternatives) === 1) {
$message .= "\n\n" . lang('CLI.altCommandSingular') . "\n ";
} else {
Expand Down
9 changes: 9 additions & 0 deletions system/CLI/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 12,14 @@
namespace CodeIgniter\CLI;

use CodeIgniter\CodeIgniter;
use Config\App;
use Config\Services;
use Exception;

/**
* Console
*
* @see \CodeIgniter\CLI\ConsoleTest
*/
class Console
{
Expand All @@ -29,6 32,12 @@ class Console
*/
public function run()
{
// Create CLIRequest
$appConfig = config(App::class);
Services::createRequest($appConfig, true);
// Load Routes
Services::routes()->loadRoutes();

$runner = Services::commands();
$params = array_merge(CLI::getSegments(), CLI::getOptions());
$params = $this->parseParamsForHelpOption($params);
Expand Down
2 changes: 2 additions & 0 deletions system/Cache/CacheFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 18,8 @@

/**
* A factory for loading the desired
*
* @see \CodeIgniter\Cache\CacheFactoryTest
*/
class CacheFactory
{
Expand Down
2 changes: 2 additions & 0 deletions system/Cache/Handlers/BaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 19,8 @@

/**
* Base class for cache handling
*
* @see \CodeIgniter\Cache\Handlers\BaseHandlerTest
*/
abstract class BaseHandler implements CacheInterface
{
Expand Down
2 changes: 2 additions & 0 deletions system/Cache/Handlers/DummyHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 15,8 @@

/**
* Dummy cache handler
*
* @see \CodeIgniter\Cache\Handlers\DummyHandlerTest
*/
class DummyHandler extends BaseHandler
{
Expand Down
2 changes: 2 additions & 0 deletions system/Cache/Handlers/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 18,8 @@

/**
* File system cache handler
*
* @see \CodeIgniter\Cache\Handlers\FileHandlerTest
*/
class FileHandler extends BaseHandler
{
Expand Down
2 changes: 2 additions & 0 deletions system/Cache/Handlers/MemcachedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 20,8 @@

/**
* Mamcached cache handler
*
* @see \CodeIgniter\Cache\Handlers\MemcachedHandlerTest
*/
class MemcachedHandler extends BaseHandler
{
Expand Down
4 changes: 3 additions & 1 deletion system/Cache/Handlers/PredisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 20,8 @@

/**
* Predis cache handler
*
* @see \CodeIgniter\Cache\Handlers\PredisHandlerTest
*/
class PredisHandler extends BaseHandler
{
Expand Down Expand Up @@ -131,7 133,7 @@ public function save(string $key, $value, int $ttl = 60)
return false;
}

if ($ttl) {
if ($ttl !== 0) {
$this->redis->expireat($key, Time::now()->getTimestamp() $ttl);
}

Expand Down
Loading

0 comments on commit c84d322

Please sign in to comment.