Merge branch 'develop' of github.com:bcit-ci/CodeIgniter4 into develop

This commit is contained in:
Lonnie Ezell 2017-08-08 12:35:09 -05:00
commit a41692efdd
51 changed files with 250 additions and 246 deletions

View File

@ -54,38 +54,38 @@ class Checks extends Controller
public function api()
{
$data = array(
$data = [
"total_users" => 3,
"users" => array(
array(
"users" => [
[
"id" => 1,
"name" => "Nitya",
"address" => array(
"address" => [
"country" => "India",
"city" => "Kolkata",
"zip" => 700102,
)
),
array(
]
],
[
"id" => 2,
"name" => "John",
"address" => array(
"address" => [
"country" => "USA",
"city" => "Newyork",
"zip" => "NY1234",
)
),
array(
]
],
[
"id" => 3,
"name" => "Viktor",
"address" => array(
"address" => [
"country" => "Australia",
"city" => "Sydney",
"zip" => 123456,
)
),
)
);
]
],
]
];
return $this->respond($data);
}

View File

@ -258,7 +258,7 @@ class FileLocator
$tempFiles = get_filenames($fullPath, true);
//CLI::newLine($tempFiles);
if (count($tempFiles))
if (! empty($tempFiles))
$files = array_merge($files, $tempFiles);
}

View File

@ -83,14 +83,14 @@ abstract class BaseCommand
*
* @var array
*/
protected $options = array();
protected $options = [];
/**
* the Command's Arguments description
*
* @var array
*/
protected $arguments = array();
protected $arguments = [];
/**
* @var \Psr\Log\LoggerInterface

View File

@ -587,7 +587,7 @@ class CLI
$first = true;
array_walk($lines, function (&$line, $index) use ($max, $pad_left, &$first) {
array_walk($lines, function (&$line, $index) use ($pad_left, &$first) {
if ( ! $first)
{
$line = str_repeat(" ", $pad_left) . $line;
@ -744,7 +744,7 @@ class CLI
*/
public static function getOptionString(): string
{
if ( ! count(static::$options))
if (empty(static::$options))
{
return '';
}

View File

@ -81,18 +81,18 @@ class CreateMigration extends BaseCommand
*
* @var array
*/
protected $arguments = array(
protected $arguments = [
'migration_name' => 'The migration file name'
);
];
/**
* the Command's Options
*
* @var array
*/
protected $options = array(
protected $options = [
'-n' => 'Set migration namespace'
);
];
/**
* Creates a new migration file with the current timestamp.
@ -131,6 +131,7 @@ class CreateMigration extends BaseCommand
if ($namespace == $ns)
{
$homepath = realpath($path);
break;
}
}
}

View File

@ -87,11 +87,11 @@ class MigrateRefresh extends BaseCommand
*
* @var array
*/
protected $options = array(
protected $options = [
'-n' => 'Set migration namespace',
'-g' => 'Set database group',
'-all' => 'Set latest for all namespace, will ignore (-n) option'
);
];
/**
* Does a rollback followed by a latest to refresh the current state

View File

@ -82,9 +82,9 @@ class Seed extends BaseCommand
*
* @var array
*/
protected $arguments = array(
protected $arguments = [
'seeder_name' => 'The seeder name to run'
);
];
/**
* the Command's Options

View File

@ -83,16 +83,16 @@ class Help extends BaseCommand
*
* @var array
*/
protected $arguments = array(
protected $arguments = [
'command_name' => 'The command name [default: "help"]'
);
];
/**
* the Command's Options
*
* @var array
*/
protected $options = array();
protected $options = [];
//--------------------------------------------------------------------

View File

@ -83,14 +83,14 @@ class ListCommands extends BaseCommand
*
* @var array
*/
protected $arguments = array();
protected $arguments = [];
/**
* the Command's Options
*
* @var array
*/
protected $options = array();
protected $options = [];
/**
* The length of the longest command name.
@ -134,8 +134,8 @@ class ListCommands extends BaseCommand
// Pad each item to the same length
$names = $this->padArray($names, 2, 2);
for ($i = 0; $i < count($names); $i ++ )
$countNames = count($names);
for ($i = 0; $i < $countNames; $i ++ )
{
$lastGroup = $this->describeGroup($groups[$i], $lastGroup);

View File

@ -76,18 +76,18 @@ class CreateMigration extends BaseCommand
*
* @var array
*/
protected $arguments = array();
protected $arguments = [];
/**
* the Command's Options
*
* @var array
*/
protected $options = array(
protected $options = [
'-n' => 'Set migration namespace',
'-g' => 'Set database group',
'-t' => 'Set table name',
);
];
/**
* Creates a new migration file with the current timestamp.

View File

@ -777,7 +777,7 @@ if ( ! function_exists('redirect_with_input'))
// so they can be displayed when the validation is
// handled within a method different than displaying the form.
$validator = Services::validation();
if (count($validator->getErrors()) > 0)
if (! empty($validator->getErrors()))
{
$session->setFlashdata('_ci_validation_errors', serialize($validator->getErrors()));
}
@ -860,7 +860,7 @@ if ( ! function_exists('is_really_writable'))
*/
if (is_dir($file))
{
$file = rtrim($file, '/') . '/' . md5(mt_rand());
$file = rtrim($file, '/') . '/' . bin2hex(random_bytes(16));
if (($fp = @fopen($file, 'ab')) === false)
{
return false;
@ -949,7 +949,7 @@ if ( ! function_exists('function_usable'))
{
if ( ! isset($_suhosin_func_blacklist))
{
$_suhosin_func_blacklist = extension_loaded('suhosin') ? explode(',', trim(ini_get('suhosin.executor.func.blacklist'))) : array();
$_suhosin_func_blacklist = extension_loaded('suhosin') ? explode(',', trim(ini_get('suhosin.executor.func.blacklist'))) : [];
}
return ! in_array($function_name, $_suhosin_func_blacklist, TRUE);

View File

@ -216,7 +216,7 @@ class BaseBuilder
$this->from($tableName);
if (count($options))
if (! empty($options))
{
foreach ($options as $key => $value)
{
@ -628,7 +628,7 @@ class BaseBuilder
foreach ($key as $k => $v)
{
$prefix = (count($this->$qb_key) === 0) ? $this->groupGetType('') : $this->groupGetType($type);
$prefix = empty($this->$qb_key) ? $this->groupGetType('') : $this->groupGetType($type);
if ($v !== null)
{
@ -784,7 +784,7 @@ class BaseBuilder
$where_in = array_values($values);
$this->binds[$ok] = $where_in;
$prefix = (count($this->QBWhere) === 0) ? $this->groupGetType('') : $this->groupGetType($type);
$prefix = empty($this->QBWhere) ? $this->groupGetType('') : $this->groupGetType($type);
$where_in = [
'condition' => $prefix . $key . $not . ' IN :' . $ok,
@ -914,7 +914,7 @@ class BaseBuilder
foreach ($field as $k => $v)
{
$prefix = (count($this->QBWhere) === 0) ? $this->groupGetType('') : $this->groupGetType($type);
$prefix = empty($this->QBWhere) ? $this->groupGetType('') : $this->groupGetType($type);
if ($insensitiveSearch === true)
{
@ -992,7 +992,7 @@ class BaseBuilder
$type = $this->groupGetType($type);
$this->QBWhereGroupStarted = true;
$prefix = count($this->QBWhere) === 0 ? '' : $type;
$prefix = empty($this->QBWhere) ? '' : $type;
$where = [
'condition' => $prefix . $not . str_repeat(' ', ++ $this->QBWhereGroupCount) . ' (',
'escape' => false,
@ -1385,7 +1385,7 @@ class BaseBuilder
}
$query = $this->db->query($sql);
if (count($query->getResult()) === 0)
if (empty($query->getResult()))
{
return 0;
}
@ -1715,7 +1715,7 @@ class BaseBuilder
*/
protected function validateInsert()
{
if (count($this->QBSet) === 0)
if (empty($this->QBSet))
{
if (CI_DEBUG)
{
@ -1766,7 +1766,7 @@ class BaseBuilder
$this->set($set);
}
if (count($this->QBSet) === 0)
if (empty($this->QBSet))
{
if (CI_DEBUG)
{
@ -1936,7 +1936,7 @@ class BaseBuilder
*/
protected function validateUpdate()
{
if (count($this->QBSet) === 0)
if (empty($this->QBSet))
{
if (CI_DEBUG)
{
@ -2241,7 +2241,7 @@ class BaseBuilder
$this->where($where);
}
if (count($this->QBWhere) === 0)
if (empty($this->QBWhere))
{
if (CI_DEBUG)
{
@ -2396,7 +2396,7 @@ class BaseBuilder
{
$sql = ( ! $this->QBDistinct) ? 'SELECT ' : 'SELECT DISTINCT ';
if (count($this->QBSelect) === 0)
if (empty($this->QBSelect))
{
$sql .= '*';
}
@ -2416,13 +2416,13 @@ class BaseBuilder
}
// Write the "FROM" portion of the query
if (count($this->QBFrom) > 0)
if (! empty($this->QBFrom))
{
$sql .= "\nFROM " . $this->_fromTables();
}
// Write the "JOIN" portion of the query
if (count($this->QBJoin) > 0)
if (! empty($this->QBJoin))
{
$sql .= "\n" . implode("\n", $this->QBJoin);
}
@ -2457,7 +2457,7 @@ class BaseBuilder
*/
protected function compileWhereHaving($qb_key)
{
if (count($this->$qb_key) > 0)
if (! empty($this->$qb_key))
{
for ($i = 0, $c = count($this->$qb_key); $i < $c; $i ++ )
{
@ -2530,7 +2530,7 @@ class BaseBuilder
*/
protected function compileGroupBy()
{
if (count($this->QBGroupBy) > 0)
if (! empty($this->QBGroupBy))
{
for ($i = 0, $c = count($this->QBGroupBy); $i < $c; $i ++ )
{
@ -2565,7 +2565,7 @@ class BaseBuilder
*/
protected function compileOrderBy()
{
if (is_array($this->QBOrderBy) && count($this->QBOrderBy) > 0)
if (is_array($this->QBOrderBy) && ! empty($this->QBOrderBy))
{
for ($i = 0, $c = count($this->QBOrderBy); $i < $c; $i ++ )
{

View File

@ -1466,7 +1466,7 @@ abstract class BaseConnection implements ConnectionInterface
return false;
}
$this->dataCache['table_names'] = array();
$this->dataCache['table_names'] = [];
$query = $this->query($sql);
foreach ($query->getResultArray() as $row)
@ -1546,7 +1546,7 @@ abstract class BaseConnection implements ConnectionInterface
}
$query = $this->query($sql);
$this->dataCache['field_names'][$table] = array();
$this->dataCache['field_names'][$table] = [];
foreach ($query->getResultArray() as $row)
{

View File

@ -205,7 +205,7 @@ abstract class BaseResult implements ResultInterface
*/
public function getResultArray(): array
{
if (count($this->resultArray) > 0)
if (! empty($this->resultArray))
{
return $this->resultArray;
}
@ -248,7 +248,7 @@ abstract class BaseResult implements ResultInterface
*/
public function getResultObject(): array
{
if (count($this->resultObject) > 0)
if (! empty($this->resultObject))
{
return $this->resultObject;
}
@ -339,7 +339,7 @@ abstract class BaseResult implements ResultInterface
{
isset($this->customResultObject[$className]) OR $this->customResultObject($className);
if (count($this->customResultObject[$className]) === 0)
if (empty($this->customResultObject[$className]))
{
return null;
}
@ -366,7 +366,7 @@ abstract class BaseResult implements ResultInterface
public function getRowArray($n = 0)
{
$result = $this->getResultArray();
if (count($result) === 0)
if (empty($result))
{
return null;
}
@ -393,7 +393,7 @@ abstract class BaseResult implements ResultInterface
public function getRowObject($n = 0)
{
$result = $this->getResultObject();
if (count($result) === 0)
if (empty($result))
{
return null;
}
@ -453,7 +453,7 @@ abstract class BaseResult implements ResultInterface
{
$result = $this->getResult($type);
return (count($result) === 0) ? null : $result[0];
return (empty($result)) ? null : $result[0];
}
//--------------------------------------------------------------------
@ -469,7 +469,7 @@ abstract class BaseResult implements ResultInterface
{
$result = $this->getResult($type);
return (count($result) === 0) ? null : $result[count($result) - 1];
return (empty($result)) ? null : $result[count($result) - 1];
}
//--------------------------------------------------------------------
@ -484,7 +484,7 @@ abstract class BaseResult implements ResultInterface
public function getNextRow($type = 'object')
{
$result = $this->getResult($type);
if (count($result) === 0)
if (empty($result))
{
return null;
}
@ -504,7 +504,7 @@ abstract class BaseResult implements ResultInterface
public function getPreviousRow($type = 'object')
{
$result = $this->getResult($type);
if (count($result) === 0)
if (empty($result))
{
return null;
}

View File

@ -109,7 +109,7 @@ abstract class BaseUtils
return false;
}
$this->db->dataCache['db_names'] = array();
$this->db->dataCache['db_names'] = [];
$query = $this->db->query($this->listDatabases);
if ($query === FALSE)
@ -187,7 +187,7 @@ abstract class BaseUtils
return false;
}
$result = array();
$result = [];
foreach ($this->db->listTables() as $table_name)
{
$res = $this->db->query(sprintf($this->optimizeTable, $this->db->escapeIdentifiers($table_name)));
@ -265,7 +265,7 @@ abstract class BaseUtils
// Next blast through the result array and build out the rows
while ($row = $query->getUnbufferedRow('array'))
{
$line = array();
$line = [];
foreach ($row as $item)
{
$line[] = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $item) . $enclosure;
@ -286,10 +286,10 @@ abstract class BaseUtils
*
* @return string
*/
public function getXMLFromResult(ResultInterface $query, $params = array())
public function getXMLFromResult(ResultInterface $query, $params = [])
{
// Set our default values
foreach (array('root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t") as $key => $val)
foreach (['root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t"] as $key => $val)
{
if ( ! isset($params[$key]))
{
@ -326,30 +326,30 @@ abstract class BaseUtils
* @return mixed
* @throws \CodeIgniter\DatabaseException
*/
public function backup($params = array())
public function backup($params = [])
{
// If the parameters have not been submitted as an
// array then we know that it is simply the table
// name, which is a valid short cut.
if (is_string($params))
{
$params = array('tables' => $params);
$params = ['tables' => $params];
}
// Set up our default preferences
$prefs = array(
'tables' => array(),
'ignore' => array(),
$prefs = [
'tables' => [],
'ignore' => [],
'filename' => '',
'format' => 'gzip', // gzip, zip, txt
'add_drop' => TRUE,
'add_insert' => TRUE,
'newline' => "\n",
'foreign_key_checks' => TRUE
);
];
// Did the user submit any preferences? If so set them....
if (count($params) > 0)
if (! empty($params))
{
foreach ($prefs as $key => $val)
{
@ -362,13 +362,13 @@ abstract class BaseUtils
// Are we backing up a complete database or individual tables?
// If no table names were submitted we'll fetch the entire table list
if (count($prefs['tables']) === 0)
if (empty($prefs['tables']))
{
$prefs['tables'] = $this->db->listTables();
}
// Validate the format
if ( ! in_array($prefs['format'], array('gzip', 'zip', 'txt'), TRUE))
if ( ! in_array($prefs['format'], ['gzip', 'zip', 'txt'], TRUE))
{
$prefs['format'] = 'txt';
}

View File

@ -405,7 +405,7 @@ class Connection extends BaseConnection implements ConnectionInterface
}
$query = $query->getResultObject();
$retval = array();
$retval = [];
for ($i = 0, $c = count($query); $i < $c; $i ++ )
{
$retval[$i] = new \stdClass();
@ -441,7 +441,7 @@ class Connection extends BaseConnection implements ConnectionInterface
return FALSE;
}
$retval = array();
$retval = [];
foreach (explode("\n", $row['Create Table']) as $line)
{
$line = trim($line);
@ -493,13 +493,13 @@ class Connection extends BaseConnection implements ConnectionInterface
{
if ( ! empty($this->mysqli->connect_errno))
{
return array(
return [
'code' => $this->mysqli->connect_errno,
'message' => $this->_mysqli->connect_error
);
];
}
return array('code' => $this->connID->errno, 'message' => $this->connID->error);
return ['code' => $this->connID->errno, 'message' => $this->connID->error];
}
//--------------------------------------------------------------------

View File

@ -158,7 +158,7 @@ class Forge extends \CodeIgniter\Database\Forge
}
}
return array($sql . implode(',', $field));
return [$sql . implode(',', $field)];
}
//--------------------------------------------------------------------
@ -221,13 +221,13 @@ class Forge extends \CodeIgniter\Database\Forge
continue;
}
is_array($this->keys[$i]) OR $this->keys[$i] = array($this->keys[$i]);
is_array($this->keys[$i]) OR $this->keys[$i] = [$this->keys[$i]];
$sql .= ",\n\tKEY " . $this->db->escapeIdentifiers(implode('_', $this->keys[$i]))
. ' (' . implode(', ', $this->db->escapeIdentifiers($this->keys[$i])) . ')';
}
$this->keys = array();
$this->keys = [];
return $sql;
}

View File

@ -116,7 +116,7 @@
</a>
<?php if (isset($_SESSION)) : ?>
<?php if (count($_SESSION)) : ?>
<?php if (! empty($_SESSION)) : ?>
<table id="session_table">
<tbody>
<?php foreach ($_SESSION as $key => $value) : ?>

View File

@ -507,7 +507,7 @@ class ContentSecurityPolicy
*/
public function setSandbox(bool $value = true, array $flags = null)
{
if (empty($this->sandbox) && ! count($flags))
if (empty($this->sandbox) && empty($flags))
{
$this->sandbox = $value;
}
@ -704,7 +704,7 @@ class ContentSecurityPolicy
// Compile our own header strings here since if we just
// append it to the response, it will be joined with
// commas, not semi-colons as we need.
if (count($this->tempHeaders))
if (! empty($this->tempHeaders))
{
$header = '';
foreach ($this->tempHeaders as $name => $value)
@ -714,7 +714,7 @@ class ContentSecurityPolicy
$response->appendHeader('Content-Security-Policy', $header);
}
if (count($this->reportOnlyHeaders))
if (! empty($this->reportOnlyHeaders))
{
$header = '';
foreach ($this->reportOnlyHeaders as $name => $value)
@ -782,12 +782,12 @@ class ContentSecurityPolicy
}
}
if (count($sources))
if (! empty($sources))
{
$this->tempHeaders[$name] = implode(' ', $sources);
}
if (count($reportSources))
if (! empty($reportSources))
{
$this->reportOnlyHeaders[$name] = implode(' ', $reportSources);
}

View File

@ -284,7 +284,7 @@ class FileCollection
*/
protected function getValueDotNotationSyntax($index, $value)
{
if (is_array($index) && count($index)
if (is_array($index) && ! empty($index)
)
{
$current_index = array_shift($index);

View File

@ -268,11 +268,11 @@ class Negotiate
unset($pairs[0]);
$parameters = array();
$parameters = [];
foreach ($pairs as $pair)
{
$param = array();
$param = [];
preg_match(
'/^(?P<name>.+?)=(?P<quoted>"|\')?(?P<value>.*?)(?:\k<quoted>)?$/', $pair, $param
);

View File

@ -102,7 +102,7 @@ class Request extends Message implements RequestInterface
if ($proxy_ips)
{
foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP') as $header)
foreach (['HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP'] as $header)
{
if (($spoof = $this->getServer($header)) !== NULL)
{

View File

@ -69,7 +69,7 @@ if ( ! function_exists('directory_map'))
{
if ($fp = @opendir($source_dir))
{
$filedata = array();
$filedata = [];
$new_depth = $directory_depth - 1;
$source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
@ -215,14 +215,14 @@ if ( ! function_exists('get_filenames'))
*/
function get_filenames(string $source_dir, bool $include_path = false, bool $recursion = false): array
{
static $filedata = array();
static $filedata = [];
if ($fp = @opendir($source_dir))
{
// reset the array and make sure $source_dir has a trailing slash on the initial call
if ($recursion === false)
{
$filedata = array();
$filedata = [];
$source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}
@ -268,7 +268,7 @@ if ( ! function_exists('get_dir_file_info'))
*/
function get_dir_file_info(string $source_dir, bool $top_level_only = true, bool $recursion = false): array
{
static $filedata = array();
static $filedata = [];
$relative_path = $source_dir;
if ($fp = @opendir($source_dir))
@ -276,7 +276,7 @@ if ( ! function_exists('get_dir_file_info'))
// reset the array and make sure $source_dir has a trailing slash on the initial call
if ($recursion === false)
{
$filedata = array();
$filedata = [];
$source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}

View File

@ -962,7 +962,7 @@ if ( ! function_exists('parse_form_attributes'))
unset($attributes[$key]);
}
}
if (count($attributes) > 0)
if (! empty($attributes))
{
$default = array_merge($default, $attributes);
}
@ -988,4 +988,3 @@ if ( ! function_exists('parse_form_attributes'))
//--------------------------------------------------------------------
}

View File

@ -66,10 +66,10 @@ if ( ! function_exists('strip_image_tags'))
function strip_image_tags(string $str)
{
return preg_replace(
array(
[
'#<img[\s/]+.*?src\s*=\s*(["\'])([^\\1]+?)\\1.*?\>#i',
'#<img[\s/]+.*?src\s*=\s*?(([^\s"\'=<>`]+)).*?\>#i'
), '\\2', $str
], '\\2', $str
);
}
@ -88,7 +88,7 @@ if ( ! function_exists('encode_php_tags'))
*/
function encode_php_tags(string $str): string
{
return str_replace(array('<?', '?>'), array('&lt;?', '?&gt;'), $str);
return str_replace(['<?', '?>'], ['&lt;?', '?&gt;'], $str);
}
}

View File

@ -165,7 +165,7 @@ if ( ! function_exists('ascii_to_entities'))
}
else
{
if (count($temp) === 0)
if (empty($temp))
{
$count = ($ordinal < 224) ? 2 : 3;
}
@ -510,7 +510,7 @@ if ( ! function_exists('word_wrap'))
}
// Put our markers back
if (count($unwrap) > 0)
if (! empty($unwrap))
{
foreach ($unwrap as $key => $val)
{
@ -709,7 +709,7 @@ if ( ! function_exists('random_string'))
*
* Useful for generating passwords or hashes.
*
* @param string $type Type of random string. basic, alpha, alnum, numeric, nozero, unique, md5, encrypt and sha1
* @param string $type Type of random string. basic, alpha, alnum, numeric, nozero, unique, md5, sha1, and crypto
* @param int $len Number of characters
*
* @return string
@ -742,9 +742,11 @@ if ( ! function_exists('random_string'))
return substr(str_shuffle(str_repeat($pool, ceil($len / strlen($pool)))), 0, $len);
case 'md5':
return md5(uniqid(mt_rand()));
return md5(uniqid(mt_rand(), true));
case 'sha1':
return sha1(uniqid(mt_rand(), true));
case 'crypto':
return bin2hex(random_bytes($len/2));
}
}

View File

@ -310,7 +310,7 @@ if ( ! function_exists('anchor_popup'))
if ( ! is_array($attributes))
{
$attributes = array($attributes);
$attributes = [$attributes];
// Ref: http://www.w3schools.com/jsref/met_win_open.asp
$window_name = '_blank';
@ -325,7 +325,7 @@ if ( ! function_exists('anchor_popup'))
$window_name = '_blank';
}
foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'menubar' => 'no', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0') as $key => $val)
foreach (['width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'menubar' => 'no', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0'] as $key => $val)
{
$atts[$key] = isset($attributes[$key]) ? $attributes[$key] : $val;
unset($attributes[$key]);
@ -427,7 +427,7 @@ if ( ! function_exists('safe_mailto'))
$x[] = '>';
$temp = array();
$temp = [];
for ($i = 0, $l = strlen($title); $i < $l; $i ++)
{
$ordinal = ord($title[$i]);
@ -438,7 +438,7 @@ if ( ! function_exists('safe_mailto'))
}
else
{
if (count($temp) === 0)
if (empty($temp))
{
$count = ($ordinal < 224) ? 2 : 3;
}
@ -449,7 +449,7 @@ if ( ! function_exists('safe_mailto'))
$number = ($count === 3) ? (($temp[0] % 16) * 4096) + (($temp[1] % 64) * 64) + ($temp[2] % 64) : (($temp[0] % 32) * 64) + ($temp[1] % 64);
$x[] = '|' . $number;
$count = 1;
$temp = array();
$temp = [];
}
}
}
@ -597,12 +597,12 @@ if ( ! function_exists('url_title'))
{
$q_separator = preg_quote($separator, '#');
$trans = array(
$trans = [
'&.+?;' => '',
'[^\w\d _-]' => '',
'\s+' => $separator,
'(' . $q_separator . ')+' => $separator
);
];
$str = strip_tags($str);
foreach ($trans as $key => $val)

View File

@ -102,7 +102,7 @@ class Language
$output = isset($this->language[$file][$line]) ? $this->language[$file][$line] : $line;
if (count($args))
if (! empty($args))
{
$output = $this->formatMessage($output, $args);
}

View File

@ -116,7 +116,7 @@ class Security
*
* @var array
*/
public $filenameBadChars = array(
public $filenameBadChars = [
'../', '<!--', '-->', '<', '>',
"'", '"', '&', '$', '#',
'{', '}', '[', ']', '=',
@ -133,7 +133,7 @@ class Security
'%3f', // ?
'%3b', // ;
'%3d' // =
);
];
//--------------------------------------------------------------------
@ -174,7 +174,7 @@ class Security
* CSRF Verify
*
* @param RequestInterface $request
* @return $this
* @return $this|false
* @throws \LogicException
*/
public function CSRFVerify(RequestInterface $request)

View File

@ -18,7 +18,7 @@ abstract class AbstractLogger implements LoggerInterface
* @param array $context
* @return null
*/
public function emergency($message, array $context = array())
public function emergency($message, array $context = [])
{
$this->log(LogLevel::EMERGENCY, $message, $context);
}
@ -33,7 +33,7 @@ abstract class AbstractLogger implements LoggerInterface
* @param array $context
* @return null
*/
public function alert($message, array $context = array())
public function alert($message, array $context = [])
{
$this->log(LogLevel::ALERT, $message, $context);
}
@ -47,7 +47,7 @@ abstract class AbstractLogger implements LoggerInterface
* @param array $context
* @return null
*/
public function critical($message, array $context = array())
public function critical($message, array $context = [])
{
$this->log(LogLevel::CRITICAL, $message, $context);
}
@ -60,7 +60,7 @@ abstract class AbstractLogger implements LoggerInterface
* @param array $context
* @return null
*/
public function error($message, array $context = array())
public function error($message, array $context = [])
{
$this->log(LogLevel::ERROR, $message, $context);
}
@ -75,7 +75,7 @@ abstract class AbstractLogger implements LoggerInterface
* @param array $context
* @return null
*/
public function warning($message, array $context = array())
public function warning($message, array $context = [])
{
$this->log(LogLevel::WARNING, $message, $context);
}
@ -87,7 +87,7 @@ abstract class AbstractLogger implements LoggerInterface
* @param array $context
* @return null
*/
public function notice($message, array $context = array())
public function notice($message, array $context = [])
{
$this->log(LogLevel::NOTICE, $message, $context);
}
@ -101,7 +101,7 @@ abstract class AbstractLogger implements LoggerInterface
* @param array $context
* @return null
*/
public function info($message, array $context = array())
public function info($message, array $context = [])
{
$this->log(LogLevel::INFO, $message, $context);
}
@ -113,7 +113,7 @@ abstract class AbstractLogger implements LoggerInterface
* @param array $context
* @return null
*/
public function debug($message, array $context = array())
public function debug($message, array $context = [])
{
$this->log(LogLevel::DEBUG, $message, $context);
}

View File

@ -26,7 +26,7 @@ interface LoggerInterface
* @param array $context
* @return null
*/
public function emergency($message, array $context = array());
public function emergency($message, array $context = []);
/**
* Action must be taken immediately.
@ -38,7 +38,7 @@ interface LoggerInterface
* @param array $context
* @return null
*/
public function alert($message, array $context = array());
public function alert($message, array $context = []);
/**
* Critical conditions.
@ -49,7 +49,7 @@ interface LoggerInterface
* @param array $context
* @return null
*/
public function critical($message, array $context = array());
public function critical($message, array $context = []);
/**
* Runtime errors that do not require immediate action but should typically
@ -59,7 +59,7 @@ interface LoggerInterface
* @param array $context
* @return null
*/
public function error($message, array $context = array());
public function error($message, array $context = []);
/**
* Exceptional occurrences that are not errors.
@ -71,7 +71,7 @@ interface LoggerInterface
* @param array $context
* @return null
*/
public function warning($message, array $context = array());
public function warning($message, array $context = []);
/**
* Normal but significant events.
@ -80,7 +80,7 @@ interface LoggerInterface
* @param array $context
* @return null
*/
public function notice($message, array $context = array());
public function notice($message, array $context = []);
/**
* Interesting events.
@ -91,7 +91,7 @@ interface LoggerInterface
* @param array $context
* @return null
*/
public function info($message, array $context = array());
public function info($message, array $context = []);
/**
* Detailed debug information.
@ -100,7 +100,7 @@ interface LoggerInterface
* @param array $context
* @return null
*/
public function debug($message, array $context = array());
public function debug($message, array $context = []);
/**
* Logs with an arbitrary level.
@ -110,5 +110,5 @@ interface LoggerInterface
* @param array $context
* @return null
*/
public function log($level, $message, array $context = array());
public function log($level, $message, array $context = []);
}

View File

@ -19,7 +19,7 @@ trait LoggerTrait
* @param array $context
* @return null
*/
public function emergency($message, array $context = array())
public function emergency($message, array $context = [])
{
$this->log(LogLevel::EMERGENCY, $message, $context);
}
@ -34,7 +34,7 @@ trait LoggerTrait
* @param array $context
* @return null
*/
public function alert($message, array $context = array())
public function alert($message, array $context = [])
{
$this->log(LogLevel::ALERT, $message, $context);
}
@ -48,7 +48,7 @@ trait LoggerTrait
* @param array $context
* @return null
*/
public function critical($message, array $context = array())
public function critical($message, array $context = [])
{
$this->log(LogLevel::CRITICAL, $message, $context);
}
@ -61,7 +61,7 @@ trait LoggerTrait
* @param array $context
* @return null
*/
public function error($message, array $context = array())
public function error($message, array $context = [])
{
$this->log(LogLevel::ERROR, $message, $context);
}
@ -76,7 +76,7 @@ trait LoggerTrait
* @param array $context
* @return null
*/
public function warning($message, array $context = array())
public function warning($message, array $context = [])
{
$this->log(LogLevel::WARNING, $message, $context);
}
@ -88,7 +88,7 @@ trait LoggerTrait
* @param array $context
* @return null
*/
public function notice($message, array $context = array())
public function notice($message, array $context = [])
{
$this->log(LogLevel::NOTICE, $message, $context);
}
@ -102,7 +102,7 @@ trait LoggerTrait
* @param array $context
* @return null
*/
public function info($message, array $context = array())
public function info($message, array $context = [])
{
$this->log(LogLevel::INFO, $message, $context);
}
@ -114,7 +114,7 @@ trait LoggerTrait
* @param array $context
* @return null
*/
public function debug($message, array $context = array())
public function debug($message, array $context = [])
{
$this->log(LogLevel::DEBUG, $message, $context);
}
@ -127,5 +127,5 @@ trait LoggerTrait
* @param array $context
* @return null
*/
abstract public function log($level, $message, array $context = array());
abstract public function log($level, $message, array $context = []);
}

View File

@ -20,7 +20,7 @@ class NullLogger extends AbstractLogger
* @param array $context
* @return null
*/
public function log($level, $message, array $context = array())
public function log($level, $message, array $context = [])
{
// noop
}

View File

@ -274,7 +274,7 @@ class Rules
return true;
}
return is_array($str) ? (bool) count($str) : (trim($str) !== '');
return is_array($str) ? ! empty($str) : (trim($str) !== '');
}
//--------------------------------------------------------------------
@ -326,7 +326,7 @@ class Rules
return ! empty($data[$item]);
});
return ! (bool) count($requiredFields);
return empty($requiredFields);
}
//--------------------------------------------------------------------

View File

@ -144,7 +144,7 @@ class Validation implements ValidationInterface
$this->processRules($rField, $data[$rField] ?? null, $rules, $data);
}
return count($this->errors) > 0 ? false : true;
return ! empty($this->errors) ? false : true;
}
//--------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
<?php if (count($errors) > 0) : ?>
<?php if (! empty($errors)) : ?>
<div class="alert alert-danger" role="alert">
<ul>
<?php foreach ($errors as $error) : ?>

View File

@ -213,7 +213,7 @@ class Cell
unset($new_params);
}
if (is_array($params) && ! count($params))
if (is_array($params) && empty($params))
{
return [];
}

View File

@ -270,7 +270,7 @@ class Parser extends View
function strpos_all($haystack, $needle)
{
$offset = 0;
$allpos = array();
$allpos = [];
while (($pos = strpos($haystack, $needle, $offset)) !== FALSE)
{
$offset = $pos + 1;

View File

@ -5,25 +5,25 @@ class CITestSeeder extends \CodeIgniter\Database\Seeder
public function run()
{
// Job Data
$data = array(
'user' => array(
array('name' => 'Derek Jones', 'email' => 'derek@world.com', 'country' => 'US'),
array('name' => 'Ahmadinejad', 'email' => 'ahmadinejad@world.com', 'country' => 'Iran'),
array('name' => 'Richard A Causey', 'email' => 'richard@world.com', 'country' => 'US'),
array('name' => 'Chris Martin', 'email' => 'chris@world.com', 'country' => 'UK')
),
'job' => array(
array('name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'),
array('name' => 'Politician', 'description' => 'This is not really a job'),
array('name' => 'Accountant', 'description' => 'Boring job, but you will get free snack at lunch'),
array('name' => 'Musician', 'description' => 'Only Coldplay can actually called Musician')
),
'misc' => array(
array('key' => '\\xxxfoo456', 'value' => 'Entry with \\xxx'),
array('key' => '\\%foo456', 'value' => 'Entry with \\%'),
array('key' => 'spaces and tabs', 'value' => ' One two three tab')
)
);
$data = [
'user' => [
['name' => 'Derek Jones', 'email' => 'derek@world.com', 'country' => 'US'],
['name' => 'Ahmadinejad', 'email' => 'ahmadinejad@world.com', 'country' => 'Iran'],
['name' => 'Richard A Causey', 'email' => 'richard@world.com', 'country' => 'US'],
['name' => 'Chris Martin', 'email' => 'chris@world.com', 'country' => 'UK']
],
'job' => [
['name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'],
['name' => 'Politician', 'description' => 'This is not really a job'],
['name' => 'Accountant', 'description' => 'Boring job, but you will get free snack at lunch'],
['name' => 'Musician', 'description' => 'Only Coldplay can actually called Musician']
],
'misc' => [
['key' => '\\xxxfoo456', 'value' => 'Entry with \\xxx'],
['key' => '\\%foo456', 'value' => 'Entry with \\%'],
['key' => 'spaces and tabs', 'value' => ' One two three tab']
]
];
foreach ($data as $table => $dummy_data)
{

View File

@ -17,7 +17,7 @@ class CommomFunctionsTest extends \CIUnitTestCase
public function testStringifyAttributes()
{
$this->assertEquals(' class="foo" id="bar"', stringify_attributes(array('class' => 'foo', 'id' => 'bar')));
$this->assertEquals(' class="foo" id="bar"', stringify_attributes(['class' => 'foo', 'id' => 'bar']));
$atts = new stdClass;
$atts->class = 'foo';
@ -29,14 +29,14 @@ class CommomFunctionsTest extends \CIUnitTestCase
$this->assertEquals(' class="foo" id="bar"', stringify_attributes('class="foo" id="bar"'));
$this->assertEquals('', stringify_attributes(array()));
$this->assertEquals('', stringify_attributes([]));
}
// ------------------------------------------------------------------------
public function testStringifyJsAttributes()
{
$this->assertEquals('width=800,height=600', stringify_attributes(array('width' => '800', 'height' => '600'), TRUE));
$this->assertEquals('width=800,height=600', stringify_attributes(['width' => '800', 'height' => '600'], TRUE));
$atts = new stdClass;
$atts->width = 800;

View File

@ -52,10 +52,10 @@ class InsertTest extends \CIUnitTestCase
{
$builder = $this->db->table('jobs');
$insertData = array(
$insertData = [
['id' => 2, 'name' => 'Commedian', 'description' => 'Theres something in your teeth'],
['id' => 3, 'name' => 'Cab Driver', 'description' => 'Iam yellow'],
);
];
$this->db->shouldReturn('execute', 1)
->shouldReturn('affectedRows', 1);

View File

@ -21,11 +21,11 @@ class ReplaceTest extends \CIUnitTestCase
$expected = "REPLACE INTO \"jobs\" (\"title\", \"name\", \"date\") VALUES (:title, :name, :date)";
$data = array(
$data = [
'title' => 'My title',
'name' => 'My Name',
'date' => 'My date'
);
];
$this->assertSame($expected, $builder->replace($data, true));
}

View File

@ -77,10 +77,10 @@ class UpdateTest extends \CIUnitTestCase
{
$builder = new BaseBuilder('jobs', $this->db);
$updateData = array(
$updateData = [
['id' => 2, 'name' => 'Comedian', 'description' => 'Theres something in your teeth'],
['id' => 3, 'name' => 'Cab Driver', 'description' => 'Iam yellow'],
);
];
$this->db->shouldReturn('execute', 1)
->shouldReturn('affectedRows', 1);

View File

@ -11,7 +11,7 @@ class InsertTest extends \CIDatabaseTestCase
public function testInsert()
{
$job_data = array('name' => 'Grocery Sales', 'description' => 'Discount!');
$job_data = ['name' => 'Grocery Sales', 'description' => 'Discount!'];
$this->db->table('job')->insert($job_data);
@ -22,10 +22,10 @@ class InsertTest extends \CIDatabaseTestCase
public function testInsertBatch()
{
$job_data = array(
array('name' => 'Comedian', 'description' => 'Theres something in your teeth'),
array('name' => 'Cab Driver', 'description' => 'Iam yellow'),
);
$job_data = [
['name' => 'Comedian', 'description' => 'Theres something in your teeth'],
['name' => 'Cab Driver', 'description' => 'Iam yellow'],
];
$this->db->table('job')->insertBatch($job_data);
@ -37,7 +37,7 @@ class InsertTest extends \CIDatabaseTestCase
public function testReplaceWithNoMatchingData()
{
$data = array('id' => 5, 'name' => 'Cab Driver', 'description' => 'Iam yellow');
$data = ['id' => 5, 'name' => 'Cab Driver', 'description' => 'Iam yellow'];
$this->db->table('job')->replace($data);
@ -52,7 +52,7 @@ class InsertTest extends \CIDatabaseTestCase
public function testReplaceWithMatchingData()
{
$data = array('id' => 1, 'name' => 'Cab Driver', 'description' => 'Iam yellow');
$data = ['id' => 1, 'name' => 'Cab Driver', 'description' => 'Iam yellow'];
$this->db->table('job')->replace($data);

View File

@ -382,24 +382,24 @@ class URITest extends \CIUnitTestCase
public function defaultDots()
{
return array (
array ('/foo/..', '/'),
array ('//foo//..', '/'),
array ('/foo/../..', '/'),
array ('/foo/../.', '/'),
array ('/./foo/..', '/'),
array ('/./foo', '/foo'),
array ('/./foo/', '/foo/'),
array ('/./foo/bar/baz/pho/../..', '/foo/bar'),
array ('*', '*'),
array ('/foo', '/foo'),
array ('/abc/123/../foo/', '/abc/foo/'),
array ('/a/b/c/./../../g', '/a/g'),
array ('/b/c/./../../g', '/g'),
array ('/b/c/./../../g', '/g'),
array ('/c/./../../g', '/g'),
array ('/./../../g', '/g'),
);
return [
['/foo/..', '/'],
['//foo//..', '/'],
['/foo/../..', '/'],
['/foo/../.', '/'],
['/./foo/..', '/'],
['/./foo', '/foo'],
['/./foo/', '/foo/'],
['/./foo/bar/baz/pho/../..', '/foo/bar'],
['*', '*'],
['/foo', '/foo'],
['/abc/123/../foo/', '/abc/foo/'],
['/a/b/c/./../../g', '/a/g'],
['/b/c/./../../g', '/g'],
['/b/c/./../../g', '/g'],
['/c/./../../g', '/g'],
['/./../../g', '/g'],
];
}
//--------------------------------------------------------------------

View File

@ -41,12 +41,11 @@ final class cookieHelperTest extends \CIUnitTestCase
public function testSetCookieByArrayParameters()
{
$cookieAttr = array
(
$cookieAttr = [
'name' => $this->name,
'value' => $this->value,
'expire' => $this->expire
);
];
//set_cookie($cookieAttr);
$this->response->setCookie($cookieAttr);

View File

@ -164,14 +164,14 @@ EOH;
$expected = <<<EOH
<input type="text" name="username" value="johndoe" id="username" maxlength="100" size="50" style="width:50%" />\n
EOH;
$data = array(
$data = [
'name' => 'username',
'id' => 'username',
'value' => 'johndoe',
'maxlength' => '100',
'size' => '50',
'style' => 'width:50%',
);
];
$this->assertEquals($expected, form_input($data));
}
// ------------------------------------------------------------------------
@ -222,12 +222,12 @@ EOH;
<option value="xlarge">Extra Large Shirt</option>
</select>\n
EOH;
$options = array(
$options = [
'small' => 'Small Shirt',
'med' => 'Medium Shirt',
'large' => 'Large Shirt',
'xlarge' => 'Extra Large Shirt',
);
];
$this->assertEquals($expected, form_dropdown('shirts', $options, 'large'));
$expected = <<<EOH
<select name="shirts" multiple="multiple">
@ -237,18 +237,18 @@ EOH;
<option value="xlarge">Extra Large Shirt</option>
</select>\n
EOH;
$shirts_on_sale = array('small', 'large');
$shirts_on_sale = ['small', 'large'];
$this->assertEquals($expected, form_dropdown('shirts', $options, $shirts_on_sale));
$options = array(
'Swedish Cars' => array(
$options = [
'Swedish Cars' => [
'volvo' => 'Volvo',
'saab' => 'Saab'
),
'German Cars' => array(
],
'German Cars' => [
'mercedes' => 'Mercedes',
'audi' => 'Audi'
)
);
]
];
$expected = <<<EOH
<select name="cars" multiple="multiple">
<optgroup label="Swedish Cars">
@ -261,7 +261,7 @@ EOH;
</optgroup>
</select>\n
EOH;
$this->assertEquals($expected, form_dropdown('cars', $options, array('volvo', 'audi')));
$this->assertEquals($expected, form_dropdown('cars', $options, ['volvo', 'audi']));
}
// ------------------------------------------------------------------------
public function testFormDropdownWithSelectedAttribute()
@ -322,13 +322,13 @@ EOH;
<option value="xlarge">Extra Large Shirt</option>
</select>\n
EOH;
$options = array(
$options = [
'small' => 'Small Shirt',
'med' => 'Medium Shirt',
'large' => 'Large Shirt',
'xlarge' => 'Extra Large Shirt',
);
$this->assertEquals($expected, form_multiselect('shirts[]', $options, array('med', 'large')));
];
$this->assertEquals($expected, form_multiselect('shirts[]', $options, ['med', 'large']));
}
// ------------------------------------------------------------------------
public function test_form_fieldset()

View File

@ -35,7 +35,7 @@ final class HTMLHelperTest extends \CIUnitTestCase
EOH;
$expected = ltrim($expected);
$list = array('foo', 'bar');
$list = ['foo', 'bar'];
$this->assertEquals(ltrim($expected), ul($list));
}
@ -51,7 +51,7 @@ EOH;
EOH;
$expected = ltrim($expected);
$list = array('foo', 'bar');
$list = ['foo', 'bar'];
$this->assertEquals($expected, ul($list, 'class="test"'));
}
@ -73,7 +73,7 @@ EOH;
EOH;
$expected = ltrim($expected);
$list = array('foo', 'bar', array('foo', 'bar'));
$list = ['foo', 'bar', ['foo', 'bar']];
$this->assertEquals(ltrim($expected), ul($list));
}
@ -91,7 +91,7 @@ EOH;
EOH;
$expected = ltrim($expected);
$list = array('foo', 'bar');
$list = ['foo', 'bar'];
$this->assertEquals(ltrim($expected), ol($list));
}
@ -107,7 +107,7 @@ EOH;
EOH;
$expected = ltrim($expected);
$list = array('foo', 'bar');
$list = ['foo', 'bar'];
$this->assertEquals($expected, ol($list, 'class="test"'));
}
@ -129,7 +129,7 @@ EOH;
EOH;
$expected = ltrim($expected);
$list = array('foo', 'bar', array('foo', 'bar'));
$list = ['foo', 'bar', ['foo', 'bar']];
$this->assertEquals(ltrim($expected), ol($list));
}

View File

@ -85,6 +85,8 @@ class TextHelperTest extends \CIUnitTestCase
{
$this->assertEquals(16, strlen(random_string('alnum', 16)));
$this->assertInternalType('string', random_string('numeric', 16));
$this->assertEquals(16, strlen($random = random_string('crypto', 16)));
$this->assertInternalType('string', $random);
}
// --------------------------------------------------------------------
public function test_increment_string()

View File

@ -560,7 +560,7 @@ class URLHelperTest extends \CIUnitTestCase
{
return [
'egpage01' => ['<a href="http://example.com/index.php/news/local/123" title="News title">My News</a>', 'news/local/123', 'My News', 'title="News title"'],
'egpage02' => ['<a href="http://example.com/index.php/news/local/123" title="The&#x20;best&#x20;news&#x21;">My News</a>', 'news/local/123', 'My News', array ('title' => 'The best news!')],
'egpage02' => ['<a href="http://example.com/index.php/news/local/123" title="The&#x20;best&#x20;news&#x21;">My News</a>', 'news/local/123', 'My News', ['title' => 'The best news!']],
'egpage03' => ['<a href="http://example.com/index.php">Click here</a>', '', 'Click here'],
'egpage04' => ['<a href="http://example.com/index.php">Click here</a>', '/', 'Click here'],
];
@ -594,7 +594,7 @@ class URLHelperTest extends \CIUnitTestCase
'normal02' => ['<a href="http://example.com/index.php" onclick="window.open(\'http://example.com/index.php\', \'_blank\'); return false;">Bananas</a>', '/', 'Bananas'],
'normal07' => ['<a href="http://example.com/index.php" onclick="window.open(\'http://example.com/index.php\', \'_blank\'); return false;">http://example.com/index.php</a>', '/'],
'normal08' => ['<a href="http://example.com/index.php/news/local/123" onclick="window.open(\'http://example.com/index.php/news/local/123\', \'_blank\', \'width=800,height=600,scrollbars=yes,menubar=no,status=yes,resizable=yes,screenx=0,screeny=0\'); return false;">Click Me!</a>',
'news/local/123', 'Click Me!', array (
'news/local/123', 'Click Me!', [
'width' => 800,
'height' => 600,
'scrollbars' => 'yes',
@ -603,12 +603,12 @@ class URLHelperTest extends \CIUnitTestCase
'screenx' => 0,
'screeny' => 0,
'window_name' => '_blank'
)],
]],
'normal09' => [
'<a href="http://example.com/index.php/news/local/123" onclick="window.open(\'http://example.com/index.php/news/local/123\', \'_blank\', \'width=800,height=600,scrollbars=yes,menubar=no,status=yes,resizable=yes,screenx=0,screeny=0\'); return false;">Click Me!</a>',
'news/local/123',
'Click Me!',
array ()],
[]],
];
}
@ -637,7 +637,7 @@ class URLHelperTest extends \CIUnitTestCase
{
return [
'page01' => ['<a href="mailto:me@my-site.com">Click Here to Contact Me</a>', 'me@my-site.com', 'Click Here to Contact Me'],
'page02' => ['<a href="mailto:me@my-site.com" title="Mail&#x20;me">Contact Me</a>', 'me@my-site.com', 'Contact Me', array ('title' => 'Mail me')],
'page02' => ['<a href="mailto:me@my-site.com" title="Mail&#x20;me">Contact Me</a>', 'me@my-site.com', 'Contact Me', ['title' => 'Mail me']],
'page03' => ['<a href="mailto:me@my-site.com">me@my-site.com</a>', 'me@my-site.com'],
];
}
@ -670,7 +670,7 @@ class URLHelperTest extends \CIUnitTestCase
'page01' => ["<script type=\"text/javascript\">//<![CDATA[var l=new Array();l[0] = '>';l[1] = 'a';l[2] = '/';l[3] = '<';l[4] = '|101';l[5] = '|77';l[6] = '|32';l[7] = '|116';l[8] = '|99';l[9] = '|97';l[10] = '|116';l[11] = '|110';l[12] = '|111';l[13] = '|67';l[14] = '|32';l[15] = '|111';l[16] = '|116';l[17] = '|32';l[18] = '|101';l[19] = '|114';l[20] = '|101';l[21] = '|72';l[22] = '|32';l[23] = '|107';l[24] = '|99';l[25] = '|105';l[26] = '|108';l[27] = '|67';l[28] = '>';l[29] = '\"';l[30] = '|109';l[31] = '|111';l[32] = '|99';l[33] = '|46';l[34] = '|101';l[35] = '|116';l[36] = '|105';l[37] = '|115';l[38] = '|45';l[39] = '|121';l[40] = '|109';l[41] = '|64';l[42] = '|101';l[43] = '|109';l[44] = ':';l[45] = 'o';l[46] = 't';l[47] = 'l';l[48] = 'i';l[49] = 'a';l[50] = 'm';l[51] = '\"';l[52] = '=';l[53] = 'f';l[54] = 'e';l[55] = 'r';l[56] = 'h';l[57] = ' ';l[58] = 'a';l[59] = '<';for (var i = l.length-1; i >= 0; i=i-1) {if (l[i].substring(0, 1) === '|') document.write(\"&#\"+unescape(l[i].substring(1))+\";\");else document.write(unescape(l[i]));}//]]></script>",
'me@my-site.com', 'Click Here to Contact Me'],
'page02' => ["<script type=\"text/javascript\">//<![CDATA[var l=new Array();l[0] = '>';l[1] = 'a';l[2] = '/';l[3] = '<';l[4] = '|101';l[5] = '|77';l[6] = '|32';l[7] = '|116';l[8] = '|99';l[9] = '|97';l[10] = '|116';l[11] = '|110';l[12] = '|111';l[13] = '|67';l[14] = '>';l[15] = '\"';l[16] = '|101';l[17] = '|109';l[18] = '|32';l[19] = '|108';l[20] = '|105';l[21] = '|97';l[22] = '|77';l[23] = ' title=\"';l[24] = '\"';l[25] = '|109';l[26] = '|111';l[27] = '|99';l[28] = '|46';l[29] = '|101';l[30] = '|116';l[31] = '|105';l[32] = '|115';l[33] = '|45';l[34] = '|121';l[35] = '|109';l[36] = '|64';l[37] = '|101';l[38] = '|109';l[39] = ':';l[40] = 'o';l[41] = 't';l[42] = 'l';l[43] = 'i';l[44] = 'a';l[45] = 'm';l[46] = '\"';l[47] = '=';l[48] = 'f';l[49] = 'e';l[50] = 'r';l[51] = 'h';l[52] = ' ';l[53] = 'a';l[54] = '<';for (var i = l.length-1; i >= 0; i=i-1) {if (l[i].substring(0, 1) === '|') document.write(\"&#\"+unescape(l[i].substring(1))+\";\");else document.write(unescape(l[i]));}//]]></script>",
'me@my-site.com', 'Contact Me', array ('title' => 'Mail me')],
'me@my-site.com', 'Contact Me', ['title' => 'Mail me']],
'page03' => ["<script type=\"text/javascript\">//<![CDATA[var l=new Array();l[0] = '>';l[1] = 'a';l[2] = '/';l[3] = '<';l[4] = '|109';l[5] = '|111';l[6] = '|99';l[7] = '|46';l[8] = '|101';l[9] = '|116';l[10] = '|105';l[11] = '|115';l[12] = '|45';l[13] = '|121';l[14] = '|109';l[15] = '|64';l[16] = '|101';l[17] = '|109';l[18] = '>';l[19] = '\"';l[20] = '|109';l[21] = '|111';l[22] = '|99';l[23] = '|46';l[24] = '|101';l[25] = '|116';l[26] = '|105';l[27] = '|115';l[28] = '|45';l[29] = '|121';l[30] = '|109';l[31] = '|64';l[32] = '|101';l[33] = '|109';l[34] = ':';l[35] = 'o';l[36] = 't';l[37] = 'l';l[38] = 'i';l[39] = 'a';l[40] = 'm';l[41] = '\"';l[42] = '=';l[43] = 'f';l[44] = 'e';l[45] = 'r';l[46] = 'h';l[47] = ' ';l[48] = 'a';l[49] = '<';for (var i = l.length-1; i >= 0; i=i-1) {if (l[i].substring(0, 1) === '|') document.write(\"&#\"+unescape(l[i].substring(1))+\";\");else document.write(unescape(l[i]));}//]]></script>",
'me@my-site.com'],
];
@ -832,10 +832,10 @@ class URLHelperTest extends \CIUnitTestCase
public function testUrlTitle()
{
$words = array (
$words = [
'foo bar /' => 'foo-bar',
'\ testing 12' => 'testing-12'
);
];
foreach ($words as $in => $out)
{
@ -845,10 +845,10 @@ class URLHelperTest extends \CIUnitTestCase
public function testUrlTitleExtraDashes()
{
$words = array (
$words = [
'_foo bar_' => 'foo_bar',
'_What\'s wrong with CSS?_' => 'Whats_wrong_with_CSS'
);
];
foreach ($words as $in => $out)
{

View File

@ -43,6 +43,7 @@ The following functions are available:
- **nozero**: Numeric string with no zeros.
- **md5**: An encrypted random number based on ``md5()`` (fixed length of 32).
- **sha1**: An encrypted random number based on ``sha1()`` (fixed length of 40).
- **crypto**: A random string based on ``random_bytes()``.
Usage example::