diff --git a/README.md b/README.md
index 8ab1360..03626c7 100644
--- a/README.md
+++ b/README.md
@@ -31,26 +31,12 @@
## Repository Management
-We use Github issues to track **BUGS** and to track approved **DEVELOPMENT** work packages.
+We use Github issues, in our main repository, to track **BUGS** and to track approved **DEVELOPMENT** work packages.
We use our [forum](http://forum.codeigniter.com) to provide SUPPORT and to discuss
FEATURE REQUESTS.
-If you raise an issue here that pertains to support or a feature request, it will
-be closed! If you are not sure if you have found a bug, raise a thread on the forum first -
-someone else may have encountered the same thing.
-
-Before raising a new Github issue, please check that your bug hasn't already
-been reported or fixed.
-
-We use pull requests (PRs) for CONTRIBUTIONS to the repository.
-We are looking for contributions that address one of the reported bugs or
-approved work packages.
-
-Do not use a PR as a form of feature request.
-Unsolicited contributions will only be considered if they fit nicely
-into the framework roadmap.
-Remember that some components that were part of CodeIgniter 3 are being moved
-to optional packages, with their own repository.
+This repository is a "distribution" one, built by our release preparation script.
+Problems with it can be raised on our forum, or as issues in the main repository.
## Contributing
diff --git a/_support/Controllers/Popcorn.php b/_support/Controllers/Popcorn.php
index b3826d3..8af998d 100644
--- a/_support/Controllers/Popcorn.php
+++ b/_support/Controllers/Popcorn.php
@@ -55,4 +55,23 @@
return $response;
}
+ public function canyon()
+ {
+ echo 'Hello-o-o';
+ }
+
+ public function cat()
+ {
+ }
+
+ public function json()
+ {
+ $this->responsd(['answer' => 42]);
+ }
+
+ public function xml()
+ {
+ $this->respond('cat');
+ }
+
}
diff --git a/_support/Database/Migrations/20160428212500_Create_test_tables.php b/_support/Database/Migrations/20160428212500_Create_test_tables.php
index d81ab34..6bddd8a 100644
--- a/_support/Database/Migrations/20160428212500_Create_test_tables.php
+++ b/_support/Database/Migrations/20160428212500_Create_test_tables.php
@@ -31,6 +31,14 @@
'constraint' => 1,
'default' => '0',
],
+ 'created_at' => [
+ 'type' => 'DATETIME',
+ 'null' => true,
+ ],
+ 'updated_at' => [
+ 'type' => 'DATETIME',
+ 'null' => true,
+ ],
]);
$this->forge->addKey('id', true);
$this->forge->createTable('user', true);
@@ -46,11 +54,25 @@
'type' => 'VARCHAR',
'constraint' => 40,
],
- 'description' => ['type' => 'TEXT'],
- 'created_at' => [
- 'type' => 'DATETIME',
+ 'description' => [
+ 'type' => 'TEXT',
'null' => true,
],
+ 'deleted' => [
+ 'type' => 'TINYINT',
+ 'constraint' => 1,
+ 'default' => '0',
+ ],
+ 'created_at' => [
+ 'type' => 'INTEGER',
+ 'constraint' => 11,
+ 'null' => true,
+ ],
+ 'updated_at' => [
+ 'type' => 'INTEGER',
+ 'constraint' => 11,
+ 'null' => true,
+ ],
]);
$this->forge->addKey('id', true);
$this->forge->createTable('job', true);
@@ -82,6 +104,14 @@
'type' => 'VARCHAR',
'constraint' => 40,
],
+ 'created_at' => [
+ 'type' => 'DATE',
+ 'null' => true,
+ ],
+ 'updated_at' => [
+ 'type' => 'DATE',
+ 'null' => true,
+ ],
]);
$this->forge->addKey('id', true);
$this->forge->createTable('empty', true);
diff --git a/_support/Database/MockConnection.php b/_support/Database/MockConnection.php
index e784053..699595b 100644
--- a/_support/Database/MockConnection.php
+++ b/_support/Database/MockConnection.php
@@ -1,5 +1,6 @@
returnValues['connect'] ?? true;
@@ -82,9 +101,9 @@
* Keep or establish the connection if no queries have been sent for
* a length of time exceeding the server's idle timeout.
*
- * @return mixed
+ * @return boolean
*/
- public function reconnect()
+ public function reconnect(): bool
{
return true;
}
@@ -110,11 +129,11 @@
/**
* Returns a string containing the version of the database being used.
*
- * @return mixed
+ * @return string
*/
- public function getVersion()
+ public function getVersion(): string
{
- return \CodeIgniter\CodeIgniter::CI_VERSION;
+ return CodeIgniter::CI_VERSION;
}
//--------------------------------------------------------------------
@@ -122,11 +141,11 @@
/**
* Executes the query against the database.
*
- * @param $sql
+ * @param string $sql
*
* @return mixed
*/
- protected function execute($sql)
+ protected function execute(string $sql)
{
return $this->returnValues['execute'];
}
@@ -136,7 +155,7 @@
/**
* Returns the total number of rows affected by this query.
*
- * @return mixed
+ * @return int
*/
public function affectedRows(): int
{
@@ -154,7 +173,7 @@
*
* @return array
*/
- public function error()
+ public function error(): array
{
return [
'code' => null,
@@ -169,7 +188,7 @@
*
* @return integer
*/
- public function insertID()
+ public function insertID(): int
{
return $this->connID->insert_id;
}
@@ -183,7 +202,7 @@
*
* @return string
*/
- protected function _listTables($constrainByPrefix = false): string
+ protected function _listTables(bool $constrainByPrefix = false): string
{
return '';
}
diff --git a/_support/Database/MockResult.php b/_support/Database/MockResult.php
index d33207f..dfe97a9 100644
--- a/_support/Database/MockResult.php
+++ b/_support/Database/MockResult.php
@@ -68,9 +68,9 @@
*
* Overridden by driver classes.
*
- * @return array
+ * @return mixed
*/
- protected function fetchAssoc(): array
+ protected function fetchAssoc()
{
}
diff --git a/_support/Database/MockTestClass.php b/_support/Database/MockTestClass.php
new file mode 100644
index 0000000..232943b
--- /dev/null
+++ b/_support/Database/MockTestClass.php
@@ -0,0 +1,7 @@
+ [],
diff --git a/_support/Models/UserModel.php b/_support/Models/UserModel.php
index c84ca1a..0501882 100644
--- a/_support/Models/UserModel.php
+++ b/_support/Models/UserModel.php
@@ -17,5 +17,11 @@
protected $useSoftDeletes = true;
- protected $dateFormat = 'integer';
+ protected $dateFormat = 'datetime';
+
+ public $name = '';
+
+ public $email = '';
+
+ public $country = '';
}
diff --git a/_support/Models/ValidErrorsModel.php b/_support/Models/ValidErrorsModel.php
index 95a2193..189ac63 100644
--- a/_support/Models/ValidErrorsModel.php
+++ b/_support/Models/ValidErrorsModel.php
@@ -10,7 +10,7 @@
protected $useSoftDeletes = false;
- protected $dateFormat = 'integer';
+ protected $dateFormat = 'int';
protected $allowedFields = [
'name',
diff --git a/_support/Models/ValidModel.php b/_support/Models/ValidModel.php
index a252120..69842d8 100644
--- a/_support/Models/ValidModel.php
+++ b/_support/Models/ValidModel.php
@@ -10,7 +10,7 @@
protected $useSoftDeletes = false;
- protected $dateFormat = 'integer';
+ protected $dateFormat = 'int';
protected $allowedFields = [
'name',
diff --git a/_support/View/MockTable.php b/_support/View/MockTable.php
new file mode 100644
index 0000000..d286b22
--- /dev/null
+++ b/_support/View/MockTable.php
@@ -0,0 +1,17 @@
+
./tests
- ./tests/system
-
-
-
- ./system
-
- ./system
-
-
-
+
+
+
+
diff --git a/public/.htaccess b/public/.htaccess
index adfbcd5..8af50c9 100644
--- a/public/.htaccess
+++ b/public/.htaccess
@@ -1,36 +1,7 @@
-# ----------------------------------------------------------------------
-# Environment Name
-# ----------------------------------------------------------------------
-
-# Sets the environment that CodeIgniter runs under.
-# SetEnv CI_ENVIRONMENT development
-
# Disable directory browsing
Options All -Indexes
# ----------------------------------------------------------------------
-# UTF-8 encoding
-# ----------------------------------------------------------------------
-
-# Use UTF-8 encoding for anything served text/plain or text/html
-AddDefaultCharset utf-8
-
-# Force UTF-8 for a number of file formats
-
- AddCharset utf-8 .atom .css .js .json .rss .vtt .xml
-
-
-# ----------------------------------------------------------------------
-# Activate CORS
-# ----------------------------------------------------------------------
-
-
-
- Header set Access-Control-Allow-Origin "*"
-
-
-
-# ----------------------------------------------------------------------
# Rewrite engine
# ----------------------------------------------------------------------
@@ -43,7 +14,7 @@
# If you installed CodeIgniter in a subfolder, you will need to
# change the following line to match the subfolder you need.
# http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
- RewriteBase /
+ # RewriteBase /
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
@@ -60,12 +31,6 @@
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
- # Disable image hotlinkiing start
- RewriteCond %{HTTP_REFERER} !^$
- RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?example.com [NC]
- RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]
- # Disable image hotlinkiing end
-
# Ensure Authorization header is passed along
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
@@ -80,103 +45,3 @@
# Disable server signature start
ServerSignature Off
# Disable server signature end
-
-# BEGIN Expires
-
- ExpiresActive On
- ExpiresByType text/css "access 1 month"
- ExpiresByType text/html "access 1 month"
- ExpiresByType image/gif "access 1 year"
- ExpiresByType image/png "access 1 year"
- ExpiresByType image/jpg "access 1 year"
- ExpiresByType image/jpeg "access 1 year"
- ExpiresByType image/x-icon "access 1 year"
- ExpiresByType image/svg+xml "access plus 1 month"
- ExpiresByType audio/ogg "access plus 1 year"
- ExpiresByType video/mp4 "access plus 1 year"
- ExpiresByType video/ogg "access plus 1 year"
- ExpiresByType video/webm "access plus 1 year"
- ExpiresByType application/atom+xml "access plus 1 hour"
- ExpiresByType application/rss+xml "access plus 1 hour"
- ExpiresByType application/pdf "access 1 month"
- ExpiresByType application/javascript "access 1 month"
- ExpiresByType text/x-javascript "access 1 month"
- ExpiresByType text/x-component "access plus 1 month"
- ExpiresByType application/x-shockwave-flash "access 1 month"
- ExpiresByType font/opentype "access plus 1 month"
- ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
- ExpiresByType application/x-font-ttf "access plus 1 month"
- ExpiresByType application/font-woff "access plus 1 month"
- ExpiresByType application/font-woff2 "access plus 1 month"
- ExpiresDefault "access 1 month"
-
-# END Expires
-
-# ----------------------------------------------------------------------
-# Gzip compression
-# ----------------------------------------------------------------------
-
-# Start gzip compression
-
- mod_gzip_on Yes
- mod_gzip_dechunk Yes
- mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
- mod_gzip_item_include handler ^cgi-script$
- mod_gzip_item_include mime ^text/.*
- mod_gzip_item_include mime ^application/x-javascript.*
- mod_gzip_item_exclude mime ^image/.*
- mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
-
-# End gzip compression
-
-
-
- # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
-
-
- SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
- RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
-
-
-
- # Compress all output labeled with one of the following MIME-types
- # (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
- # and can remove the `` and `` lines as
- # `AddOutputFilterByType` is still in the core directives)
-
- AddOutputFilterByType DEFLATE application/atom+xml \
- application/javascript \
- application/json \
- application/rss+xml \
- application/vnd.ms-fontobject \
- application/x-font-ttf \
- application/xhtml+xml \
- application/xml \
- application/x-javascript \
- application/x-font \
- application/x-font-truetype \
- application/x-font-otf \
- application/x-font-woff \
- application/x-font-woff2 \
- application/x-font-opentype \
- font/opentype \
- font/ttf \
- font/otf \
- font/eot \
- font/woff \
- font/woff2 \
- image/svg+xml svg svgz \
- image/x-icon \
- text/css \
- text/html \
- text/plain \
- text/x-component \
- text/xml \
- text/javascript \
-
- # For Olders Browsers Which Can't Handle Compression
- BrowserMatch ^Mozilla/4 gzip-only-text/html
- BrowserMatch ^Mozilla/4\.0[678] no-gzip
- BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
-
-
diff --git a/system/API/ResponseTrait.php b/system/API/ResponseTrait.php
index c168e37..3539f25 100644
--- a/system/API/ResponseTrait.php
+++ b/system/API/ResponseTrait.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -97,9 +97,9 @@
* Provides a single, simple method to return an API response, formatted
* to match the requested format, with proper content-type and status code.
*
- * @param null $data
- * @param integer $status
- * @param string $message
+ * @param array|string|null $data
+ * @param integer $status
+ * @param string $message
*
* @return mixed
*/
diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php
index 057c3bd..359e5eb 100644
--- a/system/Autoloader/Autoloader.php
+++ b/system/Autoloader/Autoloader.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Autoloader/FileLocator.php b/system/Autoloader/FileLocator.php
index 38ea283..b247730 100644
--- a/system/Autoloader/FileLocator.php
+++ b/system/Autoloader/FileLocator.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -49,6 +49,8 @@
class FileLocator
{
/**
+ * The Autoloader to use.
+ *
* @var \CodeIgniter\Autoloader\Autoloader
*/
protected $autoloader;
@@ -261,6 +263,8 @@
//--------------------------------------------------------------------
/**
+ * Return the namespace mappings we know about.
+ *
* @param string|null $prefix
*
* @return array|string
diff --git a/system/CLI/BaseCommand.php b/system/CLI/BaseCommand.php
index 154a028..9358d4a 100644
--- a/system/CLI/BaseCommand.php
+++ b/system/CLI/BaseCommand.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -142,6 +142,7 @@
* @param array $params
*
* @return mixed
+ * @throws \ReflectionException
*/
protected function call(string $command, array $params = [])
{
@@ -183,6 +184,8 @@
{
return $this->$key;
}
+
+ return null;
}
//--------------------------------------------------------------------
@@ -192,7 +195,7 @@
*/
public function showHelp()
{
- // 4 spaces insted of tab
+ // 4 spaces instead of tab
$tab = ' ';
CLI::write(lang('CLI.helpDescription'), 'yellow');
CLI::write($tab . $this->description);
@@ -236,7 +239,7 @@
*
* @return integer
*/
- public function getPad($array, int $pad)
+ public function getPad(array $array, int $pad): int
{
$max = 0;
foreach ($array as $key => $value)
diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php
index 68614ce..eb13b2a 100644
--- a/system/CLI/CLI.php
+++ b/system/CLI/CLI.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -41,10 +41,7 @@
use CodeIgniter\CLI\Exceptions\CLIException;
/**
- * Class CLI
- *
- * Tools to interact with that request since CLI requests are not
- * static like HTTP requests might be.
+ * Set of static methods useful for CLI request handling.
*
* Portions of this code were initially from the FuelPHP Framework,
* version 1.7.x, and used here under the MIT license they were
@@ -61,7 +58,7 @@
* an argument of "0".
* These have been flagged to ignore for code coverage purposes.
*
- * @package CodeIgniter\HTTP
+ * @package CodeIgniter\CLI
*/
class CLI
{
@@ -594,8 +591,8 @@
* Displays a progress bar on the CLI. You must call it repeatedly
* to update it. Set $thisStep = false to erase the progress bar.
*
- * @param integer $thisStep
- * @param integer $totalSteps
+ * @param integer|boolean $thisStep
+ * @param integer $totalSteps
*/
public static function showProgress($thisStep = 1, int $totalSteps = 10)
{
diff --git a/system/CLI/CommandRunner.php b/system/CLI/CommandRunner.php
index 3e273db..00c7874 100644
--- a/system/CLI/CommandRunner.php
+++ b/system/CLI/CommandRunner.php
@@ -33,7 +33,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -56,6 +56,8 @@
protected $commands = [];
/**
+ * Message logger.
+ *
* @var \CodeIgniter\Log\Logger
*/
protected $logger;
@@ -85,6 +87,8 @@
//--------------------------------------------------------------------
/**
+ * Default command.
+ *
* @param array $params
*
* @return mixed
@@ -197,7 +201,7 @@
*
* @return array
*/
- public function getCommands()
+ public function getCommands(): array
{
return $this->commands;
}
diff --git a/system/CLI/Console.php b/system/CLI/Console.php
index a9804ba..43457b9 100644
--- a/system/CLI/Console.php
+++ b/system/CLI/Console.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -73,7 +73,7 @@
* @param boolean $useSafeOutput
*
* @return \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed
- * @throws \CodeIgniter\Router\RedirectException
+ * @throws \Exception
*/
public function run(bool $useSafeOutput = false)
{
diff --git a/system/Cache/CacheFactory.php b/system/Cache/CacheFactory.php
index 49e360e..da2246d 100644
--- a/system/Cache/CacheFactory.php
+++ b/system/Cache/CacheFactory.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Cache/CacheInterface.php b/system/Cache/CacheInterface.php
index b4ea914..2206db1 100644
--- a/system/Cache/CacheInterface.php
+++ b/system/Cache/CacheInterface.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Cache/Handlers/DummyHandler.php b/system/Cache/Handlers/DummyHandler.php
index cf13608..a123a80 100644
--- a/system/Cache/Handlers/DummyHandler.php
+++ b/system/Cache/Handlers/DummyHandler.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Cache/Handlers/FileHandler.php b/system/Cache/Handlers/FileHandler.php
index 8bbe5ea..a33f893 100644
--- a/system/Cache/Handlers/FileHandler.php
+++ b/system/Cache/Handlers/FileHandler.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -63,6 +63,12 @@
//--------------------------------------------------------------------
+ /**
+ * Constructor.
+ *
+ * @param type $config
+ * @throws type
+ */
public function __construct($config)
{
$path = ! empty($config->storePath) ? $config->storePath : WRITEPATH . 'cache';
@@ -377,7 +383,7 @@
*
* @return boolean
*/
- protected function deleteFiles($path, $del_dir = false, $htdocs = false, $_level = 0)
+ protected function deleteFiles(string $path, bool $del_dir = false, bool $htdocs = false, int $_level = 0): bool
{
// Trim the trailing slash
$path = rtrim($path, '/\\');
@@ -423,7 +429,7 @@
*
* @return array|false
*/
- protected function getDirFileInfo($source_dir, $top_level_only = true, $_recursion = false)
+ protected function getDirFileInfo(string $source_dir, bool $top_level_only = true, bool $_recursion = false)
{
static $_filedata = [];
$relative_path = $source_dir;
@@ -474,45 +480,50 @@
*
* @return array|false
*/
- protected function getFileInfo(string $file, array $returned_values = ['name', 'server_path', 'size', 'date'])
+ protected function getFileInfo(string $file, $returned_values = ['name', 'server_path', 'size', 'date'])
{
if (! is_file($file))
{
return false;
}
+ if (is_string($returned_values))
+ {
+ $returned_values = explode(',', $returned_values);
+ }
+
foreach ($returned_values as $key)
{
switch ($key)
{
case 'name':
- $fileinfo['name'] = basename($file);
+ $fileInfo['name'] = basename($file);
break;
case 'server_path':
- $fileinfo['server_path'] = $file;
+ $fileInfo['server_path'] = $file;
break;
case 'size':
- $fileinfo['size'] = filesize($file);
+ $fileInfo['size'] = filesize($file);
break;
case 'date':
- $fileinfo['date'] = filemtime($file);
+ $fileInfo['date'] = filemtime($file);
break;
case 'readable':
- $fileinfo['readable'] = is_readable($file);
+ $fileInfo['readable'] = is_readable($file);
break;
case 'writable':
- $fileinfo['writable'] = is_writable($file);
+ $fileInfo['writable'] = is_writable($file);
break;
case 'executable':
- $fileinfo['executable'] = is_executable($file);
+ $fileInfo['executable'] = is_executable($file);
break;
case 'fileperms':
- $fileinfo['fileperms'] = fileperms($file);
+ $fileInfo['fileperms'] = fileperms($file);
break;
}
}
- return $fileinfo;
+ return $fileInfo;
}
//--------------------------------------------------------------------
diff --git a/system/Cache/Handlers/MemcachedHandler.php b/system/Cache/Handlers/MemcachedHandler.php
index 8950257..07a307d 100644
--- a/system/Cache/Handlers/MemcachedHandler.php
+++ b/system/Cache/Handlers/MemcachedHandler.php
@@ -31,13 +31,14 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
namespace CodeIgniter\Cache\Handlers;
use CodeIgniter\Cache\CacheInterface;
+use CodeIgniter\Exceptions\CriticalError;
/**
* Mamcached cache handler
@@ -73,6 +74,12 @@
//--------------------------------------------------------------------
+ /**
+ * Constructor.
+ *
+ * @param type $config
+ * @throws type
+ */
public function __construct($config)
{
$config = (array)$config;
@@ -133,7 +140,7 @@
}
elseif ($this->memcached instanceof \Memcache)
{
- // Third parameter is persistance and defaults to TRUE.
+ // Third parameter is persistence and defaults to TRUE.
$this->memcached->addServer(
$this->config['host'], $this->config['port'], true, $this->config['weight']
);
@@ -158,7 +165,7 @@
$data = $this->memcached->get($key);
// check for unmatched key
- if ($this->memcached->getResultCode()==\Memcached::RES_NOTFOUND)
+ if ($this->memcached->getResultCode() === \Memcached::RES_NOTFOUND)
{
return null;
}
@@ -166,10 +173,10 @@
elseif ($this->memcached instanceof \Memcache)
{
$flags = false;
- $data = $this->memcached->get($key, $flags);
+ $data = $this->memcached->get($key, $flags);
// check for unmatched key (i.e. $flags is untouched)
- if ($flags===false)
+ if ($flags === false)
{
return null;
}
diff --git a/system/Cache/Handlers/PredisHandler.php b/system/Cache/Handlers/PredisHandler.php
index 0f643e0..847e183 100644
--- a/system/Cache/Handlers/PredisHandler.php
+++ b/system/Cache/Handlers/PredisHandler.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -76,6 +76,12 @@
//--------------------------------------------------------------------
+ /**
+ * Constructor.
+ *
+ * @param type $config
+ * @throws type
+ */
public function __construct($config)
{
$this->prefix = $config->prefix ?: '';
diff --git a/system/Cache/Handlers/RedisHandler.php b/system/Cache/Handlers/RedisHandler.php
index 248e9bd..a0a9d45 100644
--- a/system/Cache/Handlers/RedisHandler.php
+++ b/system/Cache/Handlers/RedisHandler.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -76,6 +76,12 @@
//--------------------------------------------------------------------
+ /**
+ * Constructor.
+ *
+ * @param type $config
+ * @throws type
+ */
public function __construct($config)
{
$config = (array)$config;
diff --git a/system/Cache/Handlers/WincacheHandler.php b/system/Cache/Handlers/WincacheHandler.php
index c619f26..f1a29d2 100644
--- a/system/Cache/Handlers/WincacheHandler.php
+++ b/system/Cache/Handlers/WincacheHandler.php
@@ -33,7 +33,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -58,6 +58,12 @@
//--------------------------------------------------------------------
+ /**
+ * Constructor.
+ *
+ * @param type $config
+ * @throws type
+ */
public function __construct($config)
{
$this->prefix = $config->prefix ?: '';
diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php
index 59a46d5..e518db4 100644
--- a/system/CodeIgniter.php
+++ b/system/CodeIgniter.php
@@ -31,12 +31,13 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
namespace CodeIgniter;
+use Closure;
use CodeIgniter\Filters\Exceptions\FilterException;
use CodeIgniter\HTTP\DownloadResponse;
use CodeIgniter\HTTP\RedirectResponse;
@@ -51,6 +52,7 @@
use CodeIgniter\HTTP\CLIRequest;
use CodeIgniter\Router\RouteCollectionInterface;
use CodeIgniter\Exceptions\PageNotFoundException;
+use Exception;
/**
* This class is the core of the framework, and will analyse the
@@ -63,7 +65,7 @@
/**
* The current version of CodeIgniter Framework
*/
- const CI_VERSION = '4.0.0-beta.2';
+ const CI_VERSION = '4.0.0-beta.3';
/**
* App startup time.
@@ -159,6 +161,11 @@
//--------------------------------------------------------------------
+ /**
+ * Constructor.
+ *
+ * @param type $config
+ */
public function __construct($config)
{
$this->startTime = microtime(true);
@@ -281,7 +288,7 @@
* @param boolean $returnResponse
*
* @return \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed
- * @throws \CodeIgniter\Router\RedirectException
+ * @throws \CodeIgniter\Router\Exceptions\RedirectException
*/
protected function handleRequest(RouteCollectionInterface $routes = null, $cacheConfig, bool $returnResponse = false)
{
@@ -545,7 +552,7 @@
$cachedResponse = unserialize($cachedResponse);
if (! is_array($cachedResponse) || ! isset($cachedResponse['output']) || ! isset($cachedResponse['headers']))
{
- throw new \Exception('Error unserializing page cache');
+ throw new Exception('Error unserializing page cache');
}
$headers = $cachedResponse['headers'];
@@ -687,7 +694,7 @@
* of the config file.
*
* @return string
- * @throws \CodeIgniter\Router\RedirectException
+ * @throws \CodeIgniter\Router\Exceptions\RedirectException
*/
protected function tryToRouteIt(RouteCollectionInterface $routes = null)
{
@@ -849,7 +856,7 @@
// Is there a 404 Override available?
if ($override = $this->router->get404Override())
{
- if ($override instanceof \Closure)
+ if ($override instanceof Closure)
{
echo $override($e->getMessage());
}
diff --git a/system/Commands/Database/CreateMigration.php b/system/Commands/Database/CreateMigration.php
index dcebb41..cc00665 100644
--- a/system/Commands/Database/CreateMigration.php
+++ b/system/Commands/Database/CreateMigration.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Commands/Database/MigrateCurrent.php b/system/Commands/Database/MigrateCurrent.php
index 7745d6b..2ca0fb6 100644
--- a/system/Commands/Database/MigrateCurrent.php
+++ b/system/Commands/Database/MigrateCurrent.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Commands/Database/MigrateLatest.php b/system/Commands/Database/MigrateLatest.php
index b98abb0..d04f5ac 100644
--- a/system/Commands/Database/MigrateLatest.php
+++ b/system/Commands/Database/MigrateLatest.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -144,7 +144,7 @@
* @param array $params
* @return boolean
*/
- private function isAllNamespace(array $params)
+ private function isAllNamespace(array $params): bool
{
if (array_search('-all', $params) !== false)
{
diff --git a/system/Commands/Database/MigrateRefresh.php b/system/Commands/Database/MigrateRefresh.php
index 296d23e..e56d563 100644
--- a/system/Commands/Database/MigrateRefresh.php
+++ b/system/Commands/Database/MigrateRefresh.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Commands/Database/MigrateRollback.php b/system/Commands/Database/MigrateRollback.php
index c54d3b7..3d7cf17 100644
--- a/system/Commands/Database/MigrateRollback.php
+++ b/system/Commands/Database/MigrateRollback.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -164,7 +164,7 @@
* @param array $params
* @return boolean
*/
- private function isAllNamespace(array $params)
+ private function isAllNamespace(array $params): bool
{
if (array_search('-all', $params) !== false)
{
diff --git a/system/Commands/Database/MigrateStatus.php b/system/Commands/Database/MigrateStatus.php
index 01d206a..147e738 100644
--- a/system/Commands/Database/MigrateStatus.php
+++ b/system/Commands/Database/MigrateStatus.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -96,6 +96,11 @@
'-g' => 'Set database group',
];
+ /**
+ * Namespaces to ignore when looking for migrations.
+ *
+ * @var type
+ */
protected $ignoredNamespaces = [
'CodeIgniter',
'Config',
@@ -118,7 +123,7 @@
$runner->setGroup($group);
}
- // Get all namespaces form PSR4 paths.
+ // Get all namespaces from PSR4 paths.
$config = new Autoload();
$namespaces = $config->psr4;
diff --git a/system/Commands/Database/MigrateVersion.php b/system/Commands/Database/MigrateVersion.php
index 5757e32..d781f68 100644
--- a/system/Commands/Database/MigrateVersion.php
+++ b/system/Commands/Database/MigrateVersion.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Commands/Database/Seed.php b/system/Commands/Database/Seed.php
index c48cd87..f19445f 100644
--- a/system/Commands/Database/Seed.php
+++ b/system/Commands/Database/Seed.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Commands/Help.php b/system/Commands/Help.php
index 25610c6..0678a23 100644
--- a/system/Commands/Help.php
+++ b/system/Commands/Help.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Commands/ListCommands.php b/system/Commands/ListCommands.php
index cb84a85..75e0708 100644
--- a/system/Commands/ListCommands.php
+++ b/system/Commands/ListCommands.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -176,13 +176,13 @@
* Pads our string out so that all titles are the same length to nicely line up descriptions.
*
* @param string $item
- * @param $max
+ * @param integer $max
* @param integer $extra // How many extra spaces to add at the end
* @param integer $indent
*
- * @return array
+ * @return string
*/
- protected function padTitle(string $item, $max, $extra = 2, $indent = 0)
+ protected function padTitle(string $item, int $max, int $extra = 2, int $indent = 0): string
{
$max += $extra + $indent;
diff --git a/system/Commands/Server/Serve.php b/system/Commands/Server/Serve.php
index c07996c..8ca15ab 100644
--- a/system/Commands/Server/Serve.php
+++ b/system/Commands/Server/Serve.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Commands/Server/rewrite.php b/system/Commands/Server/rewrite.php
index f3c0dd7..94b7d15 100644
--- a/system/Commands/Server/rewrite.php
+++ b/system/Commands/Server/rewrite.php
@@ -14,11 +14,6 @@
{
return;
}
-
-// If we're serving the site locally, then we need
-// to let the application know that we're in development mode
-$_SERVER['CI_ENVIRONMENT'] = 'development';
-
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
// Front Controller path - expected to be in the default folder
diff --git a/system/Commands/Sessions/CreateMigration.php b/system/Commands/Sessions/CreateMigration.php
index ac8a90b..052eb07 100644
--- a/system/Commands/Sessions/CreateMigration.php
+++ b/system/Commands/Sessions/CreateMigration.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Commands/Utilities/Namespaces.php b/system/Commands/Utilities/Namespaces.php
index 9a2a00e..36e0c77 100644
--- a/system/Commands/Utilities/Namespaces.php
+++ b/system/Commands/Utilities/Namespaces.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Commands/Utilities/Routes.php b/system/Commands/Utilities/Routes.php
index 480b612..ad9f3a5 100644
--- a/system/Commands/Utilities/Routes.php
+++ b/system/Commands/Utilities/Routes.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Common.php b/system/Common.php
index f0907f7..a0ca219 100644
--- a/system/Common.php
+++ b/system/Common.php
@@ -32,14 +32,22 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
+use CodeIgniter\Config\Config;
+use CodeIgniter\Files\Exceptions\FileNotFoundException;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
+use CodeIgniter\HTTP\URI;
+use Config\App;
+use Config\Database;
+use Config\Logger;
use Config\Services;
+use Tests\Support\Log\TestLogger;
+use Zend\Escaper\Escaper;
/**
* Common Functions
@@ -97,7 +105,7 @@
*/
function config(string $name, bool $getShared = true)
{
- return \CodeIgniter\Config\Config::get($name, $getShared);
+ return Config::get($name, $getShared);
}
}
@@ -126,7 +134,7 @@
*/
function db_connect($db = null, bool $getShared = true)
{
- return \Config\Database::connect($db, $getShared);
+ return Database::connect($db, $getShared);
}
}
@@ -182,6 +190,7 @@
* @param string|null $cacheName
*
* @return string
+ * @throws \ReflectionException
*/
function view_cell(string $library, $params = null, int $ttl = 0, string $cacheName = null): string
{
@@ -281,7 +290,7 @@
if (! in_array($context, ['html', 'js', 'css', 'url', 'attr']))
{
- throw new \InvalidArgumentException('Invalid escape context provided.');
+ throw new InvalidArgumentException('Invalid escape context provided.');
}
if ($context === 'attr')
@@ -296,12 +305,12 @@
static $escaper;
if (! $escaper)
{
- $escaper = new \Zend\Escaper\Escaper($encoding);
+ $escaper = new Escaper($encoding);
}
if ($encoding && $escaper->getEncoding() !== $encoding)
{
- $escaper = new \Zend\Escaper\Escaper($encoding);
+ $escaper = new Escaper($encoding);
}
$data = $escaper->$method($data);
@@ -471,7 +480,7 @@
// for asserting that logs were called in the test code.
if (ENVIRONMENT === 'testing')
{
- $logger = new \Tests\Support\Log\TestLogger(new \Config\Logger());
+ $logger = new TestLogger(new Logger());
return $logger->log($level, $message, $context);
}
@@ -534,27 +543,27 @@
* between ascii characters, like Java\0script.
*
* @param string $str
- * @param boolean $url_encoded
+ * @param boolean $urlEncoded
*
* @return string
*/
- function remove_invisible_characters(string $str, bool $url_encoded = true): string
+ function remove_invisible_characters(string $str, bool $urlEncoded = true): string
{
- $non_displayables = [];
+ $nonDisplayables = [];
// every control character except newline (dec 10),
// carriage return (dec 13) and horizontal tab (dec 09)
- if ($url_encoded)
+ if ($urlEncoded)
{
- $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15
- $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31
+ $nonDisplayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15
+ $nonDisplayables[] = '/%1[0-9a-f]/'; // url encoded 16-31
}
- $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
+ $nonDisplayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
do
{
- $str = preg_replace($non_displayables, '', $str, -1, $count);
+ $str = preg_replace($nonDisplayables, '', $str, -1, $count);
}
while ($count);
@@ -611,7 +620,7 @@
if (empty($path))
{
- throw \CodeIgniter\Files\Exceptions\FileNotFoundException::forFileNotFound($filename);
+ throw FileNotFoundException::forFileNotFound($filename);
}
$includes[] = $path;
@@ -687,7 +696,7 @@
*/
function app_timezone(): string
{
- $config = config(\Config\App::class);
+ $config = config(App::class);
return $config->appTimezone;
}
@@ -706,7 +715,7 @@
*/
function csrf_token(): string
{
- $config = config(\Config\App::class);
+ $config = config(App::class);
return $config->CSRFTokenName;
}
@@ -797,7 +806,7 @@
$uri = $request->uri;
$uri->setScheme('https');
- $uri = \CodeIgniter\HTTP\URI::createURIString(
+ $uri = URI::createURIString(
$uri->getScheme(), $uri->getAuthority(true), $uri->getPath(), // Absolute URIs should use a "/" for an empty path
$uri->getQuery(), $uri->getFragment()
);
@@ -942,6 +951,7 @@
*
* @return boolean
*
+ * @throws \Exception
* @codeCoverageIgnore Not practical to test, as travis runs on linux
*/
function is_really_writable(string $file): bool
@@ -996,7 +1006,7 @@
*/
function slash_item(string $item): ?string
{
- $config = config(\Config\App::class);
+ $config = config(App::class);
$configItem = $config->{$item};
if (! isset($configItem) || empty(trim($configItem)))
diff --git a/system/ComposerScripts.php b/system/ComposerScripts.php
index d7ebade..a4395cb 100644
--- a/system/ComposerScripts.php
+++ b/system/ComposerScripts.php
@@ -32,12 +32,14 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
namespace CodeIgniter;
+use ReflectionClass;
+
/**
* ComposerScripts
*
@@ -51,6 +53,11 @@
*/
class ComposerScripts
{
+ /**
+ * Base path to use.
+ *
+ * @var type
+ */
protected static $basePath = 'ThirdParty/';
/**
@@ -76,7 +83,7 @@
*
* @return boolean
*/
- protected static function moveFile(string $source, string $destination)
+ protected static function moveFile(string $source, string $destination): bool
{
$source = realpath($source);
@@ -105,7 +112,7 @@
*/
protected static function getClassFilePath(string $class)
{
- $reflector = new \ReflectionClass($class);
+ $reflector = new ReflectionClass($class);
return $reflector->getFileName();
}
diff --git a/system/Config/AutoloadConfig.php b/system/Config/AutoloadConfig.php
index bd3d87f..e68aa6c 100644
--- a/system/Config/AutoloadConfig.php
+++ b/system/Config/AutoloadConfig.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -115,78 +115,15 @@
* ];
*/
$this->classmap = [
- 'CodeIgniter\CodeIgniter' => SYSTEMPATH . 'CodeIgniter.php',
- 'CodeIgniter\CLI\CLI' => SYSTEMPATH . 'CLI/CLI.php',
- 'CodeIgniter\Cache\CacheFactory' => SYSTEMPATH . 'Cache/CacheFactory.php',
- 'CodeIgniter\Cache\CacheInterface' => SYSTEMPATH . 'Cache/CacheInterface.php',
- 'CodeIgniter\Cache\Handlers\DummyHandler' => SYSTEMPATH . 'Cache/Handlers/DummyHandler.php',
- 'CodeIgniter\Cache\Handlers\FileHandler' => SYSTEMPATH . 'Cache/Handlers/FileHandler.php',
- 'CodeIgniter\Cache\Handlers\MemcachedHandler' => SYSTEMPATH . 'Cache/Handlers/MemcachedHandler.php',
- 'CodeIgniter\Cache\Handlers\PredisHandler' => SYSTEMPATH . 'Cache/Handlers/PredisHandler.php',
- 'CodeIgniter\Cache\Handlers\RedisHandler' => SYSTEMPATH . 'Cache/Handlers/RedisHandler.php',
- 'CodeIgniter\Cache\Handlers\WincacheHandler' => SYSTEMPATH . 'Cache/Handlers/WincacheHandler.php',
- 'CodeIgniter\Controller' => SYSTEMPATH . 'Controller.php',
- 'CodeIgniter\Config\AutoloadConfig' => SYSTEMPATH . 'Config/Autoload.php',
- 'CodeIgniter\Config\BaseConfig' => SYSTEMPATH . 'Config/BaseConfig.php',
- 'CodeIgniter\Config\Database' => SYSTEMPATH . 'Config/Database.php',
- 'CodeIgniter\Config\Database\Connection' => SYSTEMPATH . 'Config/Database/Connection.php',
- 'CodeIgniter\Config\Database\Connection\MySQLi' => SYSTEMPATH . 'Config/Database/Connection/MySQLi.php',
- 'CodeIgniter\Config\DotEnv' => SYSTEMPATH . 'Config/DotEnv.php',
- 'CodeIgniter\Database\BaseBuilder' => SYSTEMPATH . 'Database/BaseBuilder.php',
- 'CodeIgniter\Database\BaseConnection' => SYSTEMPATH . 'Database/BaseConnection.php',
- 'CodeIgniter\Database\BaseResult' => SYSTEMPATH . 'Database/BaseResult.php',
- 'CodeIgniter\Database\Config' => SYSTEMPATH . 'Database/Config.php',
- 'CodeIgniter\Database\ConnectionInterface' => SYSTEMPATH . 'Database/ConnectionInterface.php',
- 'CodeIgniter\Database\Database' => SYSTEMPATH . 'Database/Database.php',
- 'CodeIgniter\Database\Query' => SYSTEMPATH . 'Database/Query.php',
- 'CodeIgniter\Database\QueryInterface' => SYSTEMPATH . 'Database/QueryInterface.php',
- 'CodeIgniter\Database\ResultInterface' => SYSTEMPATH . 'Database/ResultInterface.php',
- 'CodeIgniter\Database\Migration' => SYSTEMPATH . 'Database/Migration.php',
- 'CodeIgniter\Database\MigrationRunner' => SYSTEMPATH . 'Database/MigrationRunner.php',
- 'CodeIgniter\Debug\Exceptions' => SYSTEMPATH . 'Debug/Exceptions.php',
- 'CodeIgniter\Debug\Timer' => SYSTEMPATH . 'Debug/Timer.php',
- 'CodeIgniter\Debug\Iterator' => SYSTEMPATH . 'Debug/Iterator.php',
- 'CodeIgniter\Events\Events' => SYSTEMPATH . 'Events/Events.php',
- 'CodeIgniter\HTTP\CLIRequest' => SYSTEMPATH . 'HTTP/CLIRequest.php',
- 'CodeIgniter\HTTP\ContentSecurityPolicy' => SYSTEMPATH . 'HTTP/ContentSecurityPolicy.php',
- 'CodeIgniter\HTTP\CURLRequest' => SYSTEMPATH . 'HTTP/CURLRequest.php',
- 'CodeIgniter\HTTP\IncomingRequest' => SYSTEMPATH . 'HTTP/IncomingRequest.php',
- 'CodeIgniter\HTTP\Message' => SYSTEMPATH . 'HTTP/Message.php',
- 'CodeIgniter\HTTP\Negotiate' => SYSTEMPATH . 'HTTP/Negotiate.php',
- 'CodeIgniter\HTTP\Request' => SYSTEMPATH . 'HTTP/Request.php',
- 'CodeIgniter\HTTP\RequestInterface' => SYSTEMPATH . 'HTTP/RequestInterface.php',
- 'CodeIgniter\HTTP\Response' => SYSTEMPATH . 'HTTP/Response.php',
- 'CodeIgniter\HTTP\ResponseInterface' => SYSTEMPATH . 'HTTP/ResponseInterface.php',
- 'CodeIgniter\HTTP\URI' => SYSTEMPATH . 'HTTP/URI.php',
- 'CodeIgniter\Log\Logger' => SYSTEMPATH . 'Log/Logger.php',
- 'Psr\Log\AbstractLogger' => SYSTEMPATH . 'ThirdParty/PSR/Log/AbstractLogger.php',
- 'Psr\Log\InvalidArgumentException' => SYSTEMPATH . 'ThirdParty/PSR/Log/InvalidArgumentException.php',
- 'Psr\Log\LoggerAwareInterface' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerAwareInterface.php',
- 'Psr\Log\LoggerAwareTrait' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerAwareTrait.php',
- 'Psr\Log\LoggerInterface' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerInterface.php',
- 'Psr\Log\LoggerTrait' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerTrait.php',
- 'Psr\Log\LogLevel' => SYSTEMPATH . 'ThirdParty/PSR/Log/LogLevel.php',
- 'Psr\Log\NullLogger' => SYSTEMPATH . 'ThirdParty/PSR/Log/NullLogger.php',
- 'CodeIgniter\Log\Handlers\BaseHandler' => SYSTEMPATH . 'Log/Handlers/BaseHandler.php',
- 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => SYSTEMPATH . 'Log/Handlers/ChromeLoggerHandler.php',
- 'CodeIgniter\Log\Handlers\FileHandler' => SYSTEMPATH . 'Log/Handlers/FileHandler.php',
- 'CodeIgniter\Log\Handlers\HandlerInterface' => SYSTEMPATH . 'Log/Handlers/HandlerInterface.php',
- 'CodeIgniter\Router\RouteCollection' => SYSTEMPATH . 'Router/RouteCollection.php',
- 'CodeIgniter\Router\RouteCollectionInterface' => SYSTEMPATH . 'Router/RouteCollectionInterface.php',
- 'CodeIgniter\Router\Router' => SYSTEMPATH . 'Router/Router.php',
- 'CodeIgniter\Router\RouterInterface' => SYSTEMPATH . 'Router/RouterInterface.php',
- 'CodeIgniter\Security\Security' => SYSTEMPATH . 'Security/Security.php',
- 'CodeIgniter\Session\Session' => SYSTEMPATH . 'Session/Session.php',
- 'CodeIgniter\Session\SessionInterface' => SYSTEMPATH . 'Session/SessionInterface.php',
- 'CodeIgniter\Session\Handlers\BaseHandler' => SYSTEMPATH . 'Session/Handlers/BaseHandler.php',
- 'CodeIgniter\Session\Handlers\FileHandler' => SYSTEMPATH . 'Session/Handlers/FileHandler.php',
- 'CodeIgniter\Session\Handlers\MemcachedHandler' => SYSTEMPATH . 'Session/Handlers/MemcachedHandler.php',
- 'CodeIgniter\Session\Handlers\RedisHandler' => SYSTEMPATH . 'Session/Handlers/RedisHandler.php',
- 'CodeIgniter\View\RendererInterface' => SYSTEMPATH . 'View/RendererInterface.php',
- 'CodeIgniter\View\View' => SYSTEMPATH . 'View/View.php',
- 'CodeIgniter\View\Parser' => SYSTEMPATH . 'View/Parser.php',
- 'CodeIgniter\View\Cell' => SYSTEMPATH . 'View/Cell.php',
- 'Zend\Escaper\Escaper' => SYSTEMPATH . 'ThirdParty/ZendEscaper/Escaper.php',
+ 'Psr\Log\AbstractLogger' => SYSTEMPATH . 'ThirdParty/PSR/Log/AbstractLogger.php',
+ 'Psr\Log\InvalidArgumentException' => SYSTEMPATH . 'ThirdParty/PSR/Log/InvalidArgumentException.php',
+ 'Psr\Log\LoggerAwareInterface' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerAwareInterface.php',
+ 'Psr\Log\LoggerAwareTrait' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerAwareTrait.php',
+ 'Psr\Log\LoggerInterface' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerInterface.php',
+ 'Psr\Log\LoggerTrait' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerTrait.php',
+ 'Psr\Log\LogLevel' => SYSTEMPATH . 'ThirdParty/PSR/Log/LogLevel.php',
+ 'Psr\Log\NullLogger' => SYSTEMPATH . 'ThirdParty/PSR/Log/NullLogger.php',
+ 'Zend\Escaper\Escaper' => SYSTEMPATH . 'ThirdParty/ZendEscaper/Escaper.php',
];
if (isset($_SERVER['CI_ENVIRONMENT']) && $_SERVER['CI_ENVIRONMENT'] === 'testing')
diff --git a/system/Config/BaseConfig.php b/system/Config/BaseConfig.php
index 9b1b0be..d297eff 100644
--- a/system/Config/BaseConfig.php
+++ b/system/Config/BaseConfig.php
@@ -33,7 +33,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -57,8 +57,20 @@
*
* @var array
*/
- public static $registrars = [];
+ public static $registrars = [];
+
+ /**
+ * Has module discovery happened yet?
+ *
+ * @var boolean
+ */
protected static $didDiscovery = false;
+
+ /**
+ * The modules configuration.
+ *
+ * @var type
+ */
protected static $moduleConfig;
/**
@@ -181,8 +193,15 @@
if (! static::$didDiscovery)
{
- $locator = \Config\Services::locator();
- static::$registrars = $locator->search('Config/Registrar.php');
+ $locator = \Config\Services::locator();
+ $registrarsFiles = $locator->search('Config/Registrar.php');
+
+ foreach ($registrarsFiles as $file)
+ {
+ $className = $locator->getClassname($file);
+ static::$registrars[] = new $className();
+ }
+
static::$didDiscovery = true;
}
diff --git a/system/Config/BaseService.php b/system/Config/BaseService.php
index aadf04d..b94ef94 100644
--- a/system/Config/BaseService.php
+++ b/system/Config/BaseService.php
@@ -31,12 +31,17 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
namespace CodeIgniter\Config;
+use CodeIgniter\Autoloader\Autoloader;
+use CodeIgniter\Autoloader\FileLocator;
+use Config\Autoload;
+use Config\Modules;
+
/**
* Services Configuration file.
*
@@ -133,13 +138,13 @@
{
if (empty(static::$instances['autoloader']))
{
- static::$instances['autoloader'] = new \CodeIgniter\Autoloader\Autoloader();
+ static::$instances['autoloader'] = new Autoloader();
}
return static::$instances['autoloader'];
}
- return new \CodeIgniter\Autoloader\Autoloader();
+ return new Autoloader();
}
//--------------------------------------------------------------------
@@ -159,7 +164,7 @@
{
if (empty(static::$instances['locator']))
{
- static::$instances['locator'] = new \CodeIgniter\Autoloader\FileLocator(
+ static::$instances['locator'] = new FileLocator(
static::autoloader()
);
}
@@ -167,7 +172,7 @@
return static::$instances['locator'];
}
- return new \CodeIgniter\Autoloader\FileLocator(static::autoloader());
+ return new FileLocator(static::autoloader());
}
//--------------------------------------------------------------------
@@ -208,7 +213,7 @@
if ($init_autoloader)
{
- static::autoloader()->initialize(new \Config\Autoload(), new \Config\Modules());
+ static::autoloader()->initialize(new Autoload(), new Modules());
}
}
diff --git a/system/Config/Config.php b/system/Config/Config.php
index 8fbfd82..ba80348 100644
--- a/system/Config/Config.php
+++ b/system/Config/Config.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Config/DotEnv.php b/system/Config/DotEnv.php
index d078fc7..1b4b58c 100644
--- a/system/Config/DotEnv.php
+++ b/system/Config/DotEnv.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -73,7 +73,7 @@
*
* @return boolean
*/
- public function load()
+ public function load(): bool
{
// We don't want to enforce the presence of a .env file,
// they should be optional.
diff --git a/system/Config/ForeignCharacters.php b/system/Config/ForeignCharacters.php
index b76f18a..39db140 100644
--- a/system/Config/ForeignCharacters.php
+++ b/system/Config/ForeignCharacters.php
@@ -32,21 +32,19 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
namespace CodeIgniter\Config;
+/**
+ * Describes foreign characters for transliteration with the text helper.
+ */
class ForeignCharacters
{
- /*
- | -------------------------------------------------------------------
- | Foreign Characters
- | -------------------------------------------------------------------
- | This file contains an array of foreign characters for transliteration
- | conversion used by the Text helper
- |
+ /**
+ * Without further ado, the list of foreign characters.
*/
public $characterList = [
diff --git a/system/Config/Routes.php b/system/Config/Routes.php
index 8050e21..3cc1b09 100644
--- a/system/Config/Routes.php
+++ b/system/Config/Routes.php
@@ -31,10 +31,12 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
+use CodeIgniter\Exceptions\PageNotFoundException;
+
/**
* System URI Routing
*
@@ -45,10 +47,9 @@
* already loaded up and ready for us to use.
*/
// Prevent access to BaseController
-$routes->add('basecontroller(:any)', function()
-{
- throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
-});
+$routes->add('basecontroller(:any)', function () {
+ throw PageNotFoundException::forPageNotFound();
+});
// Migrations
$routes->cli('migrations/(:segment)/(:segment)', '\CodeIgniter\Commands\MigrationsCommand::$1/$2');
@@ -59,7 +60,6 @@
$routes->cli('ci(:any)', '\CodeIgniter\CLI\CommandRunner::index/$1');
// Prevent access to initController method
-$routes->add('(:any)/initController', function()
-{
- throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
-});
+$routes->add('(:any)/initController', function () {
+ throw PageNotFoundException::forPageNotFound();
+});
diff --git a/system/Config/Services.php b/system/Config/Services.php
index 9cba4cb..9fdcc01 100644
--- a/system/Config/Services.php
+++ b/system/Config/Services.php
@@ -32,16 +32,49 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
namespace CodeIgniter\Config;
+use CodeIgniter\Cache\CacheFactory;
+use CodeIgniter\Debug\Exceptions;
+use CodeIgniter\Debug\Iterator;
+use CodeIgniter\Debug\Timer;
+use CodeIgniter\Debug\Toolbar;
+use CodeIgniter\Filters\Filters;
+use CodeIgniter\Honeypot\Honeypot;
+use CodeIgniter\HTTP\CLIRequest;
+use CodeIgniter\HTTP\CURLRequest;
+use CodeIgniter\HTTP\IncomingRequest;
+use CodeIgniter\HTTP\Negotiate;
+use CodeIgniter\HTTP\RedirectResponse;
+use CodeIgniter\HTTP\RequestInterface;
+use CodeIgniter\HTTP\Response;
+use CodeIgniter\HTTP\ResponseInterface;
+use CodeIgniter\HTTP\URI;
+use CodeIgniter\HTTP\UserAgent;
+use CodeIgniter\Language\Language;
+use CodeIgniter\Pager\Pager;
+use CodeIgniter\Router\RouteCollection;
+use CodeIgniter\Router\RouteCollectionInterface;
+use CodeIgniter\Router\Router;
+use CodeIgniter\Security\Security;
+use CodeIgniter\Session\Session;
+use CodeIgniter\Throttle\Throttler;
+use CodeIgniter\Typography\Typography;
+use CodeIgniter\Validation\Validation;
+use CodeIgniter\View\Cell;
+use CodeIgniter\View\Parser;
use Config\App;
use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Database\MigrationRunner;
use CodeIgniter\View\RendererInterface;
+use Config\Cache;
+use Config\Images;
+use Config\Logger;
+use Config\Migrations;
/**
* Services Configuration file.
@@ -71,7 +104,7 @@
*
* @return \CodeIgniter\Cache\CacheInterface
*/
- public static function cache(\Config\Cache $config = null, bool $getShared = true)
+ public static function cache(Cache $config = null, bool $getShared = true)
{
if ($getShared)
{
@@ -80,10 +113,10 @@
if (! is_object($config))
{
- $config = new \Config\Cache();
+ $config = new Cache();
}
- return \CodeIgniter\Cache\CacheFactory::getHandler($config);
+ return CacheFactory::getHandler($config);
}
//--------------------------------------------------------------------
@@ -97,7 +130,7 @@
*
* @return \CodeIgniter\HTTP\CLIRequest
*/
- public static function clirequest(\Config\App $config = null, bool $getShared = true)
+ public static function clirequest(App $config = null, bool $getShared = true)
{
if ($getShared)
{
@@ -109,7 +142,7 @@
$config = config(App::class);
}
- return new \CodeIgniter\HTTP\CLIRequest($config);
+ return new CLIRequest($config);
}
//--------------------------------------------------------------------
@@ -125,7 +158,7 @@
*
* @return \CodeIgniter\HTTP\CURLRequest
*/
- public static function curlrequest(array $options = [], $response = null, \Config\App $config = null, bool $getShared = true)
+ public static function curlrequest(array $options = [], ResponseInterface $response = null, App $config = null, bool $getShared = true)
{
if ($getShared === true)
{
@@ -139,12 +172,12 @@
if (! is_object($response))
{
- $response = new \CodeIgniter\HTTP\Response($config);
+ $response = new Response($config);
}
- return new \CodeIgniter\HTTP\CURLRequest(
+ return new CURLRequest(
$config,
- new \CodeIgniter\HTTP\URI($options['base_uri'] ?? null),
+ new URI($options['base_uri'] ?? null),
$response,
$options
);
@@ -168,9 +201,9 @@
*/
public static function exceptions(
\Config\Exceptions $config = null,
- \CodeIgniter\HTTP\IncomingRequest $request = null,
- \CodeIgniter\HTTP\Response $response = null,
- $getShared = true
+ IncomingRequest $request = null,
+ Response $response = null,
+ bool $getShared = true
)
{
if ($getShared)
@@ -193,7 +226,7 @@
$response = static::response();
}
- return (new \CodeIgniter\Debug\Exceptions($config, $request, $response));
+ return (new Exceptions($config, $request, $response));
}
//--------------------------------------------------------------------
@@ -221,7 +254,7 @@
$config = new \Config\Filters();
}
- return new \CodeIgniter\Filters\Filters($config, static::request(), static::response());
+ return new Filters($config, static::request(), static::response());
}
//--------------------------------------------------------------------
@@ -235,7 +268,7 @@
*
* @return \CodeIgniter\Honeypot\Honeypot|mixed
*/
- public static function honeypot(BaseConfig $config = null, $getShared = true)
+ public static function honeypot(BaseConfig $config = null, bool $getShared = true)
{
if ($getShared)
{
@@ -247,7 +280,7 @@
$config = new \Config\Honeypot();
}
- return new \CodeIgniter\Honeypot\Honeypot($config);
+ return new Honeypot($config);
}
//--------------------------------------------------------------------
@@ -271,7 +304,7 @@
if (empty($config))
{
- $config = new \Config\Images();
+ $config = new Images();
}
$handler = is_null($handler) ? $config->defaultHandler : $handler;
@@ -292,14 +325,14 @@
*
* @return \CodeIgniter\Debug\Iterator
*/
- public static function iterator($getShared = true)
+ public static function iterator(bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('iterator');
}
- return new \CodeIgniter\Debug\Iterator();
+ return new Iterator();
}
//--------------------------------------------------------------------
@@ -325,7 +358,7 @@
: static::request()
->getLocale();
- return new \CodeIgniter\Language\Language($locale);
+ return new Language($locale);
}
//--------------------------------------------------------------------
@@ -338,19 +371,21 @@
*
* @return \CodeIgniter\Log\Logger
*/
- public static function logger($getShared = true)
+ public static function logger(bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('logger');
}
- return new \CodeIgniter\Log\Logger(new \Config\Logger());
+ return new \CodeIgniter\Log\Logger(new Logger());
}
//--------------------------------------------------------------------
/**
+ * Return the appropriate igration runner.
+ *
* @param \CodeIgniter\Config\BaseConfig $config
* @param \CodeIgniter\Database\ConnectionInterface $db
* @param boolean $getShared
@@ -364,7 +399,7 @@
return static::getSharedInstance('migrations', $config, $db);
}
- $config = empty($config) ? new \Config\Migrations() : $config;
+ $config = empty($config) ? new Migrations() : $config;
return new MigrationRunner($config, $db);
}
@@ -381,7 +416,7 @@
*
* @return \CodeIgniter\HTTP\Negotiate
*/
- public static function negotiator(\CodeIgniter\HTTP\RequestInterface $request = null, bool $getShared = true)
+ public static function negotiator(RequestInterface $request = null, bool $getShared = true)
{
if ($getShared)
{
@@ -393,12 +428,14 @@
$request = static::request();
}
- return new \CodeIgniter\HTTP\Negotiate($request);
+ return new Negotiate($request);
}
//--------------------------------------------------------------------
/**
+ * Return the appropriate pagination handler.
+ *
* @param mixed $config
* @param \CodeIgniter\View\RendererInterface $view
* @param boolean $getShared
@@ -422,7 +459,7 @@
$view = static::renderer();
}
- return new \CodeIgniter\Pager\Pager($config, $view);
+ return new Pager($config, $view);
}
//--------------------------------------------------------------------
@@ -436,7 +473,7 @@
*
* @return \CodeIgniter\View\Parser
*/
- public static function parser($viewPath = null, $config = null, bool $getShared = true)
+ public static function parser(string $viewPath = null, $config = null, bool $getShared = true)
{
if ($getShared)
{
@@ -454,7 +491,7 @@
$viewPath = $paths->viewDirectory;
}
- return new \CodeIgniter\View\Parser($config, $viewPath, static::locator(true), CI_DEBUG, static::logger(true));
+ return new Parser($config, $viewPath, static::locator(true), CI_DEBUG, static::logger(true));
}
//--------------------------------------------------------------------
@@ -470,7 +507,7 @@
*
* @return \CodeIgniter\View\View
*/
- public static function renderer($viewPath = null, $config = null, bool $getShared = true)
+ public static function renderer(string $viewPath = null, $config = null, bool $getShared = true)
{
if ($getShared)
{
@@ -502,7 +539,7 @@
*
* @return \CodeIgniter\HTTP\IncomingRequest
*/
- public static function request(\Config\App $config = null, bool $getShared = true)
+ public static function request(App $config = null, bool $getShared = true)
{
if ($getShared)
{
@@ -514,11 +551,11 @@
$config = config(App::class);
}
- return new \CodeIgniter\HTTP\IncomingRequest(
+ return new IncomingRequest(
$config,
- new \CodeIgniter\HTTP\URI(),
+ new URI(),
'php://input',
- new \CodeIgniter\HTTP\UserAgent()
+ new UserAgent()
);
}
@@ -532,7 +569,7 @@
*
* @return \CodeIgniter\HTTP\Response
*/
- public static function response(\Config\App $config = null, bool $getShared = true)
+ public static function response(App $config = null, bool $getShared = true)
{
if ($getShared)
{
@@ -544,7 +581,7 @@
$config = config(App::class);
}
- return new \CodeIgniter\HTTP\Response($config);
+ return new Response($config);
}
//--------------------------------------------------------------------
@@ -557,7 +594,7 @@
*
* @return \CodeIgniter\HTTP\Response
*/
- public static function redirectResponse(\Config\App $config = null, bool $getShared = true)
+ public static function redirectResponse(App $config = null, bool $getShared = true)
{
if ($getShared)
{
@@ -569,7 +606,7 @@
$config = config(App::class);
}
- $response = new \CodeIgniter\HTTP\RedirectResponse($config);
+ $response = new RedirectResponse($config);
$response->setProtocolVersion(static::request()
->getProtocolVersion());
@@ -586,14 +623,14 @@
*
* @return \CodeIgniter\Router\RouteCollection
*/
- public static function routes($getShared = true)
+ public static function routes(bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('routes');
}
- return new \CodeIgniter\Router\RouteCollection(static::locator(), config('Modules'));
+ return new RouteCollection(static::locator(), config('Modules'));
}
//--------------------------------------------------------------------
@@ -607,7 +644,7 @@
*
* @return \CodeIgniter\Router\Router
*/
- public static function router(\CodeIgniter\Router\RouteCollectionInterface $routes = null, bool $getShared = true)
+ public static function router(RouteCollectionInterface $routes = null, bool $getShared = true)
{
if ($getShared)
{
@@ -619,7 +656,7 @@
$routes = static::routes(true);
}
- return new \CodeIgniter\Router\Router($routes);
+ return new Router($routes);
}
//--------------------------------------------------------------------
@@ -633,7 +670,7 @@
*
* @return \CodeIgniter\Security\Security
*/
- public static function security(\Config\App $config = null, bool $getShared = true)
+ public static function security(App $config = null, bool $getShared = true)
{
if ($getShared)
{
@@ -645,18 +682,20 @@
$config = config(App::class);
}
- return new \CodeIgniter\Security\Security($config);
+ return new Security($config);
}
//--------------------------------------------------------------------
/**
+ * Return the session manager.
+ *
* @param \Config\App $config
* @param boolean $getShared
*
* @return \CodeIgniter\Session\Session
*/
- public static function session(\Config\App $config = null, bool $getShared = true)
+ public static function session(App $config = null, bool $getShared = true)
{
if ($getShared)
{
@@ -674,7 +713,7 @@
$driver = new $driverName($config, static::request()->getIpAddress());
$driver->setLogger($logger);
- $session = new \CodeIgniter\Session\Session($driver, $config);
+ $session = new Session($driver, $config);
$session->setLogger($logger);
if (session_status() === PHP_SESSION_NONE)
@@ -695,14 +734,14 @@
*
* @return \CodeIgniter\Throttle\Throttler
*/
- public static function throttler($getShared = true)
+ public static function throttler(bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('throttler');
}
- return new \CodeIgniter\Throttle\Throttler(static::cache());
+ return new Throttler(static::cache());
}
//--------------------------------------------------------------------
@@ -715,19 +754,21 @@
*
* @return \CodeIgniter\Debug\Timer
*/
- public static function timer($getShared = true)
+ public static function timer(bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('timer');
}
- return new \CodeIgniter\Debug\Timer();
+ return new Timer();
}
//--------------------------------------------------------------------
/**
+ * Return the debug toolbar.
+ *
* @param \Config\Toolbar $config
* @param boolean $getShared
*
@@ -745,7 +786,7 @@
$config = config('Toolbar');
}
- return new \CodeIgniter\Debug\Toolbar($config);
+ return new Toolbar($config);
}
//--------------------------------------------------------------------
@@ -758,14 +799,14 @@
*
* @return \CodeIgniter\HTTP\URI
*/
- public static function uri($uri = null, bool $getShared = true)
+ public static function uri(string $uri = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('uri', $uri);
}
- return new \CodeIgniter\HTTP\URI($uri);
+ return new URI($uri);
}
//--------------------------------------------------------------------
@@ -790,7 +831,7 @@
$config = config('Validation');
}
- return new \CodeIgniter\Validation\Validation($config, static::renderer());
+ return new Validation($config, static::renderer());
}
//--------------------------------------------------------------------
@@ -803,14 +844,14 @@
*
* @return \CodeIgniter\View\Cell
*/
- public static function viewcell($getShared = true)
+ public static function viewcell(bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('viewcell');
}
- return new \CodeIgniter\View\Cell(static::cache());
+ return new Cell(static::cache());
}
//--------------------------------------------------------------------
@@ -822,14 +863,14 @@
*
* @return \CodeIgniter\Typography\Typography
*/
- public static function typography($getShared = true)
+ public static function typography(bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('typography');
}
- return new \CodeIgniter\Typography\Typography();
+ return new Typography();
}
//--------------------------------------------------------------------
diff --git a/system/Config/View.php b/system/Config/View.php
index 68eff58..fcbf333 100644
--- a/system/Config/View.php
+++ b/system/Config/View.php
@@ -44,6 +44,11 @@
class View extends BaseConfig
{
+ /**
+ * Built-in View filters.
+ *
+ * @var type
+ */
protected $coreFilters = [
'abs' => '\abs',
'capitalize' => '\CodeIgniter\View\Filters::capitalize',
@@ -67,6 +72,12 @@
'title' => '\CodeIgniter\View\Filters::title',
'upper' => '\strtoupper',
];
+
+ /**
+ * Built-in View plugins.
+ *
+ * @var type
+ */
protected $corePlugins = [
'current_url' => '\CodeIgniter\View\Plugins::currentURL',
'previous_url' => '\CodeIgniter\View\Plugins::previousURL',
@@ -78,6 +89,12 @@
'siteURL' => '\CodeIgniter\View\Plugins::siteURL',
];
+ /**
+ * Constructor.
+ *
+ * Merge the built-in and developer-configured filters and plugins,
+ * with preference to the developer ones.
+ */
public function __construct()
{
$this->filters = array_merge($this->coreFilters, $this->filters);
diff --git a/system/Controller.php b/system/Controller.php
index 624e0c0..25a9d45 100644
--- a/system/Controller.php
+++ b/system/Controller.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php
index ff67d1f..3bab4f1 100644
--- a/system/Database/BaseBuilder.php
+++ b/system/Database/BaseBuilder.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -524,10 +524,10 @@
*
* Generates the JOIN portion of the query
*
- * @param string $table
- * @param string $cond The join condition
- * @param string $type The type of join
- * @param boolean $escape Whether not to try to escape identifiers
+ * @param string $table
+ * @param string $cond The join condition
+ * @param string $type The type of join
+ * @param boolean $escape Whether not to try to escape identifiers
*
* @return BaseBuilder
*/
@@ -706,7 +706,7 @@
$v = " :$bind:";
}
- elseif (! $this->hasOperator($k))
+ elseif (! $this->hasOperator($k) && $qb_key !== 'QBHaving')
{
// value appears not to have been set, assign the test to IS NULL
$k .= ' IS NULL';
@@ -1016,15 +1016,15 @@
/**
* Platform independent LIKE statement builder.
*
- * @param string $prefix
- * @param string $column
- * @param string $not
- * @param string $bind
- * @param boolean $insensitiveSearch
+ * @param string $prefix
+ * @param string $column
+ * @param string $not
+ * @param string $bind
+ * @param boolean $insensitiveSearch
*
* @return string $like_statement
*/
- public function _like_statement(string $prefix = null, string $column, string $not = null, string $bind, bool $insensitiveSearch = false): string
+ protected function _like_statement(string $prefix = null, string $column, string $not = null, string $bind, bool $insensitiveSearch = false): string
{
$like_statement = "{$prefix} {$column} {$not} LIKE :{$bind}:";
@@ -1136,7 +1136,7 @@
{
if ($this->QBWhereGroupStarted)
{
- $type = '';
+ $type = '';
$this->QBWhereGroupStarted = false;
}
@@ -1148,8 +1148,8 @@
/**
* GROUP BY
*
- * @param string|array $by
- * @param boolean $escape
+ * @param string|array $by
+ * @param boolean $escape
*
* @return BaseBuilder
*/
@@ -1187,9 +1187,9 @@
*
* Separates multiple calls with 'AND'.
*
- * @param string|array $key
- * @param mixed $value
- * @param boolean $escape
+ * @param string|array $key
+ * @param mixed $value
+ * @param boolean $escape
*
* @return BaseBuilder
*/
@@ -1205,9 +1205,9 @@
*
* Separates multiple calls with 'OR'.
*
- * @param string|array $key
- * @param mixed $value
- * @param boolean $escape
+ * @param string|array $key
+ * @param mixed $value
+ * @param boolean $escape
*
* @return BaseBuilder
*/
@@ -1251,7 +1251,7 @@
if ($escape === false)
{
- $qb_orderby[] = [
+ $qb_orderBy[] = [
'field' => $orderBy,
'direction' => $direction,
'escape' => false,
@@ -1259,10 +1259,10 @@
}
else
{
- $qb_orderby = [];
+ $qb_orderBy = [];
foreach (explode(',', $orderBy) as $field)
{
- $qb_orderby[] = ($direction === '' && preg_match('/\s+(ASC|DESC)$/i', rtrim($field), $match, PREG_OFFSET_CAPTURE))
+ $qb_orderBy[] = ($direction === '' && preg_match('/\s+(ASC|DESC)$/i', rtrim($field), $match, PREG_OFFSET_CAPTURE))
?
[
'field' => ltrim(substr($field, 0, $match[0][1])),
@@ -1278,7 +1278,7 @@
}
}
- $this->QBOrderBy = array_merge($this->QBOrderBy, $qb_orderby);
+ $this->QBOrderBy = array_merge($this->QBOrderBy, $qb_orderBy);
return $this;
}
@@ -1371,7 +1371,7 @@
{
if ($escape)
{
- $bind = $this->setBind($k, $v, $escape);
+ $bind = $this->setBind($k, $v, $escape);
$this->QBSet[$this->db->protectIdentifiers($k, false, $escape)] = ":$bind:";
}
else
@@ -1594,9 +1594,9 @@
*
* Allows the where clause, limit and offset to be added directly
*
- * @param string|array $where
- * @param integer $limit
- * @param integer $offset
+ * @param string|array $where
+ * @param integer $limit
+ * @param integer $offset
*
* @return ResultInterface
*/
@@ -1852,7 +1852,7 @@
* validate that the there data is actually being set and that table
* has been chosen to be inserted into.
*
- * @return bool
+ * @return boolean
* @throws DatabaseException
*/
protected function validateInsert(): bool
@@ -2160,7 +2160,7 @@
// Batch this baby
$affected_rows = 0;
- $savedSQL = [];
+ $savedSQL = [];
for ($i = 0, $total = count($this->QBSet); $i < $total; $i += $batchSize)
{
$sql = $this->_updateBatch($table, array_slice($this->QBSet, $i, $batchSize), $this->db->protectIdentifiers($index)
@@ -2199,7 +2199,7 @@
*/
protected function _updateBatch(string $table, array $values, string $index): string
{
- $ids = [];
+ $ids = [];
$final = [];
foreach ($values as $key => $val)
{
@@ -2232,9 +2232,9 @@
/**
* The "setUpdateBatch" function. Allows key/value pairs to be set for batch updating
*
- * @param array|object $key
- * @param string $index
- * @param boolean $escape
+ * @param array|object $key
+ * @param string $index
+ * @param boolean $escape
*
* @return BaseBuilder|null
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
@@ -2504,6 +2504,7 @@
{
$this->trackAliases($t);
}
+ return;
}
// Does the string contain a comma? If so, we need to separate
diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php
index 7e16330..496c77f 100644
--- a/system/Database/BaseConnection.php
+++ b/system/Database/BaseConnection.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -422,12 +422,14 @@
* @param boolean $persistent
* @return mixed
*/
- abstract public function connect($persistent = false);
+ abstract public function connect(bool $persistent = false);
//--------------------------------------------------------------------
/**
* Close the database connection.
+ *
+ * @return void
*/
public function close()
{
@@ -526,9 +528,9 @@
/**
* The name of the platform in use (MySQLi, mssql, etc)
*
- * @return mixed
+ * @return string
*/
- public function getPlatform()
+ public function getPlatform(): string
{
return $this->DBDriver;
}
@@ -538,9 +540,9 @@
/**
* Returns a string containing the version of the database being used.
*
- * @return mixed
+ * @return string
*/
- abstract public function getVersion();
+ abstract public function getVersion(): string;
//--------------------------------------------------------------------
@@ -586,7 +588,7 @@
*
* @return mixed
*/
- abstract protected function execute($sql);
+ abstract protected function execute(string $sql);
//--------------------------------------------------------------------
@@ -599,13 +601,13 @@
* queries if needed.
*
* @param string $sql
- * @param array ...$binds
+ * @param mixed ...$binds
* @param boolean $setEscapeFlags
* @param string $queryClass
*
* @return BaseResult|Query|false
*/
- public function query(string $sql, $binds = null, bool $setEscapeFlags = true, $queryClass = 'CodeIgniter\\Database\\Query')
+ public function query(string $sql, $binds = null, bool $setEscapeFlags = true, string $queryClass = 'CodeIgniter\\Database\\Query')
{
if (empty($this->connID))
{
@@ -713,6 +715,8 @@
* Disable Transactions
*
* This permits transactions to be disabled at run-time.
+ *
+ * @return void
*/
public function transOff()
{
@@ -750,7 +754,7 @@
* @param boolean $test_mode = FALSE
* @return boolean
*/
- public function transStart($test_mode = false)
+ public function transStart(bool $test_mode = false): bool
{
if (! $this->transEnabled)
{
@@ -767,7 +771,7 @@
*
* @return boolean
*/
- public function transComplete()
+ public function transComplete(): bool
{
if (! $this->transEnabled)
{
@@ -924,7 +928,7 @@
/**
* Returns an instance of the query builder for this connection.
*
- * @param string $tableName
+ * @param string|array $tableName
*
* @return BaseBuilder
* @throws DatabaseException
@@ -1008,7 +1012,7 @@
*
* @return string
*/
- public function showLastQuery()
+ public function showLastQuery(): string
{
return (string) $this->lastQuery;
}
@@ -1023,7 +1027,7 @@
*
* @return float
*/
- public function getConnectStart()
+ public function getConnectStart(): float
{
return $this->connectTime;
}
@@ -1038,9 +1042,9 @@
*
* @param integer $decimals
*
- * @return mixed
+ * @return string
*/
- public function getConnectDuration($decimals = 6)
+ public function getConnectDuration(int $decimals = 6): string
{
return number_format($this->connectDuration, $decimals);
}
@@ -1067,14 +1071,14 @@
* insert the table prefix (if it exists) in the proper position, and escape only
* the correct identifiers.
*
- * @param string|array
- * @param boolean
- * @param mixed
- * @param boolean
+ * @param string|array $item
+ * @param boolean $prefixSingle
+ * @param boolean $protectIdentifiers
+ * @param boolean $fieldExists
*
* @return string|array
*/
- public function protectIdentifiers($item, $prefixSingle = false, $protectIdentifiers = null, $fieldExists = true)
+ public function protectIdentifiers($item, bool $prefixSingle = false, bool $protectIdentifiers = null, bool $fieldExists = true)
{
if (! is_bool($protectIdentifiers))
{
@@ -1243,7 +1247,7 @@
*
* This function escapes column and table names
*
- * @param mixed
+ * @param mixed $item
*
* @return mixed
*/
@@ -1313,7 +1317,7 @@
* @return string
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
*/
- public function prefixTable($table = '')
+ public function prefixTable(string $table = ''): string
{
if ($table === '')
{
@@ -1334,7 +1338,7 @@
*
* @return string
*/
- public function setPrefix($prefix = '')
+ public function setPrefix(string $prefix = ''): string
{
return $this->DBPrefix = $prefix;
}
@@ -1356,7 +1360,7 @@
* Escapes data based on type.
* Sets boolean and null types
*
- * @param $str
+ * @param mixed $str
*
* @return mixed
*/
@@ -1395,9 +1399,9 @@
*
* @param string|string[] $str Input string
* @param boolean $like Whether or not the string will be used in a LIKE condition
- * @return string
+ * @return string|string[]
*/
- public function escapeString($str, $like = false)
+ public function escapeString($str, bool $like = false)
{
if (is_array($str))
{
@@ -1438,7 +1442,7 @@
* specific escaping for LIKE conditions
*
* @param string|string[]
- * @return mixed
+ * @return string|string[]
*/
public function escapeLikeString($str)
{
@@ -1473,7 +1477,7 @@
* @return boolean
* @throws DatabaseException
*/
- public function callFunction(string $functionName, ...$params)
+ public function callFunction(string $functionName, ...$params): bool
{
$driver = ($this->DBDriver === 'postgre' ? 'pg' : strtolower($this->DBDriver)) . '_';
@@ -1503,11 +1507,11 @@
/**
* Returns an array of table names
*
- * @param boolean $constrain_by_prefix = FALSE
+ * @param boolean $constrainByPrefix = FALSE
* @return boolean|array
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
*/
- public function listTables($constrain_by_prefix = false)
+ public function listTables(bool $constrainByPrefix = false)
{
// Is there a cached result?
if (isset($this->dataCache['table_names']) && $this->dataCache['table_names'])
@@ -1515,7 +1519,7 @@
return $this->dataCache['table_names'];
}
- if (false === ($sql = $this->_listTables($constrain_by_prefix)))
+ if (false === ($sql = $this->_listTables($constrainByPrefix)))
{
if ($this->DBDebug)
{
@@ -1563,12 +1567,12 @@
/**
* Determine if a particular table exists
*
- * @param string $table_name
+ * @param string $tableName
* @return boolean
*/
- public function tableExists($table_name)
+ public function tableExists(string $tableName): bool
{
- return in_array($this->protectIdentifiers($table_name, true, false, false), $this->listTables());
+ return in_array($this->protectIdentifiers($tableName, true, false, false), $this->listTables());
}
//--------------------------------------------------------------------
@@ -1581,7 +1585,7 @@
* @return array|false
* @throws DatabaseException
*/
- public function getFieldNames($table)
+ public function getFieldNames(string $table)
{
// Is there a cached result?
if (isset($this->dataCache['field_names'][$table]))
@@ -1637,11 +1641,11 @@
/**
* Determine if a particular field exists
*
- * @param string
- * @param string
+ * @param string $fieldName
+ * @param string $tableName
* @return boolean
*/
- public function fieldExists($fieldName, $tableName)
+ public function fieldExists(string $fieldName, string $tableName): bool
{
return in_array($fieldName, $this->getFieldNames($tableName));
}
@@ -1735,7 +1739,7 @@
*
* @return array
*/
- abstract public function error();
+ abstract public function error(): array;
//--------------------------------------------------------------------
@@ -1744,7 +1748,7 @@
*
* @return integer
*/
- abstract public function insertID();
+ abstract public function insertID(): int;
//--------------------------------------------------------------------
@@ -1755,7 +1759,7 @@
*
* @return string
*/
- abstract protected function _listTables($constrainByPrefix = false): string;
+ abstract protected function _listTables(bool $constrainByPrefix = false): string;
//--------------------------------------------------------------------
@@ -1803,12 +1807,21 @@
//--------------------------------------------------------------------
- public function __get($key)
+ /**
+ * Accessor for properties if they exist.
+ *
+ * @param string $key
+ *
+ * @return mixed
+ */
+ public function __get(string $key)
{
if (property_exists($this, $key))
{
return $this->$key;
}
+
+ return null;
}
//--------------------------------------------------------------------
diff --git a/system/Database/BasePreparedQuery.php b/system/Database/BasePreparedQuery.php
index 887f906..cbcfff7 100644
--- a/system/Database/BasePreparedQuery.php
+++ b/system/Database/BasePreparedQuery.php
@@ -31,12 +31,13 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
namespace CodeIgniter\Database;
+use CodeIgniter\Database\MySQLi\Connection;
use CodeIgniter\Events\Events;
/**
@@ -83,9 +84,14 @@
//--------------------------------------------------------------------
+ /**
+ * Constructor.
+ *
+ * @param \CodeIgniter\Database\ConnectionInterface $db
+ */
public function __construct(ConnectionInterface $db)
{
- $this->db = & $db;
+ $this->db = &$db;
}
//--------------------------------------------------------------------
@@ -103,7 +109,7 @@
*
* @return mixed
*/
- public function prepare(string $sql, array $options = [], $queryClass = 'CodeIgniter\\Database\\Query')
+ public function prepare(string $sql, array $options = [], string $queryClass = 'CodeIgniter\\Database\\Query')
{
// We only supports positional placeholders (?)
// in order to work with the execute method below, so we
@@ -180,9 +186,9 @@
*
* @param array $data
*
- * @return ResultInterface
+ * @return boolean
*/
- abstract public function _execute($data);
+ abstract public function _execute(array $data): bool;
//--------------------------------------------------------------------
@@ -196,7 +202,9 @@
//--------------------------------------------------------------------
/**
- * Explicity closes the statement.
+ * Explicitly closes the statement.
+ *
+ * @return null|void
*/
public function close()
{
@@ -232,7 +240,7 @@
*
* @return boolean
*/
- public function hasError()
+ public function hasError(): bool
{
return ! empty($this->errorString);
}
diff --git a/system/Database/BaseResult.php b/system/Database/BaseResult.php
index 5e28509..08e485d 100644
--- a/system/Database/BaseResult.php
+++ b/system/Database/BaseResult.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -123,9 +123,9 @@
*
* @param string $type The row type. Either 'array', 'object', or a class name to use
*
- * @return mixed
+ * @return array
*/
- public function getResult($type = 'object'): array
+ public function getResult(string $type = 'object'): array
{
if ($type === 'array')
{
@@ -154,7 +154,8 @@
{
return $this->customResultObject[$className];
}
- elseif (! $this->resultID || $this->numRows === 0)
+
+ if (is_bool($this->resultID) || ! $this->resultID || $this->numRows === 0)
{
return [];
}
@@ -215,7 +216,7 @@
// In the event that query caching is on, the result_id variable
// will not be a valid resource so we'll simply return an empty
// array.
- if (! $this->resultID || $this->numRows === 0)
+ if (is_bool($this->resultID) || ! $this->resultID || $this->numRows === 0)
{
return [];
}
@@ -258,7 +259,7 @@
// In the event that query caching is on, the result_id variable
// will not be a valid resource so we'll simply return an empty
// array.
- if (! $this->resultID || $this->numRows === 0)
+ if (is_bool($this->resultID) || ! $this->resultID || $this->numRows === 0)
{
return [];
}
@@ -290,17 +291,17 @@
*
* If row doesn't exist, returns null.
*
- * @param integer $n The index of the results to return
- * @param string $type The type of result object. 'array', 'object' or class name.
+ * @param mixed $n The index of the results to return
+ * @param string $type The type of result object. 'array', 'object' or class name.
*
* @return mixed
*/
- public function getRow($n = 0, $type = 'object')
+ public function getRow($n = 0, string $type = 'object')
{
if (! is_numeric($n))
{
// We cache the row data for subsequent uses
- is_array($this->rowData) || $this->row_data = $this->getRowArray(0);
+ is_array($this->rowData) || $this->rowData = $this->getRowArray(0);
// array_key_exists() instead of isset() to allow for NULL values
if (empty($this->rowData) || ! array_key_exists($n, $this->rowData))
@@ -335,7 +336,7 @@
*
* @return mixed
*/
- public function getCustomRowObject($n, string $className)
+ public function getCustomRowObject(int $n, string $className)
{
isset($this->customResultObject[$className]) || $this->getCustomResultObject($className);
@@ -363,7 +364,7 @@
*
* @return mixed
*/
- public function getRowArray($n = 0)
+ public function getRowArray(int $n = 0)
{
$result = $this->getResultArray();
if (empty($result))
@@ -390,7 +391,7 @@
*
* @return mixed
*/
- public function getRowObject($n = 0)
+ public function getRowObject(int $n = 0)
{
$result = $this->getResultObject();
if (empty($result))
@@ -411,8 +412,8 @@
/**
* Assigns an item into a particular column slot.
*
- * @param $key
- * @param null $value
+ * @param mixed $key
+ * @param mixed $value
*
* @return mixed
*/
@@ -421,7 +422,7 @@
// We cache the row data for subsequent uses
if (! is_array($this->rowData))
{
- $this->row_data = $this->getRowArray(0);
+ $this->rowData = $this->getRowArray(0);
}
if (is_array($key))
@@ -449,7 +450,7 @@
*
* @return mixed
*/
- public function getFirstRow($type = 'object')
+ public function getFirstRow(string $type = 'object')
{
$result = $this->getResult($type);
@@ -465,7 +466,7 @@
*
* @return mixed
*/
- public function getLastRow($type = 'object')
+ public function getLastRow(string $type = 'object')
{
$result = $this->getResult($type);
@@ -481,7 +482,7 @@
*
* @return mixed
*/
- public function getNextRow($type = 'object')
+ public function getNextRow(string $type = 'object')
{
$result = $this->getResult($type);
if (empty($result))
@@ -501,7 +502,7 @@
*
* @return mixed
*/
- public function getPreviousRow($type = 'object')
+ public function getPreviousRow(string $type = 'object')
{
$result = $this->getResult($type);
if (empty($result))
@@ -526,7 +527,7 @@
*
* @return mixed
*/
- public function getUnbufferedRow($type = 'object')
+ public function getUnbufferedRow(string $type = 'object')
{
if ($type === 'array')
{
@@ -572,7 +573,7 @@
/**
* Frees the current result.
*
- * @return mixed
+ * @return void
*/
abstract public function freeResult();
@@ -587,7 +588,7 @@
*
* @return mixed
*/
- abstract public function dataSeek($n = 0);
+ abstract public function dataSeek(int $n = 0);
//--------------------------------------------------------------------
@@ -596,7 +597,7 @@
*
* Overridden by driver classes.
*
- * @return array
+ * @return mixed
*/
abstract protected function fetchAssoc();
@@ -611,7 +612,7 @@
*
* @return object
*/
- abstract protected function fetchObject($className = 'stdClass');
+ abstract protected function fetchObject(string $className = 'stdClass');
//--------------------------------------------------------------------
}
diff --git a/system/Database/BaseUtils.php b/system/Database/BaseUtils.php
index 72deff4..a512d23 100644
--- a/system/Database/BaseUtils.php
+++ b/system/Database/BaseUtils.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -136,7 +136,7 @@
* @param string $database_name
* @return boolean
*/
- public function databaseExists($database_name)
+ public function databaseExists(string $database_name): bool
{
return in_array($database_name, $this->listDatabases());
}
@@ -147,10 +147,10 @@
* Optimize Table
*
* @param string $table_name
- * @return boolean|mixed
+ * @return mixed
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
*/
- public function optimizeTable($table_name)
+ public function optimizeTable(string $table_name)
{
if ($this->optimizeTable === false)
{
@@ -200,11 +200,21 @@
}
// Build the result array...
- $res = $res->getResultArray();
- $res = current($res);
- $key = str_replace($this->db->database . '.', '', current($res));
- $keys = array_keys($res);
- unset($res[$keys[0]]);
+
+ $res = $res->getResultArray();
+
+ // Postgre & SQLite3 returns empty array
+ if (empty($res))
+ {
+ $key = $table_name;
+ }
+ else
+ {
+ $res = current($res);
+ $key = str_replace($this->db->database . '.', '', current($res));
+ $keys = array_keys($res);
+ unset($res[$keys[0]]);
+ }
$result[$key] = $res;
}
@@ -221,7 +231,7 @@
* @return mixed
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
*/
- public function repairTable($table_name)
+ public function repairTable(string $table_name)
{
if ($this->repairTable === false)
{
@@ -254,7 +264,7 @@
*
* @return string
*/
- public function getCSVFromResult(ResultInterface $query, $delim = ',', $newline = "\n", $enclosure = '"')
+ public function getCSVFromResult(ResultInterface $query, string $delim = ',', string $newline = "\n", string $enclosure = '"')
{
$out = '';
// First generate the headings from the table column names
@@ -289,7 +299,7 @@
*
* @return string
*/
- public function getXMLFromResult(ResultInterface $query, $params = [])
+ public function getXMLFromResult(ResultInterface $query, array $params = []): string
{
// Set our default values
foreach (['root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t"] as $key => $val)
@@ -304,7 +314,7 @@
extract($params);
// Load the xml helper
- helper('xml');
+ helper('xml');
// Generate the result
$xml = '<' . $root . '>' . $newline;
while ($row = $query->getUnbufferedRow())
@@ -312,7 +322,8 @@
$xml .= $tab . '<' . $element . '>' . $newline;
foreach ($row as $key => $val)
{
- $xml .= $tab . $tab . '<' . $key . '>' . xml_convert($val) . '' . $key . '>' . $newline;
+ $val = (! empty($val)) ? xml_convert($val) : '';
+ $xml .= $tab . $tab . '<' . $key . '>' . $val . '' . $key . '>' . $newline;
}
$xml .= $tab . '' . $element . '>' . $newline;
}
@@ -325,7 +336,7 @@
/**
* Database Backup
*
- * @param array $params
+ * @param array|string $params
* @return mixed
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
*/
@@ -379,7 +390,7 @@
// Is the encoder supported? If not, we'll either issue an
// error or use plain text depending on the debug settings
if (($prefs['format'] === 'gzip' && ! function_exists('gzencode'))
- || ( $prefs['format'] === 'zip' && ! function_exists('gzcompress')))
+ || ( $prefs['format'] === 'zip' && ! function_exists('gzcompress')))
{
if ($this->db->DBDebug)
{
@@ -396,7 +407,7 @@
if ($prefs['filename'] === '')
{
$prefs['filename'] = (count($prefs['tables']) === 1 ? $prefs['tables'] : $this->db->database)
- . date('Y-m-d_H-i', time()) . '.sql';
+ . date('Y-m-d_H-i', time()) . '.sql';
}
else
{
diff --git a/system/Database/Config.php b/system/Database/Config.php
index f94c663..5588035 100644
--- a/system/Database/Config.php
+++ b/system/Database/Config.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -125,7 +125,7 @@
*
* @return array
*/
- public static function getConnections()
+ public static function getConnections(): array
{
return static::$instances;
}
@@ -186,12 +186,12 @@
*/
protected static function ensureFactory()
{
- if (static::$factory instanceof \CodeIgniter\Database\Database)
+ if (static::$factory instanceof Database)
{
return;
}
- static::$factory = new \CodeIgniter\Database\Database();
+ static::$factory = new Database();
}
//--------------------------------------------------------------------
diff --git a/system/Database/ConnectionInterface.php b/system/Database/ConnectionInterface.php
index 76f8a64..302af16 100644
--- a/system/Database/ConnectionInterface.php
+++ b/system/Database/ConnectionInterface.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -61,7 +61,7 @@
* @param boolean $persistent
* @return mixed
*/
- public function connect($persistent = false);
+ public function connect(bool $persistent = false);
//--------------------------------------------------------------------
@@ -130,18 +130,18 @@
/**
* The name of the platform in use (MySQLi, mssql, etc)
*
- * @return mixed
+ * @return string
*/
- public function getPlatform();
+ public function getPlatform(): string;
//--------------------------------------------------------------------
/**
* Returns a string containing the version of the database being used.
*
- * @return mixed
+ * @return string
*/
- public function getVersion();
+ public function getVersion(): string;
//--------------------------------------------------------------------
@@ -154,7 +154,7 @@
* queries if needed.
*
* @param string $sql
- * @param array ...$binds
+ * @param mixed ...$binds
*
* @return mixed
*/
@@ -201,7 +201,7 @@
* Escapes data based on type.
* Sets boolean and null types.
*
- * @param string $str
+ * @param mixed $str
*
* @return mixed
*/
diff --git a/system/Database/Database.php b/system/Database/Database.php
index ad4e8aa..ec9c272 100644
--- a/system/Database/Database.php
+++ b/system/Database/Database.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Database/Exceptions/DataException.php b/system/Database/Exceptions/DataException.php
index 966c6ef..2af1793 100644
--- a/system/Database/Exceptions/DataException.php
+++ b/system/Database/Exceptions/DataException.php
@@ -1,4 +1,6 @@
-db->DBDebug)
{
- throw new DatabaseException('Unable to drop the specified database.');
+ throw new DatabaseException('Unable to create the specified database.');
}
return false;
@@ -385,16 +385,16 @@
/**
* Add Foreign Key
*
- * @param string $fieldName
- * @param string $tableName
- * @param string $tableField
- * @param boolean $onUpdate
- * @param boolean $onDelete
+ * @param string $fieldName
+ * @param string $tableName
+ * @param string $tableField
+ * @param string $onUpdate
+ * @param string $onDelete
*
* @return \CodeIgniter\Database\Forge
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
*/
- public function addForeignKey(string $fieldName = '', string $tableName = '', string $tableField = '', bool $onUpdate = false, bool $onDelete = false)
+ public function addForeignKey(string $fieldName = '', string $tableName = '', string $tableField = '', string $onUpdate = '', string $onDelete = '')
{
if (! isset($this->fields[$fieldName]))
{
@@ -715,8 +715,8 @@
/**
* Column Add
*
- * @param string $table Table name
- * @param string|array $field Column definition
+ * @param string $table Table name
+ * @param string|array $field Column definition
*
* @return boolean
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
@@ -786,8 +786,8 @@
/**
* Column Modify
*
- * @param string $table Table name
- * @param string|array $field Column definition
+ * @param string $table Table name
+ * @param string|array $field Column definition
*
* @return boolean
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
diff --git a/system/Database/Migration.php b/system/Database/Migration.php
index eb27199..bfa31a9 100644
--- a/system/Database/Migration.php
+++ b/system/Database/Migration.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -86,7 +86,7 @@
*
* @return string
*/
- public function getDBGroup()
+ public function getDBGroup(): string
{
return $this->DBGroup;
}
diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php
index 810e9a9..2154ab4 100644
--- a/system/Database/MigrationRunner.php
+++ b/system/Database/MigrationRunner.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -342,7 +342,7 @@
*
* @return boolean
*/
- public function latestAll(string $group = null)
+ public function latestAll(string $group = null): bool
{
$this->ensureTable();
@@ -387,7 +387,7 @@
*
* @param string|null $group
*
- * @return mixed TRUE if no migrations are found, current version string on success, FALSE on failure
+ * @return mixed Current version string on success, FALSE on failure or no migrations are found
*/
public function current(string $group = null)
{
@@ -409,7 +409,7 @@
*
* @return array list of migrations as $version for one namespace
*/
- public function findMigrations()
+ public function findMigrations(): array
{
$migrations = [];
@@ -471,11 +471,11 @@
*
* @param array $migrations
* @param string $method
- * @param string $targetversion
+ * @param string $targetVersion
*
* @return boolean
*/
- protected function checkMigrations(array $migrations, string $method, string $targetversion)
+ protected function checkMigrations(array $migrations, string $method, string $targetVersion): bool
{
// Check if no migrations found
if (empty($migrations))
@@ -487,14 +487,14 @@
throw new \RuntimeException(lang('Migrations.empty'));
}
- // Check if $targetversion file is found
- if ((int)$targetversion !== 0 && ! array_key_exists($targetversion, $migrations))
+ // Check if $targetVersion file is found
+ if ((int)$targetVersion !== 0 && ! array_key_exists($targetVersion, $migrations))
{
if ($this->silent)
{
return false;
}
- throw new \RuntimeException(lang('Migrations.notFound') . $targetversion);
+ throw new \RuntimeException(lang('Migrations.notFound') . $targetVersion);
}
ksort($migrations);
@@ -601,7 +601,7 @@
*
* @return array
*/
- public function getHistory(string $group = 'default')
+ public function getHistory(string $group = 'default'): array
{
$this->ensureTable();
@@ -645,7 +645,7 @@
*
* @return string Numeric portion of a migration filename
*/
- protected function getMigrationNumber(string $migration)
+ protected function getMigrationNumber(string $migration): string
{
return sscanf($migration, '%[0-9]+', $number) ? $number : '0';
}
@@ -659,7 +659,7 @@
*
* @return string text portion of a migration filename
*/
- protected function getMigrationName(string $migration)
+ protected function getMigrationName(string $migration): string
{
$parts = explode('_', $migration);
array_shift($parts);
@@ -674,7 +674,7 @@
*
* @return string Current migration version
*/
- protected function getVersion()
+ protected function getVersion(): string
{
$this->ensureTable();
@@ -695,7 +695,7 @@
*
* @return array Current migration version
*/
- public function getCliMessages()
+ public function getCliMessages(): array
{
return $this->cliMessages;
}
@@ -708,6 +708,8 @@
* @param string $version
*
* @internal param string $migration Migration reached
+ *
+ * @return void
*/
protected function addHistory(string $version)
{
@@ -730,7 +732,8 @@
/**
* Removes a single history
*
- * @param string $version
+ * @param string $version
+ * @return void
*/
protected function removeHistory(string $version)
{
diff --git a/system/Database/MySQLi/Builder.php b/system/Database/MySQLi/Builder.php
index 264171e..6bfe554 100644
--- a/system/Database/MySQLi/Builder.php
+++ b/system/Database/MySQLi/Builder.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php
index 7c6d45c..6edc28c 100644
--- a/system/Database/MySQLi/Connection.php
+++ b/system/Database/MySQLi/Connection.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -89,7 +89,7 @@
* @return mixed
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
*/
- public function connect($persistent = false)
+ public function connect(bool $persistent = false)
{
// Do we have a socket path?
if ($this->hostname[0] === '/')
@@ -245,6 +245,8 @@
/**
* Close the database connection.
+ *
+ * @return void
*/
protected function _close()
{
@@ -258,9 +260,9 @@
*
* @param string $databaseName
*
- * @return mixed
+ * @return boolean
*/
- public function setDatabase(string $databaseName)
+ public function setDatabase(string $databaseName): bool
{
if ($databaseName === '')
{
@@ -287,9 +289,9 @@
/**
* Returns a string containing the version of the database being used.
*
- * @return mixed
+ * @return string
*/
- public function getVersion()
+ public function getVersion(): string
{
if (isset($this->dataCache['version']))
{
@@ -313,7 +315,7 @@
*
* @return mixed
*/
- public function execute($sql)
+ public function execute(string $sql)
{
while ($this->connID->more_results())
{
@@ -338,7 +340,7 @@
*
* @return string
*/
- protected function prepQuery($sql)
+ protected function prepQuery(string $sql): string
{
// mysqli_affected_rows() returns 0 for "DELETE FROM TABLE" queries. This hack
// modifies the query so that it a proper number of affected rows is returned.
@@ -355,7 +357,7 @@
/**
* Returns the total number of rows affected by this query.
*
- * @return mixed
+ * @return integer
*/
public function affectedRows(): int
{
@@ -394,7 +396,7 @@
*
* @return string
*/
- protected function _listTables($prefixLimit = false): string
+ protected function _listTables(bool $prefixLimit = false): string
{
$sql = 'SHOW TABLES FROM ' . $this->escapeIdentifiers($this->database);
@@ -439,19 +441,19 @@
}
$query = $query->getResultObject();
- $retval = [];
+ $retVal = [];
for ($i = 0, $c = count($query); $i < $c; $i++)
{
- $retval[$i] = new \stdClass();
- $retval[$i]->name = $query[$i]->Field;
+ $retVal[$i] = new \stdClass();
+ $retVal[$i]->name = $query[$i]->Field;
- sscanf($query[$i]->Type, '%[a-z](%d)', $retval[$i]->type, $retval[$i]->max_length);
+ sscanf($query[$i]->Type, '%[a-z](%d)', $retVal[$i]->type, $retVal[$i]->max_length);
- $retval[$i]->default = $query[$i]->Default;
- $retval[$i]->primary_key = (int)($query[$i]->Key === 'PRI');
+ $retVal[$i]->default = $query[$i]->Default;
+ $retVal[$i]->primary_key = (int)($query[$i]->Key === 'PRI');
}
- return $retval;
+ return $retVal;
}
//--------------------------------------------------------------------
@@ -550,7 +552,7 @@
}
$query = $query->getResultObject();
- $retval = [];
+ $retVal = [];
foreach ($query as $row)
{
$obj = new \stdClass();
@@ -558,10 +560,10 @@
$obj->table_name = $row->TABLE_NAME;
$obj->foreign_table_name = $row->REFERENCED_TABLE_NAME;
- $retval[] = $obj;
+ $retVal[] = $obj;
}
- return $retval;
+ return $retVal;
}
//--------------------------------------------------------------------
@@ -575,7 +577,7 @@
*
* @return array
*/
- public function error()
+ public function error(): array
{
if (! empty($this->mysqli->connect_errno))
{
@@ -598,7 +600,7 @@
*
* @return integer
*/
- public function insertID()
+ public function insertID(): int
{
return $this->connID->insert_id;
}
diff --git a/system/Database/MySQLi/Forge.php b/system/Database/MySQLi/Forge.php
index 188625e..52168af 100644
--- a/system/Database/MySQLi/Forge.php
+++ b/system/Database/MySQLi/Forge.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Database/MySQLi/PreparedQuery.php b/system/Database/MySQLi/PreparedQuery.php
index 668df92..a510a37 100644
--- a/system/Database/MySQLi/PreparedQuery.php
+++ b/system/Database/MySQLi/PreparedQuery.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -41,6 +41,9 @@
use CodeIgniter\Database\PreparedQueryInterface;
use CodeIgniter\Database\BasePreparedQuery;
+/**
+ * Prepared query for MySQLi
+ */
class PreparedQuery extends BasePreparedQuery implements PreparedQueryInterface
{
@@ -80,9 +83,9 @@
*
* @param array $data
*
- * @return \CodeIgniter\Database\ResultInterface
+ * @return boolean
*/
- public function _execute($data)
+ public function _execute(array $data): bool
{
if (is_null($this->statement))
{
diff --git a/system/Database/MySQLi/Result.php b/system/Database/MySQLi/Result.php
index 2906324..4299b36 100644
--- a/system/Database/MySQLi/Result.php
+++ b/system/Database/MySQLi/Result.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -85,26 +85,28 @@
*/
public function getFieldData(): array
{
- $retval = [];
+ $retVal = [];
$fieldData = $this->resultID->fetch_fields();
foreach ($fieldData as $i => $data)
{
- $retval[$i] = new \stdClass();
- $retval[$i]->name = $data->name;
- $retval[$i]->type = $data->type;
- $retval[$i]->max_length = $data->max_length;
- $retval[$i]->primary_key = (int) ($data->flags & 2);
- $retval[$i]->default = $data->def;
+ $retVal[$i] = new \stdClass();
+ $retVal[$i]->name = $data->name;
+ $retVal[$i]->type = $data->type;
+ $retVal[$i]->max_length = $data->max_length;
+ $retVal[$i]->primary_key = (int) ($data->flags & 2);
+ $retVal[$i]->default = $data->def;
}
- return $retval;
+ return $retVal;
}
//--------------------------------------------------------------------
/**
* Frees the current result.
+ *
+ * @return void
*/
public function freeResult()
{
@@ -126,7 +128,7 @@
*
* @return mixed
*/
- public function dataSeek($n = 0)
+ public function dataSeek(int $n = 0)
{
return $this->resultID->data_seek($n);
}
@@ -138,7 +140,7 @@
*
* Overridden by driver classes.
*
- * @return array
+ * @return mixed
*/
protected function fetchAssoc()
{
@@ -156,7 +158,7 @@
*
* @return object
*/
- protected function fetchObject($className = 'stdClass')
+ protected function fetchObject(string $className = 'stdClass')
{
return $this->resultID->fetch_object($className);
}
diff --git a/system/Database/MySQLi/Utils.php b/system/Database/MySQLi/Utils.php
index 25d4036..5ebe7fb 100644
--- a/system/Database/MySQLi/Utils.php
+++ b/system/Database/MySQLi/Utils.php
@@ -32,18 +32,19 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
namespace CodeIgniter\Database\MySQLi;
+use CodeIgniter\Database\BaseUtils;
use CodeIgniter\Database\Exceptions\DatabaseException;
/**
* Utils for MySQLi
*/
-class Utils extends \CodeIgniter\Database\BaseUtils
+class Utils extends BaseUtils
{
/**
diff --git a/system/Database/Postgre/Builder.php b/system/Database/Postgre/Builder.php
index 7ab065a..9704c8c 100644
--- a/system/Database/Postgre/Builder.php
+++ b/system/Database/Postgre/Builder.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -53,7 +53,6 @@
*/
protected $randomKeyword = [
'RANDOM()',
- 'RANDOM()',
];
//--------------------------------------------------------------------
@@ -98,7 +97,7 @@
* @param string $column
* @param integer $value
*
- * @return boolean
+ * @return mixed
*/
public function increment(string $column, int $value = 1)
{
@@ -117,7 +116,7 @@
* @param string $column
* @param integer $value
*
- * @return boolean
+ * @return mixed
*/
public function decrement(string $column, int $value = 1)
{
@@ -141,7 +140,7 @@
* @param array $set An associative array of insert values
* @param boolean $returnSQL
*
- * @return boolean TRUE on success, FALSE on failure
+ * @return mixed
* @throws DatabaseException
* @internal param true $bool returns the generated SQL, false executes the query.
*/
@@ -351,11 +350,11 @@
*
* @see https://www.postgresql.org/docs/9.2/static/functions-matching.html
*
- * @param string $prefix
- * @param string $column
- * @param string $not
- * @param string $bind
- * @param boolean $insensitiveSearch
+ * @param string $prefix
+ * @param string $column
+ * @param string $not
+ * @param string $bind
+ * @param boolean $insensitiveSearch
*
* @return string $like_statement
*/
diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php
index 56aec4f..d69314b 100644
--- a/system/Database/Postgre/Connection.php
+++ b/system/Database/Postgre/Connection.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -78,7 +78,7 @@
* @param boolean $persistent
* @return mixed
*/
- public function connect($persistent = false)
+ public function connect(bool $persistent = false)
{
if (empty($this->DSN))
{
@@ -121,7 +121,7 @@
* Keep or establish the connection if no queries have been sent for
* a length of time exceeding the server's idle timeout.
*
- * @return mixed
+ * @return void
*/
public function reconnect()
{
@@ -135,6 +135,8 @@
/**
* Close the database connection.
+ *
+ * @return void
*/
protected function _close()
{
@@ -148,9 +150,9 @@
*
* @param string $databaseName
*
- * @return mixed
+ * @return boolean
*/
- public function setDatabase(string $databaseName)
+ public function setDatabase(string $databaseName): bool
{
return false;
}
@@ -160,9 +162,9 @@
/**
* Returns a string containing the version of the database being used.
*
- * @return mixed
+ * @return string
*/
- public function getVersion()
+ public function getVersion(): string
{
if (isset($this->dataCache['version']))
{
@@ -186,7 +188,7 @@
*
* @return resource
*/
- public function execute($sql)
+ public function execute(string $sql)
{
return pg_query($this->connID, $sql);
}
@@ -196,7 +198,7 @@
/**
* Returns the total number of rows affected by this query.
*
- * @return mixed
+ * @return integer
*/
public function affectedRows(): int
{
@@ -210,7 +212,7 @@
*
* Escapes data based on type
*
- * @param string $str
+ * @param mixed $str
* @return mixed
*/
public function escape($str)
@@ -259,7 +261,7 @@
*
* @return string
*/
- protected function _listTables($prefixLimit = false): string
+ protected function _listTables(bool $prefixLimit = false): string
{
$sql = 'SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" = \'' . $this->schema . "'";
@@ -312,17 +314,17 @@
}
$query = $query->getResultObject();
- $retval = [];
+ $retVal = [];
for ($i = 0, $c = count($query); $i < $c; $i ++)
{
- $retval[$i] = new \stdClass();
- $retval[$i]->name = $query[$i]->column_name;
- $retval[$i]->type = $query[$i]->data_type;
- $retval[$i]->default = $query[$i]->column_default;
- $retval[$i]->max_length = $query[$i]->character_maximum_length > 0 ? $query[$i]->character_maximum_length : $query[$i]->numeric_precision;
+ $retVal[$i] = new \stdClass();
+ $retVal[$i]->name = $query[$i]->column_name;
+ $retVal[$i]->type = $query[$i]->data_type;
+ $retVal[$i]->default = $query[$i]->column_default;
+ $retVal[$i]->max_length = $query[$i]->character_maximum_length > 0 ? $query[$i]->character_maximum_length : $query[$i]->numeric_precision;
}
- return $retval;
+ return $retVal;
}
//--------------------------------------------------------------------
@@ -347,7 +349,7 @@
}
$query = $query->getResultObject();
- $retval = [];
+ $retVal = [];
foreach ($query as $row)
{
$obj = new \stdClass();
@@ -366,10 +368,10 @@
$obj->type = (strpos($row->indexdef, 'CREATE UNIQUE') === 0) ? 'UNIQUE' : 'INDEX';
}
- $retval[$obj->name] = $obj;
+ $retVal[$obj->name] = $obj;
}
- return $retval;
+ return $retVal;
}
//--------------------------------------------------------------------
@@ -401,17 +403,17 @@
}
$query = $query->getResultObject();
- $retval = [];
+ $retVal = [];
foreach ($query as $row)
{
$obj = new \stdClass();
$obj->constraint_name = $row->constraint_name;
$obj->table_name = $row->table_name;
$obj->foreign_table_name = $row->foreign_table_name;
- $retval[] = $obj;
+ $retVal[] = $obj;
}
- return $retval;
+ return $retVal;
}
//--------------------------------------------------------------------
@@ -425,7 +427,7 @@
*
* @return array
*/
- public function error()
+ public function error(): array
{
return [
'code' => '',
@@ -440,7 +442,7 @@
*
* @return integer
*/
- public function insertID()
+ public function insertID(): int
{
$v = pg_version($this->connID);
// 'server' key is only available since PostgreSQL 7.4
@@ -540,7 +542,7 @@
* @param string $charset The client encoding to which the data will be converted.
* @return boolean
*/
- protected function setClientEncoding($charset)
+ protected function setClientEncoding(string $charset): bool
{
return pg_set_client_encoding($this->connID, $charset) === 0;
}
diff --git a/system/Database/Postgre/Forge.php b/system/Database/Postgre/Forge.php
index 4b05d9f..1dcbaf8 100644
--- a/system/Database/Postgre/Forge.php
+++ b/system/Database/Postgre/Forge.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Database/Postgre/PreparedQuery.php b/system/Database/Postgre/PreparedQuery.php
index fdd0aa4..9cf88bd 100644
--- a/system/Database/Postgre/PreparedQuery.php
+++ b/system/Database/Postgre/PreparedQuery.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -41,6 +41,9 @@
use CodeIgniter\Database\PreparedQueryInterface;
use CodeIgniter\Database\BasePreparedQuery;
+/**
+ * Prepared query for Postgre
+ */
class PreparedQuery extends BasePreparedQuery implements PreparedQueryInterface
{
@@ -74,6 +77,7 @@
* Unused in the MySQLi driver.
*
* @return mixed
+ * @throws \Exception
*/
public function _prepare(string $sql, array $options = [])
{
@@ -104,7 +108,7 @@
*
* @return boolean
*/
- public function _execute($data)
+ public function _execute(array $data): bool
{
if (is_null($this->statement))
{
diff --git a/system/Database/Postgre/Result.php b/system/Database/Postgre/Result.php
index af4af66..6842e36 100644
--- a/system/Database/Postgre/Result.php
+++ b/system/Database/Postgre/Result.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -84,19 +84,19 @@
*/
public function getFieldData(): array
{
- $retval = [];
+ $retVal = [];
for ($i = 0, $c = $this->getFieldCount(); $i < $c; $i ++)
{
- $retval[$i] = new \stdClass();
- $retval[$i]->name = pg_field_name($this->resultID, $i);
- $retval[$i]->type = pg_field_type($this->resultID, $i);
- $retval[$i]->max_length = pg_field_size($this->resultID, $i);
- // $retval[$i]->primary_key = (int)($fieldData[$i]->flags & 2);
- // $retval[$i]->default = $fieldData[$i]->def;
+ $retVal[$i] = new \stdClass();
+ $retVal[$i]->name = pg_field_name($this->resultID, $i);
+ $retVal[$i]->type = pg_field_type($this->resultID, $i);
+ $retVal[$i]->max_length = pg_field_size($this->resultID, $i);
+ // $retVal[$i]->primary_key = (int)($fieldData[$i]->flags & 2);
+ // $retVal[$i]->default = $fieldData[$i]->def;
}
- return $retval;
+ return $retVal;
}
//--------------------------------------------------------------------
@@ -104,7 +104,7 @@
/**
* Frees the current result.
*
- * @return mixed
+ * @return void
*/
public function freeResult()
{
@@ -126,7 +126,7 @@
*
* @return mixed
*/
- public function dataSeek($n = 0)
+ public function dataSeek(int $n = 0)
{
return pg_result_seek($this->resultID, $n);
}
@@ -138,7 +138,7 @@
*
* Overridden by driver classes.
*
- * @return array
+ * @return mixed
*/
protected function fetchAssoc()
{
@@ -156,7 +156,7 @@
*
* @return object
*/
- protected function fetchObject($className = 'stdClass')
+ protected function fetchObject(string $className = 'stdClass')
{
return pg_fetch_object($this->resultID, null, $className);
}
diff --git a/system/Database/Postgre/Utils.php b/system/Database/Postgre/Utils.php
index 41143e7..aa95536 100644
--- a/system/Database/Postgre/Utils.php
+++ b/system/Database/Postgre/Utils.php
@@ -31,18 +31,19 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
namespace CodeIgniter\Database\Postgre;
+use CodeIgniter\Database\BaseUtils;
use CodeIgniter\Database\Exceptions\DatabaseException;
/**
* Utils for Postgre
*/
-class Utils extends \CodeIgniter\Database\BaseUtils
+class Utils extends BaseUtils
{
/**
diff --git a/system/Database/PreparedQueryInterface.php b/system/Database/PreparedQueryInterface.php
index f1ed057..d29e250 100644
--- a/system/Database/PreparedQueryInterface.php
+++ b/system/Database/PreparedQueryInterface.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Database/Query.php b/system/Database/Query.php
index 39baaf7..06d1359 100644
--- a/system/Database/Query.php
+++ b/system/Database/Query.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Database/QueryInterface.php b/system/Database/QueryInterface.php
index 7f5cfb1..f7381b9 100644
--- a/system/Database/QueryInterface.php
+++ b/system/Database/QueryInterface.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -52,12 +52,13 @@
/**
* Sets the raw query string to use for this statement.
*
- * @param string $sql
- * @param array $binds
+ * @param string $sql
+ * @param mixed $binds
+ * @param boolean $setEscape
*
* @return mixed
*/
- public function setQuery(string $sql, $binds = null);
+ public function setQuery(string $sql, $binds = null, bool $setEscape = true);
//--------------------------------------------------------------------
@@ -91,9 +92,9 @@
*
* @param integer $decimals The accuracy of the returned time.
*
- * @return mixed
+ * @return string
*/
- public function getDuration(int $decimals = 6);
+ public function getDuration(int $decimals = 6): string;
//--------------------------------------------------------------------
diff --git a/system/Database/ResultInterface.php b/system/Database/ResultInterface.php
index af21786..6ebfe2c 100644
--- a/system/Database/ResultInterface.php
+++ b/system/Database/ResultInterface.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -53,7 +53,7 @@
*
* @return mixed
*/
- public function getResult($type = 'object'): array;
+ public function getResult(string $type = 'object'): array;
//--------------------------------------------------------------------
@@ -96,12 +96,12 @@
*
* If row doesn't exist, returns null.
*
- * @param integer $n The index of the results to return
- * @param string $type The type of result object. 'array', 'object' or class name.
+ * @param mixed $n The index of the results to return
+ * @param string $type The type of result object. 'array', 'object' or class name.
*
* @return mixed
*/
- public function getRow($n = 0, $type = 'object');
+ public function getRow($n = 0, string $type = 'object');
//--------------------------------------------------------------------
@@ -115,7 +115,7 @@
*
* @return mixed
*/
- public function getCustomRowObject($n, string $className);
+ public function getCustomRowObject(int $n, string $className);
//--------------------------------------------------------------------
@@ -128,7 +128,7 @@
*
* @return mixed
*/
- public function getRowArray($n = 0);
+ public function getRowArray(int $n = 0);
//--------------------------------------------------------------------
@@ -141,7 +141,7 @@
*
* @return mixed
*/
- public function getRowObject($n = 0);
+ public function getRowObject(int $n = 0);
//--------------------------------------------------------------------
@@ -164,7 +164,7 @@
*
* @return mixed
*/
- public function getFirstRow($type = 'object');
+ public function getFirstRow(string $type = 'object');
//--------------------------------------------------------------------
@@ -175,7 +175,7 @@
*
* @return mixed
*/
- public function getLastRow($type = 'object');
+ public function getLastRow(string $type = 'object');
//--------------------------------------------------------------------
@@ -186,7 +186,7 @@
*
* @return mixed
*/
- public function getNextRow($type = 'object');
+ public function getNextRow(string $type = 'object');
//--------------------------------------------------------------------
@@ -197,7 +197,7 @@
*
* @return mixed
*/
- public function getPreviousRow($type = 'object');
+ public function getPreviousRow(string $type = 'object');
//--------------------------------------------------------------------
@@ -208,7 +208,7 @@
*
* @return mixed
*/
- public function getUnbufferedRow($type = 'object');
+ public function getUnbufferedRow(string $type = 'object');
//--------------------------------------------------------------------
@@ -242,7 +242,7 @@
/**
* Frees the current result.
*
- * @return mixed
+ * @return void
*/
public function freeResult();
@@ -257,7 +257,7 @@
*
* @return mixed
*/
- public function dataSeek($n = 0);
+ public function dataSeek(int $n = 0);
//--------------------------------------------------------------------
}
diff --git a/system/Database/SQLite3/Builder.php b/system/Database/SQLite3/Builder.php
index 4d1c84e..ba09b58 100644
--- a/system/Database/SQLite3/Builder.php
+++ b/system/Database/SQLite3/Builder.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -76,9 +76,9 @@
*
* Generates a platform-specific replace string from the supplied data
*
- * @param string the table name
- * @param array the insert keys
- * @param array the insert values
+ * @param string $table the table name
+ * @param array $keys the insert keys
+ * @param array $values the insert values
*
* @return string
*/
diff --git a/system/Database/SQLite3/Connection.php b/system/Database/SQLite3/Connection.php
index 225deed..af14d99 100644
--- a/system/Database/SQLite3/Connection.php
+++ b/system/Database/SQLite3/Connection.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -64,7 +64,6 @@
*/
protected $_random_keyword = [
'RANDOM()',
- 'RANDOM()',
];
//--------------------------------------------------------------------
@@ -77,7 +76,7 @@
* @return mixed
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
*/
- public function connect($persistent = false)
+ public function connect(bool $persistent = false)
{
if ($persistent && $this->db->DBDebug)
{
@@ -101,7 +100,7 @@
* Keep or establish the connection if no queries have been sent for
* a length of time exceeding the server's idle timeout.
*
- * @return mixed
+ * @return void
*/
public function reconnect()
{
@@ -128,9 +127,9 @@
*
* @param string $databaseName
*
- * @return mixed
+ * @return boolean
*/
- public function setDatabase(string $databaseName)
+ public function setDatabase(string $databaseName): bool
{
return false;
}
@@ -140,9 +139,9 @@
/**
* Returns a string containing the version of the database being used.
*
- * @return mixed
+ * @return string
*/
- public function getVersion()
+ public function getVersion(): string
{
if (isset($this->dataCache['version']))
{
@@ -163,7 +162,7 @@
*
* @return mixed \SQLite3Result object or bool
*/
- public function execute($sql)
+ public function execute(string $sql)
{
return $this->isWriteType($sql)
? $this->connID->exec($sql)
@@ -175,7 +174,7 @@
/**
* Returns the total number of rows affected by this query.
*
- * @return mixed
+ * @return integer
*/
public function affectedRows(): int
{
@@ -205,7 +204,7 @@
*
* @return string
*/
- protected function _listTables($prefixLimit = false): string
+ protected function _listTables(bool $prefixLimit = false): string
{
return 'SELECT "NAME" FROM "SQLITE_MASTER" WHERE "TYPE" = \'table\''
. (($prefixLimit !== false && $this->DBPrefix !== '')
@@ -236,7 +235,7 @@
* @return array|false
* @throws DatabaseException
*/
- public function getFieldNames($table)
+ public function getFieldNames(string $table)
{
// Is there a cached result?
if (isset($this->dataCache['field_names'][$table]))
@@ -314,19 +313,19 @@
{
return [];
}
- $retval = [];
+ $retVal = [];
for ($i = 0, $c = count($query); $i < $c; $i++)
{
- $retval[$i] = new \stdClass();
- $retval[$i]->name = $query[$i]->name;
- $retval[$i]->type = $query[$i]->type;
- $retval[$i]->max_length = null;
- $retval[$i]->default = $query[$i]->dflt_value;
- $retval[$i]->primary_key = isset($query[$i]->pk) ? (bool)$query[$i]->pk : false;
- $retval[$i]->nullable = isset($query[$i]->notnull) ? ! (bool)$query[$i]->notnull : false;
+ $retVal[$i] = new \stdClass();
+ $retVal[$i]->name = $query[$i]->name;
+ $retVal[$i]->type = $query[$i]->type;
+ $retVal[$i]->max_length = null;
+ $retVal[$i]->default = $query[$i]->dflt_value;
+ $retVal[$i]->primary_key = isset($query[$i]->pk) ? (bool)$query[$i]->pk : false;
+ $retVal[$i]->nullable = isset($query[$i]->notnull) ? ! (bool)$query[$i]->notnull : false;
}
- return $retval;
+ return $retVal;
}
//--------------------------------------------------------------------
@@ -349,7 +348,7 @@
}
$query = $query->getResultObject();
- $retval = [];
+ $retVal = [];
foreach ($query as $row)
{
$obj = new \stdClass();
@@ -368,10 +367,10 @@
$obj->fields[] = $field->name;
}
- $retval[$obj->name] = $obj;
+ $retVal[$obj->name] = $obj;
}
- return $retval;
+ return $retVal;
}
//--------------------------------------------------------------------
@@ -396,7 +395,7 @@
return [];
}
- $retval = [];
+ $retVal = [];
foreach ($tables as $table)
{
@@ -409,11 +408,11 @@
$obj->table_name = $table;
$obj->foreign_table_name = $row->table;
- $retval[] = $obj;
+ $retVal[] = $obj;
}
}
- return $retval;
+ return $retVal;
}
//--------------------------------------------------------------------
diff --git a/system/Database/SQLite3/Forge.php b/system/Database/SQLite3/Forge.php
index b0756a9..7a5f77d 100644
--- a/system/Database/SQLite3/Forge.php
+++ b/system/Database/SQLite3/Forge.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Database/SQLite3/PreparedQuery.php b/system/Database/SQLite3/PreparedQuery.php
index 50e8dee..8ffb502 100644
--- a/system/Database/SQLite3/PreparedQuery.php
+++ b/system/Database/SQLite3/PreparedQuery.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -41,6 +41,10 @@
use CodeIgniter\Database\PreparedQueryInterface;
use CodeIgniter\Database\BasePreparedQuery;
+/**
+ * Prepared query for SQLite3
+ */
+
class PreparedQuery extends BasePreparedQuery implements PreparedQueryInterface
{
@@ -89,7 +93,7 @@
*
* @return boolean
*/
- public function _execute($data)
+ public function _execute(array $data): bool
{
if (is_null($this->statement))
{
diff --git a/system/Database/SQLite3/Result.php b/system/Database/SQLite3/Result.php
index 47b0cfe..014a11f 100644
--- a/system/Database/SQLite3/Result.php
+++ b/system/Database/SQLite3/Result.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -92,18 +92,18 @@
SQLITE3_NULL => 'null',
];
- $retval = [];
+ $retVal = [];
for ($i = 0, $c = $this->getFieldCount(); $i < $c; $i ++)
{
- $retval[$i] = new \stdClass();
- $retval[$i]->name = $this->resultID->columnName($i);
+ $retVal[$i] = new \stdClass();
+ $retVal[$i]->name = $this->resultID->columnName($i);
$type = $this->resultID->columnType($i);
- $retval[$i]->type = isset($data_types[$type]) ? $data_types[$type] : $type;
- $retval[$i]->max_length = null;
+ $retVal[$i]->type = isset($data_types[$type]) ? $data_types[$type] : $type;
+ $retVal[$i]->max_length = null;
}
- return $retval;
+ return $retVal;
}
//--------------------------------------------------------------------
@@ -111,7 +111,7 @@
/**
* Frees the current result.
*
- * @return mixed
+ * @return void
*/
public function freeResult()
{
@@ -134,16 +134,13 @@
* @return mixed
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
*/
- public function dataSeek($n = 0)
+ public function dataSeek(int $n = 0)
{
if ($n !== 0)
{
- if ($this->db->DBDebug)
- {
- throw new DatabaseException('SQLite3 doesn\'t support seeking to other offset.');
- }
- return false;
+ throw new DatabaseException('SQLite3 doesn\'t support seeking to other offset.');
}
+
return $this->resultID->reset();
}
@@ -154,7 +151,7 @@
*
* Overridden by driver classes.
*
- * @return array
+ * @return mixed
*/
protected function fetchAssoc()
{
@@ -170,9 +167,9 @@
*
* @param string $className
*
- * @return object
+ * @return object|boolean
*/
- protected function fetchObject($className = 'stdClass')
+ protected function fetchObject(string $className = 'stdClass')
{
// No native support for fetching rows as objects
if (($row = $this->fetchAssoc()) === false)
diff --git a/system/Database/SQLite3/Table.php b/system/Database/SQLite3/Table.php
index 0b31eb4..865502e 100644
--- a/system/Database/SQLite3/Table.php
+++ b/system/Database/SQLite3/Table.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -88,11 +88,15 @@
protected $prefixedTableName;
/**
+ * Database connection.
+ *
* @var Connection
*/
protected $db;
/**
+ * Handle to our forge.
+ *
* @var Forge
*/
protected $forge;
@@ -101,6 +105,7 @@
* Table constructor.
*
* @param Connection $db
+ * @param Forge $forge
*/
public function __construct(Connection $db, Forge $forge)
{
@@ -214,6 +219,8 @@
/**
* Creates the new table based on our current fields.
+ *
+ * @return mixed
*/
protected function createTable()
{
@@ -264,6 +271,8 @@
* Copies data from our old table to the new one,
* taking care map data correctly based on any columns
* that have been renamed.
+ *
+ * @return void
*/
protected function copyData()
{
@@ -297,7 +306,7 @@
*
* @param array|boolean $fields
*
- * @return array
+ * @return mixed
*/
protected function formatFields($fields)
{
@@ -332,7 +341,7 @@
* Converts keys retrieved from the database to
* the format needed to create later.
*
- * @param $keys
+ * @param mixed $keys
*
* @return mixed
*/
@@ -359,6 +368,8 @@
/**
* Attempts to drop all indexes and constraints
* from the database for this table.
+ *
+ * @return null|void
*/
protected function dropIndexes()
{
diff --git a/system/Database/SQLite3/Utils.php b/system/Database/SQLite3/Utils.php
index bdb8ec0..5c4263a 100644
--- a/system/Database/SQLite3/Utils.php
+++ b/system/Database/SQLite3/Utils.php
@@ -32,18 +32,19 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
namespace CodeIgniter\Database\SQLite3;
+use CodeIgniter\Database\BaseUtils;
use CodeIgniter\Database\Exceptions\DatabaseException;
/**
* Utils for SQLite3
*/
-class Utils extends \CodeIgniter\Database\BaseUtils
+class Utils extends BaseUtils
{
/**
diff --git a/system/Database/Seeder.php b/system/Database/Seeder.php
index 47fd52c..18c8304 100644
--- a/system/Database/Seeder.php
+++ b/system/Database/Seeder.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php
index 696f0db..009a081 100644
--- a/system/Debug/Exceptions.php
+++ b/system/Debug/Exceptions.php
@@ -32,14 +32,20 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
namespace CodeIgniter\Debug;
use CodeIgniter\API\ResponseTrait;
+use CodeIgniter\Exceptions\PageNotFoundException;
+use CodeIgniter\HTTP\IncomingRequest;
+use CodeIgniter\HTTP\Response;
use Config\Paths;
+use function error_reporting;
+use ErrorException;
+use Throwable;
/**
* Exceptions manager
@@ -64,16 +70,22 @@
protected $viewPath;
/**
+ * Config for debug exceptions.
+ *
* @var \Config\Exceptions
*/
protected $config;
/**
+ * The incoming request.
+ *
* @var \CodeIgniter\HTTP\IncomingRequest
*/
protected $request;
/**
+ * The outgoing response.
+ *
* @var \CodeIgniter\HTTP\Response
*/
protected $response;
@@ -87,7 +99,7 @@
* @param \CodeIgniter\HTTP\IncomingRequest $request
* @param \CodeIgniter\HTTP\Response $response
*/
- public function __construct(\Config\Exceptions $config, \CodeIgniter\HTTP\IncomingRequest $request, \CodeIgniter\HTTP\Response $response)
+ public function __construct(\Config\Exceptions $config, IncomingRequest $request, Response $response)
{
$this->ob_level = ob_get_level();
@@ -127,7 +139,7 @@
*
* @param \Throwable $exception
*/
- public function exceptionHandler(\Throwable $exception)
+ public function exceptionHandler(Throwable $exception)
{
$codes = $this->determineCodes($exception);
$statusCode = $codes[0];
@@ -179,13 +191,13 @@
*/
public function errorHandler(int $severity, string $message, string $file = null, int $line = null, $context = null)
{
- if (! (\error_reporting() & $severity))
+ if (! (error_reporting() & $severity))
{
return;
}
// Convert it to an exception and pass it along.
- throw new \ErrorException($message, 0, $severity, $file, $line);
+ throw new ErrorException($message, 0, $severity, $file, $line);
}
//--------------------------------------------------------------------
@@ -206,7 +218,7 @@
// Fatal Error?
if (in_array($error['type'], [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE]))
{
- $this->exceptionHandler(new \ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']));
+ $this->exceptionHandler(new ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']));
}
}
}
@@ -222,7 +234,7 @@
*
* @return string The path and filename of the view file to use
*/
- protected function determineView(\Throwable $exception, string $template_path): string
+ protected function determineView(Throwable $exception, string $template_path): string
{
// Production environments should have a custom exception file.
$view = 'production.php';
@@ -234,7 +246,7 @@
}
// 404 Errors
- if ($exception instanceof \CodeIgniter\Exceptions\PageNotFoundException)
+ if ($exception instanceof PageNotFoundException)
{
return 'error_404.php';
}
@@ -256,7 +268,7 @@
* @param \Throwable $exception
* @param integer $statusCode
*/
- protected function render(\Throwable $exception, int $statusCode)
+ protected function render(Throwable $exception, int $statusCode)
{
// Determine directory with views
$path = $this->viewPath;
@@ -300,7 +312,7 @@
*
* @return array
*/
- protected function collectVars(\Throwable $exception, int $statusCode): array
+ protected function collectVars(Throwable $exception, int $statusCode): array
{
return [
'title' => get_class($exception),
@@ -320,7 +332,7 @@
*
* @return array
*/
- protected function determineCodes(\Throwable $exception): array
+ protected function determineCodes(Throwable $exception): array
{
$statusCode = abs($exception->getCode());
@@ -432,7 +444,7 @@
{
$source = file_get_contents($file);
}
- catch (\Throwable $e)
+ catch (Throwable $e)
{
return false;
}
diff --git a/system/Debug/Iterator.php b/system/Debug/Iterator.php
index 2a8d332..abad5f4 100644
--- a/system/Debug/Iterator.php
+++ b/system/Debug/Iterator.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -65,12 +65,12 @@
* Tests are simply closures that the user can define any sequence of
* things to happen during the test.
*
- * @param $name
+ * @param string $name
* @param \Closure $closure
*
* @return $this
*/
- public function add($name, \Closure $closure)
+ public function add(string $name, \Closure $closure)
{
$name = strtolower($name);
@@ -89,9 +89,9 @@
* @param integer $iterations
* @param boolean $output
*
- * @return string
+ * @return string|null
*/
- public function run($iterations = 1000, $output = true)
+ public function run(int $iterations = 1000, bool $output = true)
{
foreach ($this->tests as $name => $test)
{
@@ -121,6 +121,8 @@
{
return $this->getReport();
}
+
+ return null;
}
//--------------------------------------------------------------------
diff --git a/system/Debug/Timer.php b/system/Debug/Timer.php
index 11c228c..ab5fc2d 100644
--- a/system/Debug/Timer.php
+++ b/system/Debug/Timer.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php
index f67bffb..5b1066c 100644
--- a/system/Debug/Toolbar.php
+++ b/system/Debug/Toolbar.php
@@ -31,17 +31,19 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
namespace CodeIgniter\Debug;
+use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Debug\Toolbar\Collectors\History;
use CodeIgniter\Format\JSONFormatter;
-use Config\Services;
-use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Format\XMLFormatter;
+use CodeIgniter\HTTP\RequestInterface;
+use CodeIgniter\HTTP\ResponseInterface;
+use Config\Services;
/**
* Debug Toolbar
@@ -55,6 +57,8 @@
class Toolbar
{
/**
+ * Toolbar configuration settings.
+ *
* @var BaseConfig
*/
protected $config;
@@ -102,7 +106,7 @@
*
* @return string JSON encoded data
*/
- public function run($startTime, $totalTime, $request, $response): string
+ public function run(float $startTime, float $totalTime, RequestInterface $request, ResponseInterface $response): string
{
// Data items used within the view.
$data['url'] = current_url();
@@ -123,17 +127,17 @@
foreach ($this->collectVarData() as $heading => $items)
{
- $vardata = [];
+ $varData = [];
if (is_array($items))
{
foreach ($items as $key => $value)
{
- $vardata[esc($key)] = is_string($value) ? esc($value) : print_r($value, true);
+ $varData[esc($key)] = is_string($value) ? esc($value) : print_r($value, true);
}
}
- $data['vars']['varData'][esc($heading)] = $vardata;
+ $data['vars']['varData'][esc($heading)] = $varData;
}
if (! empty($_SESSION))
@@ -141,7 +145,7 @@
foreach ($_SESSION as $key => $value)
{
// Replace the binary data with string to avoid json_encode failure.
- if (preg_match('~[^\x20-\x7E\t\r\n]~', $value))
+ if (is_string($value) && preg_match('~[^\x20-\x7E\t\r\n]~', $value))
{
$value = 'binary data';
}
@@ -212,10 +216,11 @@
* @param float $startTime
* @param integer $segmentCount
* @param integer $segmentDuration
+ * @param array $styles
*
* @return string
*/
- protected function renderTimeline(array $collectors, $startTime, int $segmentCount, int $segmentDuration, array& $styles): string
+ protected function renderTimeline(array $collectors, $startTime, int $segmentCount, int $segmentDuration, array &$styles): string
{
$displayTime = $segmentCount * $segmentDuration;
$rows = $this->collectTimelineData($collectors);
@@ -234,8 +239,7 @@
$length = (($row['duration'] * 1000) / $displayTime) * 100;
$styles['debug-bar-timeline-' . $styleCount] = "left: {$offset}%; width: {$length}%;";
- $output .= "";
+ $output .= "";
$output .= '';
$output .= '';
@@ -250,6 +254,8 @@
/**
* Returns a sorted array of timeline data arrays from the collectors.
*
+ * @param array $collectors
+ *
* @return array
*/
protected function collectTimelineData($collectors): array
@@ -307,7 +313,7 @@
*
* @return float
*/
- protected function roundTo($number, $increments = 5): float
+ protected function roundTo(float $number, int $increments = 5): float
{
$increments = 1 / $increments;
@@ -316,6 +322,12 @@
//--------------------------------------------------------------------
+ /**
+ * Prepare for debugging..
+ *
+ * @global type $app
+ * @return type
+ */
public function prepare()
{
if (CI_DEBUG && ! is_cli())
@@ -384,7 +396,7 @@
//--------------------------------------------------------------------
/**
- *
+ * Inject debug toolbar into the response.
*/
public function respond()
{
diff --git a/system/Debug/Toolbar/Collectors/BaseCollector.php b/system/Debug/Toolbar/Collectors/BaseCollector.php
index 0785f13..16a948d 100644
--- a/system/Debug/Toolbar/Collectors/BaseCollector.php
+++ b/system/Debug/Toolbar/Collectors/BaseCollector.php
@@ -91,7 +91,7 @@
* @param boolean $safe
* @return string
*/
- public function getTitle($safe = false): string
+ public function getTitle(bool $safe = false): string
{
if ($safe)
{
@@ -232,9 +232,9 @@
/**
* Returns the data of this collector to be formatted in the toolbar
*
- * @return array
+ * @return array|string
*/
- public function display(): array
+ public function display()
{
return [];
}
@@ -303,6 +303,11 @@
return '';
}
+ /**
+ * Return settings as an array.
+ *
+ * @return array
+ */
public function getAsArray(): array
{
return [
diff --git a/system/Debug/Toolbar/Collectors/Config.php b/system/Debug/Toolbar/Collectors/Config.php
index 7ab1e3d..25ef37f 100644
--- a/system/Debug/Toolbar/Collectors/Config.php
+++ b/system/Debug/Toolbar/Collectors/Config.php
@@ -47,6 +47,11 @@
*/
class Config
{
+ /**
+ * Return toolbar config values as an array.
+ *
+ * @return array
+ */
public static function display(): array
{
$config = config(App::class);
@@ -60,7 +65,6 @@
'timezone' => app_timezone(),
'locale' => Services::request()->getLocale(),
'cspEnabled' => $config->CSPEnabled,
- 'salt' => $config->salt,
];
}
}
diff --git a/system/Debug/Toolbar/Collectors/Events.php b/system/Debug/Toolbar/Collectors/Events.php
index f2d397a..a20faca 100644
--- a/system/Debug/Toolbar/Collectors/Events.php
+++ b/system/Debug/Toolbar/Collectors/Events.php
@@ -102,7 +102,7 @@
* Child classes should implement this to return the timeline data
* formatted for correct usage.
*
- * @return mixed
+ * @return array
*/
protected function formatTimelineData(): array
{
diff --git a/system/Debug/Toolbar/Collectors/History.php b/system/Debug/Toolbar/Collectors/History.php
index 7249332..d0f2806 100644
--- a/system/Debug/Toolbar/Collectors/History.php
+++ b/system/Debug/Toolbar/Collectors/History.php
@@ -83,6 +83,8 @@
//--------------------------------------------------------------------
/**
+ * Specify time limit & file count for debug history.
+ *
* @param integer $current Current history time
* @param integer $limit Max history files
*/
@@ -111,7 +113,7 @@
if (json_last_error() === JSON_ERROR_NONE)
{
preg_match_all('/\d+/', $filename, $time);
- $time = (int)$time[0][0];
+ $time = (int)end($time[0]);
// Debugbar files shown in History Collector
$files[] = [
@@ -154,6 +156,11 @@
return count($this->files);
}
+ /**
+ * Return true if there are no history files.
+ *
+ * @return boolean
+ */
public function isEmpty(): bool
{
return empty($this->files);
diff --git a/system/Debug/Toolbar/Collectors/Routes.php b/system/Debug/Toolbar/Collectors/Routes.php
index bc9c595..2e3a1e3 100644
--- a/system/Debug/Toolbar/Collectors/Routes.php
+++ b/system/Debug/Toolbar/Collectors/Routes.php
@@ -97,7 +97,7 @@
$params[] = [
'name' => $param->getName(),
'value' => $router->params()[$key] ??
- '<empty> | default: ' . var_export($param->getDefaultValue(), true),
+ '<empty> | default: ' . var_export($param->isDefaultValueAvailable() ? $param->getDefaultValue() : null, true),
];
}
diff --git a/system/Debug/Toolbar/Collectors/Timers.php b/system/Debug/Toolbar/Collectors/Timers.php
index 0a08545..adf5409 100644
--- a/system/Debug/Toolbar/Collectors/Timers.php
+++ b/system/Debug/Toolbar/Collectors/Timers.php
@@ -76,7 +76,7 @@
* Child classes should implement this to return the timeline data
* formatted for correct usage.
*
- * @return mixed
+ * @return array
*/
protected function formatTimelineData(): array
{
diff --git a/system/Debug/Toolbar/Collectors/Views.php b/system/Debug/Toolbar/Collectors/Views.php
index 57ec408..25c909f 100644
--- a/system/Debug/Toolbar/Collectors/Views.php
+++ b/system/Debug/Toolbar/Collectors/Views.php
@@ -117,7 +117,7 @@
* Child classes should implement this to return the timeline data
* formatted for correct usage.
*
- * @return mixed
+ * @return array
*/
protected function formatTimelineData(): array
{
diff --git a/system/Debug/Toolbar/Views/_config.tpl.php b/system/Debug/Toolbar/Views/_config.tpl.php
index 08c06f0..4247e81 100644
--- a/system/Debug/Toolbar/Views/_config.tpl.php
+++ b/system/Debug/Toolbar/Views/_config.tpl.php
@@ -44,17 +44,5 @@
Content Security Policy Enabled: |
{ if $cspEnabled } Yes { else } No { endif } |
-
- Salt Set?: |
-
- { if $salt == '' }
-
- You have not defined an application-wide $salt. This could lead to a less secure site.
-
- { else }
- Set
- { endif }
- |
-
diff --git a/system/Debug/Toolbar/Views/toolbar.tpl.php b/system/Debug/Toolbar/Views/toolbar.tpl.php
index 2494a83..b746364 100644
--- a/system/Debug/Toolbar/Views/toolbar.tpl.php
+++ b/system/Debug/Toolbar/Views/toolbar.tpl.php
@@ -136,7 +136,7 @@
= $c['title'] ?> = $c['titleDetails'] ?>
- = $parser->setData($c['display'])->render("_{$c['titleSafe']}.tpl") ?>
+ = is_string($c['display']) ? $c['display'] : $parser->setData($c['display'])->render("_{$c['titleSafe']}.tpl") ?>
diff --git a/system/Debug/Toolbar/Views/toolbarloader.js.php b/system/Debug/Toolbar/Views/toolbarloader.js.php
index 62e3418..539490b 100644
--- a/system/Debug/Toolbar/Views/toolbarloader.js.php
+++ b/system/Debug/Toolbar/Views/toolbarloader.js.php
@@ -56,12 +56,16 @@
}
};
- xhttp.open("GET", url + "?debugbar_time=" + time, true);
+ xhttp.open("GET", url + "/?debugbar_time=" + time, true);
xhttp.send();
}
// Track all AJAX requests
-var oldXHR = window.XMLHttpRequest;
+if (window.ActiveXObject) {
+ var oldXHR = new ActiveXObject('Microsoft.XMLHTTP');
+} else {
+ var oldXHR = window.XMLHttpRequest;
+}
function newXHR() {
var realXHR = new oldXHR();
diff --git a/system/Entity.php b/system/Entity.php
index bdada1b..19cb2b3 100644
--- a/system/Entity.php
+++ b/system/Entity.php
@@ -32,12 +32,13 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
namespace CodeIgniter;
+use CodeIgniter\Exceptions\EntityException;
use CodeIgniter\I18n\Time;
use CodeIgniter\Exceptions\CastException;
@@ -46,8 +47,7 @@
*/
class Entity
{
- protected $_options = [
- /*
+ /**
* Maps names used in sets and gets against unique
* names within the class, allowing independence from
* database column names.
@@ -57,9 +57,10 @@
* 'db_name' => 'class_name'
* ];
*/
+ protected $_options = [
'datamap' => [],
- /*
+ /**
* Define properties that are automatically converted to Time instances.
*/
'dates' => [
@@ -68,7 +69,7 @@
'deleted_at',
],
- /*
+ /**
* Array of field names and the type of value to cast them as
* when they are accessed.
*/
@@ -295,6 +296,11 @@
$result = $this->castAs($result, $this->_options['casts'][$key]);
}
+ if (! isset($result) && ! property_exists($this, $key))
+ {
+ throw EntityException::forTryingToAccessNonExistentProperty($key, get_called_class());
+ }
+
return $result;
}
@@ -313,6 +319,7 @@
* @param null $value
*
* @return $this
+ * @throws \Exception
*/
public function __set(string $key, $value = null)
{
@@ -349,6 +356,11 @@
if (($castTo === 'json' || $castTo === 'json-array') && function_exists('json_encode'))
{
$value = json_encode($value);
+
+ if (json_last_error() !== JSON_ERROR_NONE)
+ {
+ throw CastException::forInvalidJsonFormatException(json_last_error());
+ }
}
}
diff --git a/system/Events/Events.php b/system/Events/Events.php
index f92f42a..5fab269 100644
--- a/system/Events/Events.php
+++ b/system/Events/Events.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/Exceptions/EntityException.php b/system/Exceptions/EntityException.php
new file mode 100644
index 0000000..40e3017
--- /dev/null
+++ b/system/Exceptions/EntityException.php
@@ -0,0 +1,22 @@
+config = $config;
@@ -105,6 +111,11 @@
$this->setResponse($response);
}
+ /**
+ * Set the response explicity.
+ *
+ * @param ResponseInterface $response
+ */
public function setResponse(ResponseInterface $response)
{
$this->response = & $response;
@@ -147,7 +158,7 @@
if ($position === 'before')
{
- $result = $class->before($this->request);
+ $result = $class->before($this->request, $this->arguments[$alias] ?? null);
if ($result instanceof RequestInterface)
{
@@ -228,7 +239,7 @@
*
* @return array
*/
- public function getFilters()
+ public function getFilters(): array
{
return $this->filters;
}
@@ -313,13 +324,11 @@
/**
* Returns the arguments for a specified key, or all.
*
- * @return array
+ * @return mixed
*/
public function getArguments(string $key = null)
{
- return is_null($key)
- ? $this->arguments
- : $this->arguments[$key];
+ return is_null($key) ? $this->arguments : $this->arguments[$key];
}
//--------------------------------------------------------------------
@@ -327,6 +336,12 @@
// Processors
//--------------------------------------------------------------------
+ /**
+ * Add any applicable (not excluded) global filter settings to the mix.
+ *
+ * @param string $uri
+ * @return type
+ */
protected function processGlobals(string $uri = null)
{
if (! isset($this->config->globals) || ! is_array($this->config->globals))
@@ -334,85 +349,54 @@
return;
}
- // Before
- if (isset($this->config->globals['before']))
+ $uri = strtolower(trim($uri, '/ '));
+
+ // Add any global filters, unless they are excluded for this URI
+ $sets = [
+ 'before',
+ 'after',
+ ];
+ foreach ($sets as $set)
{
- // Take any 'except' routes into consideration
- foreach ($this->config->globals['before'] as $alias => $rules)
+ if (isset($this->config->globals[$set]))
{
- if (! is_array($rules) || ! array_key_exists('except', $rules))
+ // look at each alias in the group
+ foreach ($this->config->globals[$set] as $alias => $rules)
{
- continue;
- }
-
- $rules = $rules['except'];
-
- if (is_string($rules))
- {
- $rules = [$rules];
- }
-
- foreach ($rules as $path)
- {
- // Prep it for regex
- $path = strtolower(str_replace('/*', '*', $path));
- $path = trim(str_replace('*', '.+', $path), '/ ');
-
- // Path doesn't match the URI? continue on...
- if (preg_match('#' . $path . '#', $uri, $match) !== 1)
+ $keep = true;
+ if (is_array($rules))
{
- continue;
+ // see if it should be excluded
+ if (isset($rules['except']))
+ {
+ // grab the exclusion rules
+ $check = $rules['except'];
+ if ($this->pathApplies($uri, $check))
+ {
+ $keep = false;
+ }
+ }
}
-
- unset($this->config->globals['before'][$alias]);
- break;
+ else
+ {
+ $alias = $rules; // simple name of filter to apply
+ }
+ if ($keep)
+ {
+ $this->filters[$set][] = $alias;
+ }
}
}
-
- $this->filters['before'] = array_merge($this->filters['before'], $this->config->globals['before']);
- }
-
- // After
- if (isset($this->config->globals['after']))
- {
- // Take any 'except' routes into consideration
- foreach ($this->config->globals['after'] as $alias => $rules)
- {
- if (! is_array($rules) || ! array_key_exists('except', $rules))
- {
- continue;
- }
-
- $rules = $rules['except'];
-
- if (is_string($rules))
- {
- $rules = [$rules];
- }
-
- foreach ($rules as $path)
- {
- // Prep it for regex
- $path = strtolower(str_replace('/*', '*', $path));
- $path = trim(str_replace('*', '.+', $path), '/ ');
-
- // Path doesn't match the URI? continue on...
- if (preg_match('#' . $path . '#', $uri, $match) !== 1)
- {
- continue;
- }
-
- unset($this->config->globals['after'][$alias]);
- break;
- }
- }
-
- $this->filters['after'] = array_merge($this->filters['after'], $this->config->globals['after']);
}
}
//--------------------------------------------------------------------
+ /**
+ * Add any method-specific flters to the mix.
+ *
+ * @return type
+ */
protected function processMethods()
{
if (! isset($this->config->methods) || ! is_array($this->config->methods))
@@ -432,6 +416,12 @@
//--------------------------------------------------------------------
+ /**
+ * Add any applicable configured filters to the mix.
+ *
+ * @param string $uri
+ * @return type
+ */
protected function processFilters(string $uri = null)
{
if (! isset($this->config->filters) || ! $this->config->filters)
@@ -441,53 +431,64 @@
$uri = strtolower(trim($uri, '/ '));
- $matches = [];
-
+ // Add any filters that apply to this URI
foreach ($this->config->filters as $alias => $settings)
{
- // Before
+ // Look for inclusion rules
if (isset($settings['before']))
{
- foreach ($settings['before'] as $path)
+ $path = $settings['before'];
+ if ($this->pathApplies($uri, $path))
{
- // Prep it for regex
- $path = strtolower(str_replace('/*', '*', $path));
- $path = trim(str_replace('*', '.+', $path), '/ ');
-
- if (preg_match('#' . $path . '#', $uri) !== 1)
- {
- continue;
- }
-
- $matches[] = $alias;
+ $this->filters['before'][] = $alias;
}
-
- $this->filters['before'] = array_merge($this->filters['before'], $matches);
- $matches = [];
}
-
- // After
if (isset($settings['after']))
{
- foreach ($settings['after'] as $path)
+ $path = $settings['after'];
+ if ($this->pathApplies($uri, $path))
{
- // Prep it for regex
- $path = strtolower(str_replace('/*', '*', $path));
- $path = trim(str_replace('*', '.+', $path), '/ ');
-
- if (preg_match('#' . $path . '#', $uri) !== 1)
- {
- continue;
- }
-
- $matches[] = $alias;
+ $this->filters['after'][] = $alias;
}
-
- $this->filters['after'] = array_merge($this->filters['after'], $matches);
- $matches = [];
}
}
}
- //--------------------------------------------------------------------
+ /**
+ * Check paths for match for URI
+ *
+ * @param string $uri URI to test against
+ * @param mixed $paths The path patterns to test
+ * @return boolean True if any of the paths apply to the URI
+ */
+ private function pathApplies(string $uri, $paths)
+ {
+ // empty path matches all
+ if (empty($paths))
+ {
+ return true;
+ }
+
+ // make sure the paths are iterable
+ if (is_string($paths))
+ {
+ $paths = [$paths];
+ }
+
+ // treat each paths as pseudo-regex
+ foreach ($paths as $path)
+ {
+ // need to escape path separators
+ $path = str_replace('/', '\/', trim($path, '/ '));
+ // need to make pseudo wildcard real
+ $path = strtolower(str_replace('*', '.*', $path));
+ // Does this rule apply here?
+ if (preg_match('#' . $path . '#', $uri, $match) === 1)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
}
diff --git a/system/Filters/Honeypot.php b/system/Filters/Honeypot.php
index e1c84d6..c4b9b86 100644
--- a/system/Filters/Honeypot.php
+++ b/system/Filters/Honeypot.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -70,9 +70,9 @@
/**
* Attach a honeypot to the current response.
*
- * @param CodeIgniter\HTTP\RequestInterface $request
- * @param CodeIgniter\HTTP\ResponseInterface $response
- *
+ * @param \CodeIgniter\HTTP\RequestInterface $request
+ * @param \CodeIgniter\HTTP\ResponseInterface $response
+ *
* @return void
*/
public function after(RequestInterface $request, ResponseInterface $response)
diff --git a/system/Format/FormatterInterface.php b/system/Format/FormatterInterface.php
index 29a9d3f..9376228 100644
--- a/system/Format/FormatterInterface.php
+++ b/system/Format/FormatterInterface.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -47,9 +47,9 @@
/**
* Takes the given data and formats it.
*
- * @param array $data
+ * @param string|array $data
*
* @return mixed
*/
- public function format(array $data);
+ public function format($data);
}
diff --git a/system/Format/JSONFormatter.php b/system/Format/JSONFormatter.php
index 1152159..e05137a 100644
--- a/system/Format/JSONFormatter.php
+++ b/system/Format/JSONFormatter.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -51,9 +51,9 @@
*
* @param $data
*
- * @return mixed
+ * @return string|boolean (JSON string | false)
*/
- public function format(array $data)
+ public function format($data)
{
$options = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES;
diff --git a/system/Format/XMLFormatter.php b/system/Format/XMLFormatter.php
index 22bd86f..cb94aed 100644
--- a/system/Format/XMLFormatter.php
+++ b/system/Format/XMLFormatter.php
@@ -1,7 +1,5 @@
');
- $this->arrayToXML($data, $output);
+ $this->arrayToXML((array)$data, $output);
return $output->asXML();
}
diff --git a/system/HTTP/CLIRequest.php b/system/HTTP/CLIRequest.php
index 23f1c0f..518bb62 100644
--- a/system/HTTP/CLIRequest.php
+++ b/system/HTTP/CLIRequest.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -148,12 +148,7 @@
*/
public function getOption(string $key)
{
- if (array_key_exists($key, $this->options))
- {
- return $this->options[$key];
- }
-
- return null;
+ return $this->options[$key] ?? null;
}
//--------------------------------------------------------------------
diff --git a/system/HTTP/CURLRequest.php b/system/HTTP/CURLRequest.php
index f48b421..a0ba1ef 100644
--- a/system/HTTP/CURLRequest.php
+++ b/system/HTTP/CURLRequest.php
@@ -33,7 +33,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -399,7 +399,7 @@
*
* @return string
*/
- public function getMethod($upper = false): string
+ public function getMethod(bool $upper = false): string
{
return ($upper) ? strtoupper($this->method) : strtolower($this->method);
}
@@ -514,9 +514,9 @@
* @param string $method
* @param array $curl_options
*
- * @return array|integer
+ * @return array
*/
- protected function applyMethod($method, array $curl_options): array
+ protected function applyMethod(string $method, array $curl_options): array
{
$method = strtoupper($method);
@@ -763,6 +763,7 @@
$json = json_encode($config['json']);
$this->setBody($json);
$this->setHeader('Content-Type', 'application/json');
+ $this->setHeader('Content-Length', (string) strlen($json));
}
// version
diff --git a/system/HTTP/ContentSecurityPolicy.php b/system/HTTP/ContentSecurityPolicy.php
index e013bb7..d88cd40 100644
--- a/system/HTTP/ContentSecurityPolicy.php
+++ b/system/HTTP/ContentSecurityPolicy.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -535,9 +535,9 @@
*
* @return $this
*/
- public function setReportURI($uri)
+ public function setReportURI(string $uri)
{
- $this->reportURI = (string) $uri;
+ $this->reportURI = $uri;
return $this;
}
diff --git a/system/HTTP/DownloadResponse.php b/system/HTTP/DownloadResponse.php
index f240944..067dbcd 100644
--- a/system/HTTP/DownloadResponse.php
+++ b/system/HTTP/DownloadResponse.php
@@ -42,6 +42,9 @@
use CodeIgniter\Files\File;
use Config\Mimes;
+/**
+ * HTTP response when a download is requested.
+ */
class DownloadResponse extends Message implements ResponseInterface
{
/**
@@ -93,6 +96,12 @@
*/
private $pretend = false;
+ /**
+ * Constructor.
+ *
+ * @param string $filename
+ * @param boolean $setMime
+ */
public function __construct(string $filename, bool $setMime)
{
$this->filename = $filename;
@@ -348,6 +357,12 @@
// Output Methods
//--------------------------------------------------------------------
+ /**
+ * For unit testing, don't actually send headers.
+ *
+ * @param boolean $pretend
+ * @return $this
+ */
public function pretend(bool $pretend = true)
{
$this->pretend = $pretend;
diff --git a/system/HTTP/Exceptions/HTTPException.php b/system/HTTP/Exceptions/HTTPException.php
index 49e83f3..22448b6 100644
--- a/system/HTTP/Exceptions/HTTPException.php
+++ b/system/HTTP/Exceptions/HTTPException.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/HTTP/Files/FileCollection.php b/system/HTTP/Files/FileCollection.php
index f1b7d91..df544ad 100644
--- a/system/HTTP/Files/FileCollection.php
+++ b/system/HTTP/Files/FileCollection.php
@@ -33,7 +33,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/HTTP/Files/UploadedFile.php b/system/HTTP/Files/UploadedFile.php
index f219d28..9eafbc1 100644
--- a/system/HTTP/Files/UploadedFile.php
+++ b/system/HTTP/Files/UploadedFile.php
@@ -33,7 +33,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -41,6 +41,8 @@
use CodeIgniter\Files\File;
use CodeIgniter\HTTP\Exceptions\HTTPException;
+use Config\Mimes;
+use Exception;
/**
* Value object representing a single file uploaded through an
@@ -177,7 +179,7 @@
{
move_uploaded_file($this->path, $destination);
}
- catch (\Exception $e)
+ catch (Exception $e)
{
$error = error_get_last();
throw HTTPException::forMoveFailed(basename($this->path), $targetPath, strip_tags($error['message']));
@@ -201,7 +203,7 @@
*
* @return string The path set or created.
*/
- protected function setPath($path)
+ protected function setPath(string $path): string
{
if (! is_dir($path))
{
@@ -261,8 +263,6 @@
/**
* Get error string
*
- * @var array $errors
- *
* @return string
*/
public function getErrorString(): string
@@ -290,8 +290,7 @@
* This is NOT a trusted value.
* For a trusted version, use getMimeType() instead.
*
- * @return string|null The media type sent by the client or null if none
- * was provided.
+ * @return string The media type sent by the client or null if none was provided.
*/
public function getClientMimeType(): string
{
@@ -305,8 +304,7 @@
* by the client, and should not be trusted. If the file has been
* moved, this will return the final name of the moved file.
*
- * @return string|null The filename sent by the client or null if none
- * was provided.
+ * @return string The filename sent by the client or null if none was provided.
*/
public function getName(): string
{
@@ -353,9 +351,14 @@
return $this->guessExtension();
}
+ /**
+ * Attempts to determine the best file extension.
+ *
+ * @return string|null
+ */
public function guessExtension(): ?string
{
- return \Config\Mimes::guessExtensionFromType($this->getClientMimeType(), $this->getClientExtension());
+ return Mimes::guessExtensionFromType($this->getClientMimeType(), $this->getClientExtension());
}
//--------------------------------------------------------------------
@@ -365,7 +368,7 @@
* was uploaded. This is NOT a trusted source.
* For a trusted version, use guessExtension() instead.
*
- * @return string|null
+ * @return string
*/
public function getClientExtension(): string
{
diff --git a/system/HTTP/Files/UploadedFileInterface.php b/system/HTTP/Files/UploadedFileInterface.php
index 76c0069..d98696b 100644
--- a/system/HTTP/Files/UploadedFileInterface.php
+++ b/system/HTTP/Files/UploadedFileInterface.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/HTTP/Header.php b/system/HTTP/Header.php
index e0d1b5d..2f44c04 100644
--- a/system/HTTP/Header.php
+++ b/system/HTTP/Header.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -83,7 +83,7 @@
*
* @return string
*/
- public function getName()
+ public function getName(): string
{
return $this->name;
}
diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php
index 5d5a235..9b0cd82 100755
--- a/system/HTTP/IncomingRequest.php
+++ b/system/HTTP/IncomingRequest.php
@@ -33,7 +33,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -127,6 +127,8 @@
protected $validLocales = [];
/**
+ * Configuration settings.
+ *
* @var \Config\App
*/
public $config;
@@ -139,6 +141,8 @@
protected $oldInput = [];
/**
+ * The user agent this request is from.
+ *
* @var \CodeIgniter\HTTP\UserAgent
*/
protected $userAgent;
@@ -149,11 +153,11 @@
* Constructor
*
* @param object $config
- * @param URI $uri
- * @param string $body
+ * @param \CodeIgniter\HTTP\URI $uri
+ * @param string|null $body
* @param \CodeIgniter\HTTP\UserAgent $userAgent
*/
- public function __construct($config, $uri = null, $body = 'php://input', UserAgent $userAgent)
+ public function __construct($config, URI $uri = null, $body = 'php://input', UserAgent $userAgent)
{
// Get our body from php://input
if ($body === 'php://input')
@@ -321,9 +325,9 @@
* to grab data from the request object and can be used in lieu of the
* other get* methods in most cases.
*
- * @param null $index
- * @param null $filter
- * @param null $flags
+ * @param string|array|null $index
+ * @param integer|null $filter Filter constant
+ * @param mixed $flags
*
* @return mixed
*/
@@ -531,7 +535,7 @@
*
* @return array
*/
- public function getFiles()
+ public function getFiles(): array
{
if (is_null($this->files))
{
diff --git a/system/HTTP/Message.php b/system/HTTP/Message.php
index 7114750..05071f0 100644
--- a/system/HTTP/Message.php
+++ b/system/HTTP/Message.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -197,7 +197,7 @@
*
* @return array|\CodeIgniter\HTTP\Header
*/
- public function getHeader($name)
+ public function getHeader(string $name)
{
$orig_name = $this->getHeaderName($name);
@@ -214,11 +214,11 @@
/**
* Determines whether a header exists.
*
- * @param $name
+ * @param string $name
*
* @return boolean
*/
- public function hasHeader($name): bool
+ public function hasHeader(string $name): bool
{
$orig_name = $this->getHeaderName($name);
@@ -318,7 +318,7 @@
*
* @return Message
*/
- public function appendHeader(string $name, $value)
+ public function appendHeader(string $name, string $value)
{
$orig_name = $this->getHeaderName($name);
@@ -338,7 +338,7 @@
*
* @return Message
*/
- public function prependHeader(string $name, $value)
+ public function prependHeader(string $name, string $value)
{
$orig_name = $this->getHeaderName($name);
@@ -395,7 +395,7 @@
*
* @return string
*/
- protected function getHeaderName($name): string
+ protected function getHeaderName(string $name): string
{
$lower_name = strtolower($name);
diff --git a/system/HTTP/Negotiate.php b/system/HTTP/Negotiate.php
index e864fb8..dbad9df 100644
--- a/system/HTTP/Negotiate.php
+++ b/system/HTTP/Negotiate.php
@@ -33,7 +33,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -68,7 +68,7 @@
*
* @param \CodeIgniter\HTTP\RequestInterface $request
*/
- public function __construct(\CodeIgniter\HTTP\RequestInterface $request = null)
+ public function __construct(RequestInterface $request = null)
{
if (! is_null($request))
{
@@ -85,7 +85,7 @@
*
* @return $this
*/
- public function setRequest(\CodeIgniter\HTTP\RequestInterface $request)
+ public function setRequest(RequestInterface $request)
{
$this->request = $request;
@@ -253,7 +253,7 @@
*
* @return array
*/
- public function parseHeader(string $header)
+ public function parseHeader(string $header): array
{
$results = [];
$acceptable = explode(',', $header);
@@ -341,7 +341,7 @@
* @param boolean $enforceTypes
* @return boolean
*/
- protected function match(array $acceptable, string $supported, bool $enforceTypes = false)
+ protected function match(array $acceptable, string $supported, bool $enforceTypes = false): bool
{
$supported = $this->parseHeader($supported);
if (is_array($supported) && count($supported) === 1)
diff --git a/system/HTTP/RedirectResponse.php b/system/HTTP/RedirectResponse.php
index 83f795a..ad9f70b 100644
--- a/system/HTTP/RedirectResponse.php
+++ b/system/HTTP/RedirectResponse.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/HTTP/Request.php b/system/HTTP/Request.php
index 3f87727..6940504 100644
--- a/system/HTTP/Request.php
+++ b/system/HTTP/Request.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -256,7 +256,7 @@
*
* @return string
*/
- public function getMethod($upper = false): string
+ public function getMethod(bool $upper = false): string
{
return ($upper) ? strtoupper($this->method) : strtolower($this->method);
}
diff --git a/system/HTTP/RequestInterface.php b/system/HTTP/RequestInterface.php
index bb507ab..e28fa67 100644
--- a/system/HTTP/RequestInterface.php
+++ b/system/HTTP/RequestInterface.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -76,7 +76,7 @@
*
* @return string
*/
- public function getMethod($upper = false): string;
+ public function getMethod(bool $upper = false): string;
//--------------------------------------------------------------------
diff --git a/system/HTTP/Response.php b/system/HTTP/Response.php
index 0632998..a9b21c5 100644
--- a/system/HTTP/Response.php
+++ b/system/HTTP/Response.php
@@ -33,7 +33,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -904,7 +904,7 @@
*
* @return boolean
*/
- public function hasCookie(string $name, $value = null, string $prefix = '')
+ public function hasCookie(string $name, string $value = null, string $prefix = ''): bool
{
if ($prefix === '' && $this->cookiePrefix !== '')
{
@@ -967,14 +967,14 @@
/**
* Sets a cookie to be deleted when the response is sent.
*
- * @param $name
+ * @param string $name
* @param string $domain
* @param string $path
* @param string $prefix
*
* @return $this
*/
- public function deleteCookie($name = '', string $domain = '', string $path = '/', string $prefix = '')
+ public function deleteCookie(string $name = '', string $domain = '', string $path = '/', string $prefix = '')
{
if (empty($name))
{
@@ -1035,9 +1035,9 @@
* Generates the headers that force a download to happen. And
* sends the file to the browser.
*
- * @param string $filename The path to the file to send
- * @param string $data The data to be downloaded
- * @param boolean $setMime Whether to try and send the actual MIME type
+ * @param string $filename The path to the file to send
+ * @param string|null $data The data to be downloaded
+ * @param boolean $setMime Whether to try and send the actual MIME type
*
* @return \CodeIgniter\HTTP\DownloadResponse|null
*/
diff --git a/system/HTTP/ResponseInterface.php b/system/HTTP/ResponseInterface.php
index 153ef66..28370a1 100644
--- a/system/HTTP/ResponseInterface.php
+++ b/system/HTTP/ResponseInterface.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php
index e1ab897..72f7722 100644
--- a/system/HTTP/URI.php
+++ b/system/HTTP/URI.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -79,49 +79,49 @@
/**
* The URI Scheme.
*
- * @var
+ * @var string
*/
protected $scheme = 'http';
/**
* URI User Info
*
- * @var
+ * @var string
*/
protected $user;
/**
* URI User Password
*
- * @var
+ * @var string
*/
protected $password;
/**
* URI Host
*
- * @var
+ * @var string
*/
protected $host;
/**
* URI Port
*
- * @var
+ * @var integer
*/
protected $port;
/**
* URI path.
*
- * @var
+ * @var string
*/
protected $path;
/**
* The name of any fragment.
*
- * @var
+ * @var string
*/
protected $fragment = '';
@@ -288,7 +288,7 @@
* The trailing "@" character is not part of the user information and MUST
* NOT be added.
*
- * @return string The URI user information, in "username[:password]" format.
+ * @return string|null The URI user information, in "username[:password]" format.
*/
public function getUserInfo()
{
@@ -531,7 +531,7 @@
* Allow the URI to be output as a string by simply casting it to a string
* or echoing out.
*/
- public function __toString()
+ public function __toString(): string
{
return static::createURIString(
$this->getScheme(), $this->getAuthority(), $this->getPath(), // Absolute URIs should use a "/" for an empty path
@@ -783,7 +783,7 @@
*
* @return string
*/
- protected function decode(string $value)
+ protected function decode(string $value): string
{
if (empty($value))
{
@@ -843,7 +843,7 @@
* Adds a single new element to the query vars.
*
* @param string $key
- * @param null $value
+ * @param mixed $value
*
* @return $this
*/
@@ -929,9 +929,9 @@
*
* @param $path
*
- * @return mixed|string
+ * @return string
*/
- protected function filterPath(string $path = null)
+ protected function filterPath(string $path = null): string
{
$orig = $path;
diff --git a/system/HTTP/UserAgent.php b/system/HTTP/UserAgent.php
index 6bd2309..8674a22 100644
--- a/system/HTTP/UserAgent.php
+++ b/system/HTTP/UserAgent.php
@@ -32,13 +32,12 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
namespace CodeIgniter\HTTP;
-use CodeIgniter\Database\BasePreparedQuery;
use Config\UserAgents;
/**
diff --git a/system/Helpers/array_helper.php b/system/Helpers/array_helper.php
index 5215173..b43ab4b 100644
--- a/system/Helpers/array_helper.php
+++ b/system/Helpers/array_helper.php
@@ -31,18 +31,14 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
/**
* CodeIgniter Array Helpers
*
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author CodeIgniter Dev Team
- * @link https://codeigniter.com/user_guide/helpers/cookie_helper.html
+ * @package CodeIgniter
*/
if (! function_exists('dot_array_search'))
diff --git a/system/Helpers/cookie_helper.php b/system/Helpers/cookie_helper.php
index 0be9f30..5e80918 100755
--- a/system/Helpers/cookie_helper.php
+++ b/system/Helpers/cookie_helper.php
@@ -31,7 +31,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -40,11 +40,7 @@
/**
* CodeIgniter Cookie Helpers
*
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author CodeIgniter Dev Team
- * @link https://codeigniter.com/user_guide/helpers/cookie_helper.html
+ * @package CodeIgniter
*/
if (! function_exists('set_cookie'))
{
diff --git a/system/Helpers/date_helper.php b/system/Helpers/date_helper.php
index 1d42b18..451657a 100644
--- a/system/Helpers/date_helper.php
+++ b/system/Helpers/date_helper.php
@@ -31,18 +31,14 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
/**
* CodeIgniter Date Helpers
*
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author CodeIgniter Dev Team
- * @link https://codeigniter.com/user_guide/helpers/cookie_helper.html
+ * @package CodeIgniter
*/
if (! function_exists('now'))
@@ -56,6 +52,7 @@
* @param string $timezone
*
* @return integer
+ * @throws \Exception
*/
function now(string $timezone = null): int
{
diff --git a/system/Helpers/filesystem_helper.php b/system/Helpers/filesystem_helper.php
index a2dae09..3d34c79 100644
--- a/system/Helpers/filesystem_helper.php
+++ b/system/Helpers/filesystem_helper.php
@@ -38,13 +38,9 @@
*/
/**
- * CodeIgniter Directory Helpers
+ * CodeIgniter File System Helpers
*
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author CodeIgniter Dev Team
- * @link https://codeigniter.com/user_guide/helpers/directory_helper.html
+ * @package CodeIgniter
*/
// ------------------------------------------------------------------------
@@ -59,7 +55,7 @@
*
* @param string $source_dir Path to source
* @param integer $directory_depth Depth of directories to traverse
- * (0 = fully recursive, 1 = current dir, etc)
+ * (0 = fully recursive, 1 = current dir, etc)
* @param boolean $hidden Whether to show hidden files
*
* @return array
@@ -70,7 +66,7 @@
{
$fp = opendir($source_dir);
- $filedata = [];
+ $fileData = [];
$new_depth = $directory_depth - 1;
$source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
@@ -86,16 +82,16 @@
if (($directory_depth < 1 || $new_depth > 0) && is_dir($source_dir . $file))
{
- $filedata[$file] = directory_map($source_dir . $file, $new_depth, $hidden);
+ $fileData[$file] = directory_map($source_dir . $file, $new_depth, $hidden);
}
else
{
- $filedata[] = $file;
+ $fileData[] = $file;
}
}
closedir($fp);
- return $filedata;
+ return $fileData;
}
catch (\Exception $fe)
{
@@ -160,14 +156,14 @@
* If the second parameter is set to true, any directories contained
* within the supplied base directory will be nuked as well.
*
- * @param string $path File path
- * @param boolean $delDir Whether to delete any directories found in the path
- * @param boolean $htdocs Whether to skip deleting .htaccess and index page files
- * @param integer $_level Current directory depth level (default: 0; internal use only)
+ * @param string $path File path
+ * @param boolean $del_dir Whether to delete any directories found in the path
+ * @param boolean $htdocs Whether to skip deleting .htaccess and index page files
+ * @param integer $_level Current directory depth level (default: 0; internal use only)
*
* @return boolean
*/
- function delete_files(string $path, bool $delDir = false, bool $htdocs = false, int $_level = 0): bool
+ function delete_files(string $path, bool $del_dir = false, bool $htdocs = false, int $_level = 0): bool
{
// Trim the trailing slash
$path = rtrim($path, '/\\');
@@ -182,7 +178,7 @@
{
if (is_dir($path . DIRECTORY_SEPARATOR . $filename) && $filename[0] !== '.')
{
- delete_files($path . DIRECTORY_SEPARATOR . $filename, $delDir, $htdocs, $_level + 1);
+ delete_files($path . DIRECTORY_SEPARATOR . $filename, $del_dir, $htdocs, $_level + 1);
}
elseif ($htdocs !== true || ! preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename))
{
@@ -193,7 +189,7 @@
closedir($current_dir);
- return ($delDir === true && $_level > 0) ? @rmdir($path) : true;
+ return ($del_dir === true && $_level > 0) ? @rmdir($path) : true;
}
catch (\Exception $fe)
{
@@ -220,7 +216,7 @@
*/
function get_filenames(string $source_dir, bool $include_path = false, bool $recursion = false): array
{
- static $filedata = [];
+ static $fileData = [];
try
{
@@ -228,7 +224,7 @@
// reset the array and make sure $source_dir has a trailing slash on the initial call
if ($recursion === false)
{
- $filedata = [];
+ $fileData = [];
$source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}
@@ -240,12 +236,12 @@
}
elseif ($file[0] !== '.')
{
- $filedata[] = ($include_path === true) ? $source_dir . $file : $file;
+ $fileData[] = ($include_path === true) ? $source_dir . $file : $file;
}
}
closedir($fp);
- return $filedata;
+ return $fileData;
}
catch (\Exception $fe)
{
@@ -274,7 +270,7 @@
*/
function get_dir_file_info(string $source_dir, bool $top_level_only = true, bool $recursion = false): array
{
- static $filedata = [];
+ static $fileData = [];
$relative_path = $source_dir;
try
@@ -283,7 +279,7 @@
// reset the array and make sure $source_dir has a trailing slash on the initial call
if ($recursion === false)
{
- $filedata = [];
+ $fileData = [];
$source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}
@@ -296,13 +292,13 @@
}
elseif ($file[0] !== '.')
{
- $filedata[$file] = get_file_info($source_dir . $file);
- $filedata[$file]['relative_path'] = $relative_path;
+ $fileData[$file] = get_file_info($source_dir . $file);
+ $fileData[$file]['relative_path'] = $relative_path;
}
}
closedir($fp);
- return $filedata;
+ return $fileData;
}
}
catch (\Exception $fe)
@@ -345,33 +341,33 @@
{
switch ($key) {
case 'name':
- $fileinfo['name'] = basename($file);
+ $fileInfo['name'] = basename($file);
break;
case 'server_path':
- $fileinfo['server_path'] = $file;
+ $fileInfo['server_path'] = $file;
break;
case 'size':
- $fileinfo['size'] = filesize($file);
+ $fileInfo['size'] = filesize($file);
break;
case 'date':
- $fileinfo['date'] = filemtime($file);
+ $fileInfo['date'] = filemtime($file);
break;
case 'readable':
- $fileinfo['readable'] = is_readable($file);
+ $fileInfo['readable'] = is_readable($file);
break;
case 'writable':
- $fileinfo['writable'] = is_really_writable($file);
+ $fileInfo['writable'] = is_really_writable($file);
break;
case 'executable':
- $fileinfo['executable'] = is_executable($file);
+ $fileInfo['executable'] = is_executable($file);
break;
case 'fileperms':
- $fileinfo['fileperms'] = fileperms($file);
+ $fileInfo['fileperms'] = fileperms($file);
break;
}
}
- return $fileinfo;
+ return $fileInfo;
}
}
@@ -469,11 +465,11 @@
* Set Realpath
*
* @param string $path
- * @param boolean $checkExistance Checks to see if the path exists
+ * @param boolean $check_existence Checks to see if the path exists
*
* @return string
*/
- function set_realpath(string $path, bool $checkExistance = false): string
+ function set_realpath(string $path, bool $check_existence = false): string
{
// Security check to make sure the path is NOT a URL. No remote file inclusion!
if (preg_match('#^(http:\/\/|https:\/\/|www\.|ftp)#i', $path) || filter_var($path, FILTER_VALIDATE_IP) === $path)
@@ -486,7 +482,7 @@
{
$path = realpath($path);
}
- elseif ($checkExistance && ! is_dir($path) && ! is_file($path))
+ elseif ($check_existence && ! is_dir($path) && ! is_file($path))
{
throw new InvalidArgumentException('Not a valid path: ' . $path);
}
diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php
index ad051bd..ccc2b24 100644
--- a/system/Helpers/form_helper.php
+++ b/system/Helpers/form_helper.php
@@ -32,7 +32,7 @@
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
- * @since Version 3.0.0
+ * @since Version 4.0.0
* @filesource
*/
@@ -41,11 +41,7 @@
/**
* CodeIgniter Form Helpers
*
- * @package CodeIgniter
- * @subpackage Helpers
- * @category Helpers
- * @author CodeIgniter Dev Team
- * @link https://codeigniter.com/user_guide/helpers/cookie_helper.html
+ * @package CodeIgniter
*/
//--------------------------------------------------------------------
@@ -96,7 +92,8 @@
$form = '