Skip to content

Commit 34b7657

Browse files
authored
Merge pull request #1951 from atishamte/system
System typos changes & code cleanup
2 parents 2db456a + 93d2c50 commit 34b7657

84 files changed

Lines changed: 770 additions & 553 deletions

File tree

Some content is hidden

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

system/CLI/BaseCommand.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ abstract public function run(array $params);
142142
* @param array $params
143143
*
144144
* @return mixed
145+
* @throws \ReflectionException
145146
*/
146147
protected function call(string $command, array $params = [])
147148
{
@@ -183,6 +184,8 @@ public function __get(string $key)
183184
{
184185
return $this->$key;
185186
}
187+
188+
return null;
186189
}
187190

188191
//--------------------------------------------------------------------
@@ -192,7 +195,7 @@ public function __get(string $key)
192195
*/
193196
public function showHelp()
194197
{
195-
// 4 spaces insted of tab
198+
// 4 spaces instead of tab
196199
$tab = ' ';
197200
CLI::write(lang('CLI.helpDescription'), 'yellow');
198201
CLI::write($tab . $this->description);
@@ -236,7 +239,7 @@ public function showHelp()
236239
*
237240
* @return integer
238241
*/
239-
public function getPad($array, int $pad)
242+
public function getPad(array $array, int $pad): int
240243
{
241244
$max = 0;
242245
foreach ($array as $key => $value)

system/CLI/CLI.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ public static function color(string $text, string $foreground, string $backgroun
517517
* Get the number of characters in string having encoded characters
518518
* and ignores styles set by the color() function
519519
*
520-
* @param string $string
520+
* @param ?string $string
521521
*
522522
* @return integer
523523
*/
@@ -594,8 +594,8 @@ public static function getHeight(int $default = 32): int
594594
* Displays a progress bar on the CLI. You must call it repeatedly
595595
* to update it. Set $thisStep = false to erase the progress bar.
596596
*
597-
* @param integer $thisStep
598-
* @param integer $totalSteps
597+
* @param integer|boolean $thisStep
598+
* @param integer $totalSteps
599599
*/
600600
public static function showProgress($thisStep = 1, int $totalSteps = 10)
601601
{

system/CLI/CommandRunner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ protected function createCommandList()
197197
*
198198
* @return array
199199
*/
200-
public function getCommands()
200+
public function getCommands(): array
201201
{
202202
return $this->commands;
203203
}

system/CLI/Console.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function __construct(CodeIgniter $app)
7373
* @param boolean $useSafeOutput
7474
*
7575
* @return \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed
76-
* @throws \CodeIgniter\Router\RedirectException
76+
* @throws \Exception
7777
*/
7878
public function run(bool $useSafeOutput = false)
7979
{

system/Cache/Handlers/FileHandler.php

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ protected function writeFile($path, $data, $mode = 'wb')
377377
*
378378
* @return boolean
379379
*/
380-
protected function deleteFiles($path, $del_dir = false, $htdocs = false, $_level = 0)
380+
protected function deleteFiles(string $path, bool $del_dir = false, bool $htdocs = false, int $_level = 0): bool
381381
{
382382
// Trim the trailing slash
383383
$path = rtrim($path, '/\\');
@@ -423,7 +423,7 @@ protected function deleteFiles($path, $del_dir = false, $htdocs = false, $_level
423423
*
424424
* @return array|false
425425
*/
426-
protected function getDirFileInfo($source_dir, $top_level_only = true, $_recursion = false)
426+
protected function getDirFileInfo(string $source_dir, bool $top_level_only = true, bool $_recursion = false)
427427
{
428428
static $_filedata = [];
429429
$relative_path = $source_dir;
@@ -474,45 +474,50 @@ protected function getDirFileInfo($source_dir, $top_level_only = true, $_recursi
474474
*
475475
* @return array|false
476476
*/
477-
protected function getFileInfo(string $file, array $returned_values = ['name', 'server_path', 'size', 'date'])
477+
protected function getFileInfo(string $file, $returned_values = ['name', 'server_path', 'size', 'date'])
478478
{
479479
if (! is_file($file))
480480
{
481481
return false;
482482
}
483483

484+
if (is_string($returned_values))
485+
{
486+
$returned_values = explode(',', $returned_values);
487+
}
488+
484489
foreach ($returned_values as $key)
485490
{
486491
switch ($key)
487492
{
488493
case 'name':
489-
$fileinfo['name'] = basename($file);
494+
$fileInfo['name'] = basename($file);
490495
break;
491496
case 'server_path':
492-
$fileinfo['server_path'] = $file;
497+
$fileInfo['server_path'] = $file;
493498
break;
494499
case 'size':
495-
$fileinfo['size'] = filesize($file);
500+
$fileInfo['size'] = filesize($file);
496501
break;
497502
case 'date':
498-
$fileinfo['date'] = filemtime($file);
503+
$fileInfo['date'] = filemtime($file);
499504
break;
500505
case 'readable':
501-
$fileinfo['readable'] = is_readable($file);
506+
$fileInfo['readable'] = is_readable($file);
502507
break;
503508
case 'writable':
504-
$fileinfo['writable'] = is_writable($file);
509+
$fileInfo['writable'] = is_writable($file);
505510
break;
506511
case 'executable':
507-
$fileinfo['executable'] = is_executable($file);
512+
$fileInfo['executable'] = is_executable($file);
508513
break;
509514
case 'fileperms':
510-
$fileinfo['fileperms'] = fileperms($file);
515+
$fileInfo['fileperms'] = fileperms($file);
511516
break;
512517
}
513518
}
514519

515-
return $fileinfo;
520+
return $fileInfo;
516521
}
517522

518523
//--------------------------------------------------------------------

system/Cache/Handlers/MemcachedHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
namespace CodeIgniter\Cache\Handlers;
3939

4040
use CodeIgniter\Cache\CacheInterface;
41+
use CodeIgniter\Exceptions\CriticalError;
4142

4243
/**
4344
* Mamcached cache handler
@@ -133,7 +134,7 @@ public function initialize()
133134
}
134135
elseif ($this->memcached instanceof \Memcache)
135136
{
136-
// Third parameter is persistance and defaults to TRUE.
137+
// Third parameter is persistence and defaults to TRUE.
137138
$this->memcached->addServer(
138139
$this->config['host'], $this->config['port'], true, $this->config['weight']
139140
);

system/Cache/Handlers/WincacheHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public function getCacheInfo()
215215
* Returns detailed information about the specific item in the cache.
216216
*
217217
* @codeCoverageIgnore
218-
* @param string $key Cache item name.
218+
* @param string $key Cache item name.
219219
*
220220
* @return mixed
221221
*/

system/CodeIgniter.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
namespace CodeIgniter;
3939

40+
use Closure;
4041
use CodeIgniter\Filters\Exceptions\FilterException;
4142
use CodeIgniter\HTTP\DownloadResponse;
4243
use CodeIgniter\HTTP\RedirectResponse;
@@ -51,6 +52,7 @@
5152
use CodeIgniter\HTTP\CLIRequest;
5253
use CodeIgniter\Router\RouteCollectionInterface;
5354
use CodeIgniter\Exceptions\PageNotFoundException;
55+
use Exception;
5456

5557
/**
5658
* This class is the core of the framework, and will analyse the
@@ -281,7 +283,7 @@ public function useSafeOutput(bool $safe = true)
281283
* @param boolean $returnResponse
282284
*
283285
* @return \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed
284-
* @throws \CodeIgniter\Router\RedirectException
286+
* @throws \CodeIgniter\Router\Exceptions\RedirectException
285287
*/
286288
protected function handleRequest(RouteCollectionInterface $routes = null, $cacheConfig, bool $returnResponse = false)
287289
{
@@ -545,7 +547,7 @@ public function displayCache($config)
545547
$cachedResponse = unserialize($cachedResponse);
546548
if (! is_array($cachedResponse) || ! isset($cachedResponse['output']) || ! isset($cachedResponse['headers']))
547549
{
548-
throw new \Exception('Error unserializing page cache');
550+
throw new Exception('Error unserializing page cache');
549551
}
550552

551553
$headers = $cachedResponse['headers'];
@@ -687,7 +689,7 @@ public function displayPerformanceMetrics(string $output): string
687689
* of the config file.
688690
*
689691
* @return string
690-
* @throws \CodeIgniter\Router\RedirectException
692+
* @throws \CodeIgniter\Router\Exceptions\RedirectException
691693
*/
692694
protected function tryToRouteIt(RouteCollectionInterface $routes = null)
693695
{
@@ -849,7 +851,7 @@ protected function display404errors(PageNotFoundException $e)
849851
// Is there a 404 Override available?
850852
if ($override = $this->router->get404Override())
851853
{
852-
if ($override instanceof \Closure)
854+
if ($override instanceof Closure)
853855
{
854856
echo $override($e->getMessage());
855857
}

system/Commands/Database/MigrateLatest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function run(array $params = [])
144144
* @param array $params
145145
* @return boolean
146146
*/
147-
private function isAllNamespace(array $params)
147+
private function isAllNamespace(array $params): bool
148148
{
149149
if (array_search('-all', $params) !== false)
150150
{

system/Commands/Database/MigrateRollback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function run(array $params = [])
164164
* @param array $params
165165
* @return boolean
166166
*/
167-
private function isAllNamespace(array $params)
167+
private function isAllNamespace(array $params): bool
168168
{
169169
if (array_search('-all', $params) !== false)
170170
{

0 commit comments

Comments
 (0)