Skip to content

Commit a12f860

Browse files
authored
Merge pull request #4611 from ac-dc/non-canonical-casts
Fix deprecated non-canonical casts to canonical forms
2 parents a2d4af9 + dae5112 commit a12f860

File tree

10 files changed

+23
-21
lines changed

10 files changed

+23
-21
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
- "8.2"
3535
- "8.3"
3636
- "8.4"
37+
- "8.5"
3738

3839
services:
3940
mysql:

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Version 1.1.33 under development
55
--------------------------------
66

7+
- Bug #4598: PHP 8.5 compatibility: Fix deprecated non-canonical casts to canonical forms (ac-dc)
78
- Bug #4607: Fix loading CHttpSessionHandler when using yiilite on Yii 1.1.32 and PHP 7+ (tance77, marcovtwout)
89

910
Version 1.1.32 December 23, 2025

framework/db/schema/CDbColumnSchema.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ public function typecast($value)
144144
switch($this->type)
145145
{
146146
case 'string': return (string)$value;
147-
case 'integer': return (integer)$value;
148-
case 'boolean': return (boolean)$value;
147+
case 'integer': return (int)$value;
148+
case 'boolean': return (bool)$value;
149149
case 'double':
150150
default: return $value;
151151
}

framework/utils/CPropertyValue.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static function ensureBoolean($value)
5555
if (is_string($value))
5656
return !strcasecmp($value,'true') || ($value!=0 && $value!=='' && is_numeric($value));
5757
else
58-
return (boolean)$value;
58+
return (bool)$value;
5959
}
6060

6161
/**
@@ -80,7 +80,7 @@ public static function ensureString($value)
8080
*/
8181
public static function ensureInteger($value)
8282
{
83-
return (integer)$value;
83+
return (int)$value;
8484
}
8585

8686
/**

framework/utils/CTimestamp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ public static function isLeapYear($year)
112112
protected static function digitCheck($y)
113113
{
114114
if ($y < 100){
115-
$yr = (integer) date("Y");
116-
$century = (integer) ($yr /100);
115+
$yr = (int) date("Y");
116+
$century = (int) ($yr /100);
117117

118118
if ($yr%100 > 50) {
119119
$c1 = $century + 1;

framework/validators/CTypeValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public function validateValue($value)
117117
return false;
118118

119119
if($type==='integer')
120-
return (boolean)preg_match('/^[-+]?[0-9]+$/',trim($value));
120+
return (bool)preg_match('/^[-+]?[0-9]+$/',trim($value));
121121
elseif($type==='double')
122-
return (boolean)preg_match('/^[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?$/',trim($value));
122+
return (bool)preg_match('/^[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?$/',trim($value));
123123
elseif($type==='date')
124124
return CDateTimeParser::parse($value,$this->dateFormat,array('month'=>1,'day'=>1,'hour'=>0,'minute'=>0,'second'=>0))!==false;
125125
elseif($type==='time')

framework/vendors/Net_IDNA2/Net/IDNA2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3351,7 +3351,7 @@ private static function _byteLength($string)
33513351
if (self::$_mb_string_overload) {
33523352
return mb_strlen($string, '8bit');
33533353
}
3354-
return strlen((binary)$string);
3354+
return strlen((string)$string);
33553355
}
33563356

33573357
// }}}}

framework/web/CHttpRequest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -972,11 +972,11 @@ public static function parseAcceptHeader($header)
972972
if($matches[4][$i]==='q')
973973
{
974974
// sanity check on q value
975-
$q=(double)$matches[5][$i];
975+
$q=(float)$matches[5][$i];
976976
if($q>1)
977-
$q=(double)1;
977+
$q=(float)1;
978978
elseif($q<0)
979-
$q=(double)0;
979+
$q=(float)0;
980980
$accept['params'][$matches[4][$i]]=$q;
981981
}
982982
else
@@ -987,7 +987,7 @@ public static function parseAcceptHeader($header)
987987
}
988988
// q defaults to 1 if not explicitly given
989989
if(!isset($accept['params']['q']))
990-
$accept['params']['q']=(double)1;
990+
$accept['params']['q']=(float)1;
991991
$accepts[] = $accept;
992992
}
993993
}

framework/web/helpers/CJSON.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ public static function decode($str, $useArray=true)
362362
// return (float)$str;
363363

364364
// Return float or int, as appropriate
365-
return ((float)$str == (integer)$str)
366-
? (integer)$str
365+
return ((float)$str == (int)$str)
366+
? (int)$str
367367
: (float)$str;
368368

369369
} elseif (preg_match('/^("|\').+(\1)$/s', $str, $m) && $m[1] == $m[2]) {

framework/yiilite.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,11 +2775,11 @@ public static function parseAcceptHeader($header)
27752775
if($matches[4][$i]==='q')
27762776
{
27772777
// sanity check on q value
2778-
$q=(double)$matches[5][$i];
2778+
$q=(float)$matches[5][$i];
27792779
if($q>1)
2780-
$q=(double)1;
2780+
$q=(float)1;
27812781
elseif($q<0)
2782-
$q=(double)0;
2782+
$q=(float)0;
27832783
$accept['params'][$matches[4][$i]]=$q;
27842784
}
27852785
else
@@ -2790,7 +2790,7 @@ public static function parseAcceptHeader($header)
27902790
}
27912791
// q defaults to 1 if not explicitly given
27922792
if(!isset($accept['params']['q']))
2793-
$accept['params']['q']=(double)1;
2793+
$accept['params']['q']=(float)1;
27942794
$accepts[] = $accept;
27952795
}
27962796
}
@@ -10327,8 +10327,8 @@ public function typecast($value)
1032710327
switch($this->type)
1032810328
{
1032910329
case 'string': return (string)$value;
10330-
case 'integer': return (integer)$value;
10331-
case 'boolean': return (boolean)$value;
10330+
case 'integer': return (int)$value;
10331+
case 'boolean': return (bool)$value;
1033210332
case 'double':
1033310333
default: return $value;
1033410334
}

0 commit comments

Comments
 (0)