Skip to content
Merged
2 changes: 0 additions & 2 deletions system/Autoloader/Autoloader.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php namespace CodeIgniter\Autoloader;

use Composer\Autoload\ClassLoader;

/**
* CodeIgniter
*
Expand Down
26 changes: 14 additions & 12 deletions system/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ public static function input(string $prefix = null): string
* $email = CLI::prompt('What is your email?', null, 'required|valid_email');
*
* @param string $field Output "field" question
* @param string|array $options String to a defaul value, array to a list of options (the first option will be the default value)
* @param string|array $options String to a default value, array to a list of options (the first option will be the default value)
* @param string $validation Validation rules
*
* @return string The user input
* @codeCoverageIgnore
*/
public static function prompt($field, $options = null, $validation = null): string
public static function prompt(string $field, $options = null, string $validation = null): string
{
$extra_output = '';
$default = '';
Expand Down Expand Up @@ -270,7 +270,7 @@ public static function prompt($field, $options = null, $validation = null): stri
* @return boolean
* @codeCoverageIgnore
*/
protected static function validate($field, $value, $rules)
protected static function validate(string $field, string $value, string $rules): bool
{
$validation = \Config\Services::validation(null, false);
$validation->setRule($field, null, $rules);
Expand Down Expand Up @@ -380,10 +380,12 @@ public static function wait(int $seconds, bool $countdown = false)

/**
* if operating system === windows
*
* @return boolean
*/
public static function isWindows()
public static function isWindows(): bool
{
return stripos(PHP_OS, 'WIN') === 0;
return stripos(PHP_OS, 'WIN') === 0;
}

//--------------------------------------------------------------------
Expand Down Expand Up @@ -436,7 +438,7 @@ public static function clearScreen()
*
* @return string The color coded string
*/
public static function color(string $text, string $foreground, string $background = null, string $format = null)
public static function color(string $text, string $foreground, string $background = null, string $format = null): string
{
if (static::isWindows() && ! isset($_SERVER['ANSICON']))
{
Expand Down Expand Up @@ -655,7 +657,7 @@ public static function wrap(string $string = null, int $max = 0, int $pad_left =
* Parses the command line it was called from and collects all
* options and valid segments.
*
* I tried to use getopt but had it fail occassionally to find any
* I tried to use getopt but had it fail occasionally to find any
* options but argc has always had our back. We don't have all of the power
* of getopt but this does us just fine.
*/
Expand Down Expand Up @@ -706,7 +708,7 @@ protected static function parseCommandLine()
*
* @return string
*/
public static function getURI()
public static function getURI(): string
{
return implode('/', static::$segments);
}
Expand Down Expand Up @@ -743,7 +745,7 @@ public static function getSegment(int $index)
*
* @return array
*/
public static function getSegments()
public static function getSegments(): array
{
return static::$segments;
}
Expand Down Expand Up @@ -779,7 +781,7 @@ public static function getOption(string $name)
*
* @return array
*/
public static function getOptions()
public static function getOptions(): array
{
return static::$options;
}
Expand Down Expand Up @@ -819,12 +821,12 @@ public static function getOptionString(): string
//--------------------------------------------------------------------

/**
* Returns a well formated table
* Returns a well formatted table
*
* @param array $tbody List of rows
* @param array $thead List of columns
*
* @return string
* @return void
*/
public static function table(array $tbody, array $thead = [])
{
Expand Down
5 changes: 5 additions & 0 deletions system/CLI/CommandRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class CommandRunner extends Controller
*
* @param string $method
* @param array ...$params
*
* @throws \ReflectionException
*/
public function _remap($method, ...$params)
{
Expand All @@ -81,6 +83,7 @@ public function _remap($method, ...$params)
* @param array $params
*
* @return mixed
* @throws \ReflectionException
*/
public function index(array $params)
{
Expand Down Expand Up @@ -128,6 +131,8 @@ protected function runCommand(string $command, array $params)
/**
* Scans all Commands directories and prepares a list
* of each command with it's group and file.
*
* @throws \ReflectionException
*/
protected function createCommandList()
{
Expand Down
2 changes: 1 addition & 1 deletion system/CLI/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __construct(CodeIgniter $app)
* @param boolean $useSafeOutput
*
* @return \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed
* @throws \CodeIgniter\HTTP\RedirectException
* @throws \CodeIgniter\Router\RedirectException
*/
public function run(bool $useSafeOutput = false)
{
Expand Down
2 changes: 1 addition & 1 deletion system/Cache/Handlers/PredisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/

use CodeIgniter\Cache\CacheInterface;
use CodeIgniter\CriticalError;
use CodeIgniter\Exceptions\CriticalError;

class PredisHandler implements CacheInterface
{
Expand Down
28 changes: 9 additions & 19 deletions system/Cache/Handlers/RedisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
* @filesource
*/

use CodeIgniter\Exceptions\CriticalError;
use CodeIgniter\Cache\CacheInterface;

class RedisHandler implements CacheInterface
Expand Down Expand Up @@ -106,28 +105,19 @@ public function initialize()
$config = $this->config;

$this->redis = new \Redis();
if (!$this->redis->connect($config['host'], ($config['host'][0] === '/' ? 0 : $config['port']), $config['timeout']))
{
log_message('error', 'Cache: Redis connection failed. Check your configuration.');
}

try
if (isset($config['password']) && !$this->redis->auth($config['password']))
{
if (! $this->redis->connect($config['host'], ($config['host'][0] === '/' ? 0 : $config['port']), $config['timeout'])
)
{
// log_message('error', 'Cache: Redis connection failed. Check your configuration.');
}

if (isset($config['password']) && ! $this->redis->auth($config['password']))
{
log_message('error', 'Cache: Redis authentication failed.');
}

if (isset($config['database']) && ! $this->redis->select($config['database']))
{
log_message('error', 'Cache: Redis select database failed.');
}
log_message('error', 'Cache: Redis authentication failed.');
}
catch (\RedisException $e)

if (isset($config['database']) && !$this->redis->select($config['database']))
{
throw new CriticalError('Cache: Redis connection refused (' . $e->getMessage() . ')');
log_message('error', 'Cache: Redis select database failed.');
}
}

Expand Down
2 changes: 1 addition & 1 deletion system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ public function cachePage(Cache $config)
*
* @return array
*/
public function getPerformanceStats()
public function getPerformanceStats(): array
{
return [
'startTime' => $this->startTime,
Expand Down
1 change: 0 additions & 1 deletion system/Commands/Help.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
*/

use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;

/**
* CI Help command for the spark script.
Expand Down
2 changes: 1 addition & 1 deletion system/Commands/Utilities/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*RouRouddfdf
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
Expand Down
2 changes: 2 additions & 0 deletions system/Config/BaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ protected function getEnvValue(string $property, string $prefix, string $shortPr
/**
* Provides external libraries a simple way to register one or more
* options into a config file.
*
* @throws \ReflectionException
*/
protected function registerProperties()
{
Expand Down
12 changes: 6 additions & 6 deletions system/Debug/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ protected function render(\Throwable $exception, int $statusCode)
*
* @return array
*/
protected function collectVars(\Throwable $exception, int $statusCode)
protected function collectVars(\Throwable $exception, int $statusCode): array
{
return [
'title' => get_class($exception),
Expand Down Expand Up @@ -356,7 +356,7 @@ protected function determineCodes(\Throwable $exception): array
*
* @return string
*/
public static function cleanPath($file)
public static function cleanPath(string $file): string
{
if (strpos($file, APPPATH) === 0)
{
Expand Down Expand Up @@ -403,13 +403,13 @@ public static function describeMemory(int $bytes): string
/**
* Creates a syntax-highlighted version of a PHP file.
*
* @param $file
* @param $lineNumber
* @param integer $lines
* @param string $file
* @param integer $lineNumber
* @param integer $lines
*
* @return boolean|string
*/
public static function highlightFile($file, $lineNumber, $lines = 15)
public static function highlightFile(string $file, int $lineNumber, int $lines = 15)
{
if (empty($file) || ! is_readable($file))
{
Expand Down
2 changes: 1 addition & 1 deletion system/Debug/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function run($iterations = 1000, $output = true)
*
* @return string
*/
public function getReport()
public function getReport(): string
{
if (empty($this->results))
{
Expand Down
4 changes: 2 additions & 2 deletions system/Debug/Timer.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function getElapsedTime(string $name, int $decimals = 4)
*
* @return array
*/
public function getTimers(int $decimals = 4)
public function getTimers(int $decimals = 4): array
{
$timers = $this->timers;

Expand All @@ -172,7 +172,7 @@ public function getTimers(int $decimals = 4)
*
* @return boolean
*/
public function has(string $name)
public function has(string $name): bool
{
return array_key_exists(strtolower($name), $this->timers);
}
Expand Down
6 changes: 3 additions & 3 deletions system/Debug/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ protected function collectTimelineData($collectors): array
*
* @return array
*/
protected function collectVarData()// : array
protected function collectVarData(): array
{
$data = [];

Expand All @@ -300,7 +300,7 @@ protected function collectVarData()// : array
*
* @return float
*/
protected function roundTo($number, $increments = 5)
protected function roundTo($number, $increments = 5): float
{
$increments = 1 / $increments;

Expand Down Expand Up @@ -440,7 +440,7 @@ public function respond()
*
* @return string
*/
protected function format(string $data, string $format = 'html')
protected function format(string $data, string $format = 'html'): string
{
$data = json_decode($data, true);

Expand Down
10 changes: 5 additions & 5 deletions system/Debug/Toolbar/Collectors/BaseCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ public function timelineData(): array
* Does this Collector have data that should be shown in the
* 'Vars' tab?
*
* @return mixed
* @return boolean
*/
public function hasVarData()
public function hasVarData(): bool
{
return (bool) $this->hasVarData;
}
Expand Down Expand Up @@ -249,7 +249,7 @@ public function display(): array
*
* @return string
*/
public function cleanPath($file)
public function cleanPath(string $file): string
{
if (strpos($file, APPPATH) === 0)
{
Expand Down Expand Up @@ -284,7 +284,7 @@ public function getBadgeValue()
*
* @return boolean
*/
public function isEmpty()
public function isEmpty(): bool
{
return false;
}
Expand All @@ -302,7 +302,7 @@ public function icon(): string
return '';
}

public function getAsArray()
public function getAsArray(): array
{
return [
'title' => $this->getTitle(),
Expand Down
2 changes: 1 addition & 1 deletion system/Debug/Toolbar/Collectors/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Config
{
public static function display()
public static function display(): array
{
$config = config(App::class);

Expand Down
4 changes: 2 additions & 2 deletions system/Debug/Toolbar/Collectors/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function display(): array
*
* @return integer
*/
public function getBadgeValue()
public function getBadgeValue(): int
{
return count(static::$queries);
}
Expand All @@ -251,7 +251,7 @@ public function getTitleDetails(): string
*
* @return boolean
*/
public function isEmpty()
public function isEmpty(): bool
{
return empty(static::$queries);
}
Expand Down
Loading