Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unneeded (string) cast as type hinted #1152

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions system/Helpers/form_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,6 @@ function set_select(string $field, string $value = '', bool $default = false): s

if (is_array($input))
{
$value = (string) $value;

// Note: in_array('', array(0)) returns TRUE, do not use it
foreach ($input as &$v)
{
Expand Down Expand Up @@ -840,9 +838,6 @@ function set_select(string $field, string $value = '', bool $default = false): s
*/
function set_checkbox(string $field, string $value = '', bool $default = false): string
{
// Form inputs are always strings ...
$value = (string) $value;

$request = Services::request();

// Try any old input data we may have first
Expand Down Expand Up @@ -897,9 +892,6 @@ function set_checkbox(string $field, string $value = '', bool $default = false):
*/
function set_radio(string $field, string $value = '', bool $default = false): string
{
// Form inputs are always strings ...
$value = (string) $value;

$request = Services::request();

// Try any old input data we may have first
Expand Down
15 changes: 4 additions & 11 deletions system/Helpers/url_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,11 @@ function index_page(\Config\App $altConfig = null): string
*
* @return string
*/
function anchor($uri = '', $title = '', $attributes = '', \Config\App $altConfig = null): string
function anchor($uri = '', string $title = '', $attributes = '', \Config\App $altConfig = null): string
{
// use alternate config if provided, else default one
$config = empty($altConfig) ? config(\Config\App::class) : $altConfig;

$title = (string) $title;

$site_url = is_array($uri) ? site_url($uri, null, $config) : (preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri, null, $config));
// eliminate trailing slash
$site_url = rtrim($site_url, '/');
Expand Down Expand Up @@ -286,12 +284,11 @@ function anchor($uri = '', $title = '', $attributes = '', \Config\App $altConfig
*
* @return string
*/
function anchor_popup($uri = '', $title = '', $attributes = false, \Config\App $altConfig = null): string
function anchor_popup($uri = '', string $title = '', $attributes = false, \Config\App $altConfig = null): string
{
// use alternate config if provided, else default one
$config = empty($altConfig) ? config(\Config\App::class) : $altConfig;

$title = (string) $title;
$site_url = preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri, '', $config);
$site_url = rtrim($site_url, '/');

Expand Down Expand Up @@ -351,10 +348,8 @@ function anchor_popup($uri = '', $title = '', $attributes = false, \Config\App $
*
* @return string
*/
function mailto($email, $title = '', $attributes = ''): string
function mailto($email, string $title = '', $attributes = ''): string
{
$title = (string) $title;

if ($title === '')
{
$title = $email;
Expand All @@ -381,10 +376,8 @@ function mailto($email, $title = '', $attributes = ''): string
*
* @return string
*/
function safe_mailto($email, $title = '', $attributes = ''): string
function safe_mailto($email, string $title = '', $attributes = ''): string
{
$title = (string) $title;

if ($title === '')
{
$title = $email;
Expand Down
6 changes: 3 additions & 3 deletions system/Validation/FormatRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function alpha_dash(string $str = null): bool
*/
public function alpha_numeric(string $str = null): bool
{
return ctype_alnum((string) $str);
return ctype_alnum($str);
}

//--------------------------------------------------------------------
Expand Down Expand Up @@ -155,7 +155,7 @@ public function integer(string $str = null): bool
*/
public function is_natural(string $str = null): bool
{
return ctype_digit((string) $str);
return ctype_digit($str);
}

//--------------------------------------------------------------------
Expand All @@ -168,7 +168,7 @@ public function is_natural(string $str = null): bool
*/
public function is_natural_no_zero(string $str = null): bool
{
return ($str != 0 && ctype_digit((string) $str));
return ($str != 0 && ctype_digit($str));
}

//--------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion system/View/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ protected function parseSingle(string $key, string $val): array
{
$pattern = '#' . $this->leftDelimiter . '!?\s*' . preg_quote($key) . '\s*\|*\s*([|a-zA-Z0-9<>=\(\),:_\-\s\+]+)*\s*!?' . $this->rightDelimiter . '#ms';

return [$pattern => (string) $val];
return [$pattern => $val];
}

//--------------------------------------------------------------------
Expand Down