From ec4f0d0592182f488de31ae20feee0638e579f51 Mon Sep 17 00:00:00 2001 From: ruslan Date: Fri, 16 Jan 2026 08:02:50 +0100 Subject: [PATCH] Fix deprecated non-canonical casts to canonical forms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace deprecated non-canonical PHP casts with their canonical equivalents: - (integer) → (int) - (boolean) → (bool) - (double) / (real) → (float) - (binary) → (string) This addresses PHP 8.5 deprecation warnings for non-canonical cast syntax. --- framework/db/schema/CDbColumnSchema.php | 4 ++-- framework/utils/CPropertyValue.php | 4 ++-- framework/utils/CTimestamp.php | 4 ++-- framework/validators/CTypeValidator.php | 4 ++-- framework/vendors/Net_IDNA2/Net/IDNA2.php | 2 +- framework/web/CHttpRequest.php | 8 ++++---- framework/web/helpers/CJSON.php | 4 ++-- framework/yiilite.php | 12 ++++++------ 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/framework/db/schema/CDbColumnSchema.php b/framework/db/schema/CDbColumnSchema.php index 40e9c68fe..8540f67f1 100644 --- a/framework/db/schema/CDbColumnSchema.php +++ b/framework/db/schema/CDbColumnSchema.php @@ -144,8 +144,8 @@ class CDbColumnSchema extends CComponent switch($this->type) { case 'string': return (string)$value; - case 'integer': return (integer)$value; - case 'boolean': return (boolean)$value; + case 'integer': return (int)$value; + case 'boolean': return (bool)$value; case 'double': default: return $value; } diff --git a/framework/utils/CPropertyValue.php b/framework/utils/CPropertyValue.php index 9b02da82b..684ea8c44 100644 --- a/framework/utils/CPropertyValue.php +++ b/framework/utils/CPropertyValue.php @@ -55,7 +55,7 @@ class CPropertyValue if (is_string($value)) return !strcasecmp($value,'true') || ($value!=0 && $value!=='' && is_numeric($value)); else - return (boolean)$value; + return (bool)$value; } /** @@ -80,7 +80,7 @@ class CPropertyValue */ public static function ensureInteger($value) { - return (integer)$value; + return (int)$value; } /** diff --git a/framework/utils/CTimestamp.php b/framework/utils/CTimestamp.php index 8b8f946c1..c757496f9 100644 --- a/framework/utils/CTimestamp.php +++ b/framework/utils/CTimestamp.php @@ -112,8 +112,8 @@ class CTimestamp protected static function digitCheck($y) { if ($y < 100){ - $yr = (integer) date("Y"); - $century = (integer) ($yr /100); + $yr = (int) date("Y"); + $century = (int) ($yr /100); if ($yr%100 > 50) { $c1 = $century + 1; diff --git a/framework/validators/CTypeValidator.php b/framework/validators/CTypeValidator.php index fc7a3a545..1ecddbfbd 100644 --- a/framework/validators/CTypeValidator.php +++ b/framework/validators/CTypeValidator.php @@ -117,9 +117,9 @@ class CTypeValidator extends CValidator return false; if($type==='integer') - return (boolean)preg_match('/^[-+]?[0-9]+$/',trim($value)); + return (bool)preg_match('/^[-+]?[0-9]+$/',trim($value)); elseif($type==='double') - return (boolean)preg_match('/^[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?$/',trim($value)); + return (bool)preg_match('/^[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?$/',trim($value)); elseif($type==='date') return CDateTimeParser::parse($value,$this->dateFormat,array('month'=>1,'day'=>1,'hour'=>0,'minute'=>0,'second'=>0))!==false; elseif($type==='time') diff --git a/framework/vendors/Net_IDNA2/Net/IDNA2.php b/framework/vendors/Net_IDNA2/Net/IDNA2.php index 4e0e6f4d5..125e8593e 100644 --- a/framework/vendors/Net_IDNA2/Net/IDNA2.php +++ b/framework/vendors/Net_IDNA2/Net/IDNA2.php @@ -3351,7 +3351,7 @@ class Net_IDNA2 if (self::$_mb_string_overload) { return mb_strlen($string, '8bit'); } - return strlen((binary)$string); + return strlen((string)$string); } // }}}} diff --git a/framework/web/CHttpRequest.php b/framework/web/CHttpRequest.php index f167602ba..94efb9d8d 100644 --- a/framework/web/CHttpRequest.php +++ b/framework/web/CHttpRequest.php @@ -972,11 +972,11 @@ class CHttpRequest extends CApplicationComponent if($matches[4][$i]==='q') { // sanity check on q value - $q=(double)$matches[5][$i]; + $q=(float)$matches[5][$i]; if($q>1) - $q=(double)1; + $q=(float)1; elseif($q<0) - $q=(double)0; + $q=(float)0; $accept['params'][$matches[4][$i]]=$q; } else @@ -987,7 +987,7 @@ class CHttpRequest extends CApplicationComponent } // q defaults to 1 if not explicitly given if(!isset($accept['params']['q'])) - $accept['params']['q']=(double)1; + $accept['params']['q']=(float)1; $accepts[] = $accept; } } diff --git a/framework/web/helpers/CJSON.php b/framework/web/helpers/CJSON.php index dd01c472a..85db646c7 100644 --- a/framework/web/helpers/CJSON.php +++ b/framework/web/helpers/CJSON.php @@ -362,8 +362,8 @@ class CJSON // return (float)$str; // Return float or int, as appropriate - return ((float)$str == (integer)$str) - ? (integer)$str + return ((float)$str == (int)$str) + ? (int)$str : (float)$str; } elseif (preg_match('/^("|\').+(\1)$/s', $str, $m) && $m[1] == $m[2]) { diff --git a/framework/yiilite.php b/framework/yiilite.php index b51ba0024..66245fbf7 100644 --- a/framework/yiilite.php +++ b/framework/yiilite.php @@ -2775,11 +2775,11 @@ class CHttpRequest extends CApplicationComponent if($matches[4][$i]==='q') { // sanity check on q value - $q=(double)$matches[5][$i]; + $q=(float)$matches[5][$i]; if($q>1) - $q=(double)1; + $q=(float)1; elseif($q<0) - $q=(double)0; + $q=(float)0; $accept['params'][$matches[4][$i]]=$q; } else @@ -2790,7 +2790,7 @@ class CHttpRequest extends CApplicationComponent } // q defaults to 1 if not explicitly given if(!isset($accept['params']['q'])) - $accept['params']['q']=(double)1; + $accept['params']['q']=(float)1; $accepts[] = $accept; } } @@ -10327,8 +10327,8 @@ class CDbColumnSchema extends CComponent switch($this->type) { case 'string': return (string)$value; - case 'integer': return (integer)$value; - case 'boolean': return (boolean)$value; + case 'integer': return (int)$value; + case 'boolean': return (bool)$value; case 'double': default: return $value; }