Skip to content

Commit 32d2573

Browse files
committed
Merge branch 'develop' into database-feature
2 parents 6581002 + 061f174 commit 32d2573

67 files changed

Lines changed: 410 additions & 284 deletions

Some content is hidden

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

contributing/styleguide.rst

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,82 @@ Control Structures
247247
if ( $foo ) $bar += $baz;
248248
else $baz = 'bar';
249249

250+
Docblocks
251+
=========
252+
253+
We use phpDocumentor (phpdoc) to generate the API docs, for all of the source
254+
code inside the `system` folder.
255+
256+
It wants to see a file summary docblock at the top of a PHP file,
257+
before any PHP statements, and then a docblock before each documentable
258+
component, namely any class/interface/trait, and all public and protected
259+
methods/functions/variables. The docblock for a method or function
260+
is expected to describe the parameters, return value, and any exceptions
261+
thrown.
262+
263+
Deviations from the above are considered errors by phpdoc.
264+
265+
An example::
266+
267+
<?php
268+
269+
/**
270+
* CodeIgniter
271+
*
272+
* An open source application development framework for PHP
273+
*
274+
...
275+
*
276+
* @package CodeIgniter
277+
* @author CodeIgniter Dev Team
278+
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
279+
* @license https://opensource.org/licenses/MIT MIT License
280+
* @link https://codeigniter.com
281+
* @since Version 3.0.0
282+
* @filesource
283+
*/
284+
namespace CodeIgniter\Fruit;
285+
use CodeIgniter\Config\BaseConfig;
286+
287+
/**
288+
* Base class for entities in the CodeIgniter\Fruit module.
289+
*
290+
* @property $group
291+
* @property $name
292+
* @property $description
293+
*
294+
* @package CodeIgniter\Fruit
295+
*/
296+
abstract class BaseFruit
297+
{
298+
299+
/**
300+
* The group a fruit belongs to.
301+
*
302+
* @var string
303+
*/
304+
protected $group;
305+
306+
/**
307+
* Fruit constructor.
308+
*
309+
* @param BaseConfig $config
310+
*/
311+
public function __construct(BaseConfig $Config)
312+
{
313+
$this->group = 'Unknown';
314+
}
315+
316+
//--------------------------------------------------------------------
317+
318+
/**
319+
* Model a fruit ripening over time.
320+
*
321+
* @param array $params
322+
*/
323+
abstract public function ripen(array $params);
324+
}
325+
250326
Other
251327
=====
252328

phpdoc.dist.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88
<target>api/build/</target>
99
</transformer>
1010
<files>
11-
<directory>./system</directory>
12-
<ignore>./vendor/*</ignore>
13-
<ignore>./tests/*</ignore>
11+
<directory>system</directory>
12+
<ignore>vendor/*</ignore>
13+
<ignore>tests/*</ignore>
1414
<ignore>Kint/*</ignore>
1515
</files>
1616

1717
<logging>
18-
<level>warn</level>
18+
<level>err</level>
1919
<paths>
2020
<default>api/log/{DATE}.log</default>
2121
<errors>api/{DATE}.errors.log</errors>
2222
</paths>
2323
</logging>
2424

2525
<transformations>
26-
<template name="responsive" />
26+
<template name="responsive-twig" />
2727
</transformations>
2828
</phpdoc>

system/API/ResponseTrait.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace CodeIgniter\API;
1+
<?php
22

33
/**
44
* CodeIgniter
@@ -36,6 +36,8 @@
3636
* @filesource
3737
*/
3838

39+
namespace CodeIgniter\API;
40+
3941
use Config\Format;
4042
use CodeIgniter\HTTP\Response;
4143

system/Autoloader/Autoloader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<?php namespace CodeIgniter\Autoloader;
2-
3-
use Composer\Autoload\ClassLoader;
1+
<?php
42

53
/**
64
* CodeIgniter
@@ -38,6 +36,8 @@
3836
* @filesource
3937
*/
4038

39+
namespace CodeIgniter\Autoloader;
40+
4141
/**
4242
* CodeIgniter Autoloader
4343
*

system/Autoloader/FileLocator.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace CodeIgniter\Autoloader;
1+
<?php
22

33
/**
44
* CodeIgniter
@@ -36,6 +36,8 @@
3636
* @filesource
3737
*/
3838

39+
namespace CodeIgniter\Autoloader;
40+
3941
/**
4042
* Class FileLocator
4143
*
@@ -394,7 +396,7 @@ public function listNamespaceFiles(string $prefix, string $path): array
394396

395397
$files = [];
396398
helper('filesystem');
397-
399+
398400
// autoloader->getNamespace($prefix) returns an array of paths for that namespace
399401
foreach ($this->autoloader->getNamespace($prefix) as $namespacePath)
400402
{

system/CLI/CLI.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ public static function input(string $prefix = null): string
204204
* $email = CLI::prompt('What is your email?', null, 'required|valid_email');
205205
*
206206
* @param string $field Output "field" question
207-
* @param string|array $options String to a defaul value, array to a list of options (the first option will be the default value)
207+
* @param string|array $options String to a default value, array to a list of options (the first option will be the default value)
208208
* @param string $validation Validation rules
209209
*
210210
* @return string The user input
211211
* @codeCoverageIgnore
212212
*/
213-
public static function prompt($field, $options = null, $validation = null): string
213+
public static function prompt(string $field, $options = null, string $validation = null): string
214214
{
215215
$extra_output = '';
216216
$default = '';
@@ -270,7 +270,7 @@ public static function prompt($field, $options = null, $validation = null): stri
270270
* @return boolean
271271
* @codeCoverageIgnore
272272
*/
273-
protected static function validate($field, $value, $rules)
273+
protected static function validate(string $field, string $value, string $rules): bool
274274
{
275275
$validation = \Config\Services::validation(null, false);
276276
$validation->setRule($field, null, $rules);
@@ -380,10 +380,12 @@ public static function wait(int $seconds, bool $countdown = false)
380380

381381
/**
382382
* if operating system === windows
383+
*
384+
* @return boolean
383385
*/
384-
public static function isWindows()
386+
public static function isWindows(): bool
385387
{
386-
return stripos(PHP_OS, 'WIN') === 0;
388+
return stripos(PHP_OS, 'WIN') === 0;
387389
}
388390

389391
//--------------------------------------------------------------------
@@ -436,7 +438,7 @@ public static function clearScreen()
436438
*
437439
* @return string The color coded string
438440
*/
439-
public static function color(string $text, string $foreground, string $background = null, string $format = null)
441+
public static function color(string $text, string $foreground, string $background = null, string $format = null): string
440442
{
441443
if (static::isWindows() && ! isset($_SERVER['ANSICON']))
442444
{
@@ -655,7 +657,7 @@ public static function wrap(string $string = null, int $max = 0, int $pad_left =
655657
* Parses the command line it was called from and collects all
656658
* options and valid segments.
657659
*
658-
* I tried to use getopt but had it fail occassionally to find any
660+
* I tried to use getopt but had it fail occasionally to find any
659661
* options but argc has always had our back. We don't have all of the power
660662
* of getopt but this does us just fine.
661663
*/
@@ -706,7 +708,7 @@ protected static function parseCommandLine()
706708
*
707709
* @return string
708710
*/
709-
public static function getURI()
711+
public static function getURI(): string
710712
{
711713
return implode('/', static::$segments);
712714
}
@@ -743,7 +745,7 @@ public static function getSegment(int $index)
743745
*
744746
* @return array
745747
*/
746-
public static function getSegments()
748+
public static function getSegments(): array
747749
{
748750
return static::$segments;
749751
}
@@ -779,7 +781,7 @@ public static function getOption(string $name)
779781
*
780782
* @return array
781783
*/
782-
public static function getOptions()
784+
public static function getOptions(): array
783785
{
784786
return static::$options;
785787
}
@@ -819,12 +821,12 @@ public static function getOptionString(): string
819821
//--------------------------------------------------------------------
820822

821823
/**
822-
* Returns a well formated table
824+
* Returns a well formatted table
823825
*
824826
* @param array $tbody List of rows
825827
* @param array $thead List of columns
826828
*
827-
* @return string
829+
* @return void
828830
*/
829831
public static function table(array $tbody, array $thead = [])
830832
{

system/CLI/CommandRunner.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class CommandRunner extends Controller
6363
*
6464
* @param string $method
6565
* @param array ...$params
66+
*
67+
* @throws \ReflectionException
6668
*/
6769
public function _remap($method, ...$params)
6870
{
@@ -81,6 +83,7 @@ public function _remap($method, ...$params)
8183
* @param array $params
8284
*
8385
* @return mixed
86+
* @throws \ReflectionException
8487
*/
8588
public function index(array $params)
8689
{
@@ -128,6 +131,8 @@ protected function runCommand(string $command, array $params)
128131
/**
129132
* Scans all Commands directories and prepares a list
130133
* of each command with it's group and file.
134+
*
135+
* @throws \ReflectionException
131136
*/
132137
protected function createCommandList()
133138
{

system/CLI/Console.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function __construct(CodeIgniter $app)
6868
* @param boolean $useSafeOutput
6969
*
7070
* @return \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed
71-
* @throws \CodeIgniter\HTTP\RedirectException
71+
* @throws \CodeIgniter\Router\RedirectException
7272
*/
7373
public function run(bool $useSafeOutput = false)
7474
{

system/Cache/Handlers/PredisHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*/
3838

3939
use CodeIgniter\Cache\CacheInterface;
40-
use CodeIgniter\CriticalError;
40+
use CodeIgniter\Exceptions\CriticalError;
4141

4242
class PredisHandler implements CacheInterface
4343
{

system/Cache/Handlers/RedisHandler.php

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
* @filesource
3737
*/
3838

39-
use CodeIgniter\Exceptions\CriticalError;
4039
use CodeIgniter\Cache\CacheInterface;
4140

4241
class RedisHandler implements CacheInterface
@@ -106,28 +105,19 @@ public function initialize()
106105
$config = $this->config;
107106

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

110-
try
113+
if (isset($config['password']) && !$this->redis->auth($config['password']))
111114
{
112-
if (! $this->redis->connect($config['host'], ($config['host'][0] === '/' ? 0 : $config['port']), $config['timeout'])
113-
)
114-
{
115-
// log_message('error', 'Cache: Redis connection failed. Check your configuration.');
116-
}
117-
118-
if (isset($config['password']) && ! $this->redis->auth($config['password']))
119-
{
120-
log_message('error', 'Cache: Redis authentication failed.');
121-
}
122-
123-
if (isset($config['database']) && ! $this->redis->select($config['database']))
124-
{
125-
log_message('error', 'Cache: Redis select database failed.');
126-
}
115+
log_message('error', 'Cache: Redis authentication failed.');
127116
}
128-
catch (\RedisException $e)
117+
118+
if (isset($config['database']) && !$this->redis->select($config['database']))
129119
{
130-
throw new CriticalError('Cache: Redis connection refused (' . $e->getMessage() . ')');
120+
log_message('error', 'Cache: Redis select database failed.');
131121
}
132122
}
133123

0 commit comments

Comments
 (0)