Skip to content

Commit

Permalink
Merge pull request codeigniter4#1812 from jim-parry/testing23
Browse files Browse the repository at this point in the history
Test: Improve Filters coverage
  • Loading branch information
jim-parry authored Mar 12, 2019
2 parents 895ae04 + 97726bb commit ba4f258
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function initialize()
* @param \CodeIgniter\Router\RouteCollectionInterface $routes
* @param boolean $returnResponse
*
* @return bool|\CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed
* @return boolean|\CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed
* @throws \CodeIgniter\Filters\Exceptions\FilterException
* @throws \Exception
*/
Expand Down Expand Up @@ -276,7 +276,7 @@ public function useSafeOutput(bool $safe = true)
* Handles the main request logic and fires the controller.
*
* @param \CodeIgniter\Router\RouteCollectionInterface $routes
* @param $cacheConfig
* @param $cacheConfig
* @param boolean $returnResponse
*
* @return \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed
Expand Down
15 changes: 7 additions & 8 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -662,20 +662,19 @@ protected function whereHaving($qb_key, $key, $value = null, $type = 'AND ', $es
if ($v !== null)
{
$op = $this->getOperator($k, true);
if(!empty($op))

if (! empty($op))
{
$k = trim($k);

end($op);

$op = trim(current($op));

if(substr($k, -1 * strlen($op)) === $op)
if (substr($k, -1 * strlen($op)) === $op)
{
$k = rtrim(strrev(preg_replace(strrev("/" . $op . "/"),strrev(''),strrev($k),1)));
$k = rtrim(strrev(preg_replace(strrev('/' . $op . '/'), strrev(''), strrev($k), 1)));
}

}

$bind = $this->setBind($k, $v, $escape);
Expand Down Expand Up @@ -2922,8 +2921,8 @@ protected function hasOperator($str)
/**
* Returns the SQL string operator
*
* @param string $str
* @param bool $list
* @param string $str
* @param boolean $list
*
* @return string
*/
Expand All @@ -2950,7 +2949,7 @@ protected function getOperator($str, bool $list = false)
];
}

return preg_match_all('/' . implode('|', $_operators) . '/i', $str, $match) ? ($list ? $match[0] : $match[0][count($match[0])-1]) : false;
return preg_match_all('/' . implode('|', $_operators) . '/i', $str, $match) ? ($list ? $match[0] : $match[0][count($match[0]) - 1]) : false;
}

// --------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion system/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ protected function mutateDate($value)
* Provides the ability to cast an item as a specific data type.
* Add ? at the beginning of $type (i.e. ?string) to get NULL instead of castig $value if $value === null
*
* @param $value
* @param $value
* @param string $type
*
* @return mixed
Expand Down
6 changes: 3 additions & 3 deletions system/Validation/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ public function differs(string $str = null, string $field, array $data): bool
*/
public function exact_length(string $str = null, string $val, array $data): bool
{
if(strpos($val, ',') !== 1)
if (strpos($val, ',') !== 1)
{
$val = explode(',', $val);
foreach ($val as $tmp)
{
if(is_numeric($tmp) && (int) $tmp === mb_strlen($str))
if (is_numeric($tmp) && (int) $tmp === mb_strlen($str))
{
return true;
}
}
}

return ((int) $val === mb_strlen($str));
}

Expand Down

0 comments on commit ba4f258

Please sign in to comment.