Skip to content

Commit 89281e6

Browse files
authored
PHP 8.5 compatibility (#264)
* Replace non-canonical cast names deprecated in PHP 8.5 * Add PHP 8.5 to CI workflow
1 parent bfea700 commit 89281e6

File tree

17 files changed

+46
-46
lines changed

17 files changed

+46
-46
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
17+
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
1818

1919
steps:
2020
- name: Checkout
@@ -63,7 +63,7 @@ jobs:
6363

6464
strategy:
6565
matrix:
66-
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
66+
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
6767

6868
steps:
6969
- name: Checkout
@@ -114,7 +114,7 @@ jobs:
114114

115115
strategy:
116116
matrix:
117-
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
117+
php-version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
118118

119119
steps:
120120
- name: Checkout

src/xPDO/Cache/xPDOCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(& $xpdo, $options = array()) {
3636
* @return boolean true if the implementation was initialized successfully.
3737
*/
3838
public function isInitialized() {
39-
return (boolean) $this->initialized;
39+
return (bool) $this->initialized;
4040
}
4141

4242
/**

src/xPDO/Cache/xPDOCacheManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ public function writeFile($filename, $content, $mode= 'wb', $options= array()) {
215215
} else {
216216
$locked = false;
217217
$attempt = 1;
218-
$attempts = (integer) $this->getOption(xPDO::OPT_CACHE_ATTEMPTS, $options, 1);
219-
$attemptDelay = (integer) $this->getOption(xPDO::OPT_CACHE_ATTEMPT_DELAY, $options, 1000);
218+
$attempts = (int) $this->getOption(xPDO::OPT_CACHE_ATTEMPTS, $options, 1);
219+
$attemptDelay = (int) $this->getOption(xPDO::OPT_CACHE_ATTEMPT_DELAY, $options, 1000);
220220
while (!$locked && ($attempts === 0 || $attempt <= $attempts)) {
221221
if ($this->getOption('use_flock', $options, true)) {
222222
$locked = flock($file, LOCK_EX | LOCK_NB);
@@ -466,7 +466,7 @@ public function deleteTree($dirname, $options= array('deleteTop' => false, 'skip
466466
if (!is_array($options)) {
467467
$numArgs = func_num_args();
468468
$options = array(
469-
'deleteTop' => is_scalar($options) ? (boolean) $options : false
469+
'deleteTop' => is_scalar($options) ? (bool) $options : false
470470
,'skipDirs' => $numArgs > 2 ? func_get_arg(2) : false
471471
,'extensions' => $numArgs > 3 ? func_get_arg(3) : array('.cache.php')
472472
);

src/xPDO/Cache/xPDOFileCache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function set($key, $var, $expire= 0, $options= array()) {
5656
$expireContent= 'if(time() > ' . $expirationTS . '){return null;}';
5757
}
5858
$fileName= $this->getCacheKey($key, $options);
59-
$format = (integer) $this->getOption(xPDO::OPT_CACHE_FORMAT, $options, xPDOCacheManager::CACHE_PHP);
59+
$format = (int) $this->getOption(xPDO::OPT_CACHE_FORMAT, $options, xPDOCacheManager::CACHE_PHP);
6060
switch ($format) {
6161
case xPDOCacheManager::CACHE_SERIALIZE:
6262
$content= serialize(array('expires' => $expirationTS, 'content' => $var));
@@ -107,7 +107,7 @@ public function get($key, $options= array()) {
107107
$cacheKey= $this->getCacheKey($key, $options);
108108
if (file_exists($cacheKey)) {
109109
if ($file = @fopen($cacheKey, 'rb')) {
110-
$format = (integer) $this->getOption(xPDO::OPT_CACHE_FORMAT, $options, xPDOCacheManager::CACHE_PHP);
110+
$format = (int) $this->getOption(xPDO::OPT_CACHE_FORMAT, $options, xPDOCacheManager::CACHE_PHP);
111111
if (flock($file, LOCK_SH)) {
112112
switch ($format) {
113113
case xPDOCacheManager::CACHE_PHP:

src/xPDO/Cache/xPDOMemCache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public function __construct(& $xpdo, $options = array()) {
3131
$servers = explode(',', $this->getOption($this->key . '_memcached_server', $options, $this->getOption('memcached_server', $options, 'localhost:11211')));
3232
foreach ($servers as $server) {
3333
$server = explode(':', $server);
34-
$this->memcache->addServer($server[0], (integer) $server[1]);
34+
$this->memcache->addServer($server[0], (int) $server[1]);
3535
}
3636
$compressThreshold = $this->getOption($this->key . '_memcached_compress_threshold', $options, $this->getOption('memcached_compress_threshold', array(), '20000:0.2'));
3737
if (!empty($compressThreshold)) {
3838
$threshold = explode(':', $compressThreshold);
3939
if (count($threshold) == 2) {
40-
$minValue = (integer) $threshold[0];
40+
$minValue = (int) $threshold[0];
4141
$minSaving = (float) $threshold[1];
4242
if ($minSaving >= 0 && $minSaving <= 1) {
4343
$this->memcache->setCompressThreshold($minValue, $minSaving);

src/xPDO/Cache/xPDOMemCached.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public function __construct(& $xpdo, $options = array()) {
3131
$servers = explode(',', $this->getOption($this->key . '_memcached_server', $options, $this->getOption('memcached_server', $options, 'localhost:11211')));
3232
foreach ($servers as $server) {
3333
$server = explode(':', $server);
34-
$this->memcached->addServer($server[0], (integer) $server[1]);
34+
$this->memcached->addServer($server[0], (int) $server[1]);
3535
}
36-
$this->memcached->setOption(Memcached::OPT_COMPRESSION, (boolean) $this->getOption($this->key . '_memcached_compression', $options, $this->getOption('memcached_compression', $options, $this->getOption(Memcached::OPT_COMPRESSION, $options, true))));
36+
$this->memcached->setOption(Memcached::OPT_COMPRESSION, (bool) $this->getOption($this->key . '_memcached_compression', $options, $this->getOption('memcached_compression', $options, $this->getOption(Memcached::OPT_COMPRESSION, $options, true))));
3737
$this->initialized = true;
3838
} else {
3939
$this->memcached = null;

src/xPDO/Cache/xPDORedisCache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ public function __construct(&$xpdo, $options = [])
3838
$this->getOption('redis_server', $options, 'localhost:6379')
3939
)
4040
);
41-
if ($this->redis->pconnect($server[0], (integer)$server[1])) {
41+
if ($this->redis->pconnect($server[0], (int)$server[1])) {
4242
$redis_auth = $this->getOption('redis_auth', $options, '');
4343
if (!empty($redis_auth)) {
4444
$this->redis->auth($redis_auth);
4545
}
46-
$this->redis->select((integer)$this->getOption('redis_db', $options, 0));
46+
$this->redis->select((int)$this->getOption('redis_db', $options, 0));
4747
$this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
4848
$this->initialized = true;
4949
}

src/xPDO/Om/sqlsrv/xPDOQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function parseConditions($conditions, $conjunction = xPDOQuery::SQL_AND)
100100
foreach ($val as $v) {
101101
switch ($type) {
102102
case \PDO::PARAM_INT:
103-
$vals[] = (integer) $v;
103+
$vals[] = (int) $v;
104104
break;
105105
case \PDO::PARAM_STR:
106106
$vals[] = $this->xpdo->quote($v);

src/xPDO/Om/xPDOGenerator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,12 @@ abstract public function writeSchema(string $schemaFile, string $package = '', s
240240
public function parseSchema($schemaFile, $outputDir= '', $options = array()) {
241241
$this->_reset();
242242
if (!is_array($options)) {
243-
$compile = (boolean) $options;
243+
$compile = (bool) $options;
244244
} else {
245-
$compile = array_key_exists('compile', $options) ? (boolean) $options['compile'] : false;
245+
$compile = array_key_exists('compile', $options) ? (bool) $options['compile'] : false;
246246
}
247-
$regenerate = array_key_exists('regenerate', $options) ? (integer) $options['regenerate'] : 0;
248-
$update = array_key_exists('update', $options) ? (integer) $options['update'] : 2;
247+
$regenerate = array_key_exists('regenerate', $options) ? (int) $options['regenerate'] : 0;
248+
$update = array_key_exists('update', $options) ? (int) $options['update'] : 2;
249249
$namespacePrefix = array_key_exists('namespacePrefix', $options) ? trim($options['namespacePrefix'], '\\') : '';
250250

251251
$this->schemaFile= $schemaFile;
@@ -307,7 +307,7 @@ public function parseSchema($schemaFile, $outputDir= '', $options = array()) {
307307
case 'integer':
308308
case 'boolean':
309309
case 'bit':
310-
$fldAttrValue = (integer) $fldAttrValue;
310+
$fldAttrValue = (int) $fldAttrValue;
311311
break;
312312
case 'float':
313313
case 'numeric':

src/xPDO/Om/xPDOObject.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ public static function loadCollection(xPDO & $xpdo, $className, $criteria= null,
460460
if (!$className= $xpdo->loadClass($className)) return $objCollection;
461461
$rows= false;
462462
$fromCache= false;
463-
$collectionCaching = (integer) $xpdo->getOption(xPDO::OPT_CACHE_DB_COLLECTIONS, array(), 1);
463+
$collectionCaching = (int) $xpdo->getOption(xPDO::OPT_CACHE_DB_COLLECTIONS, array(), 1);
464464
if (!is_object($criteria)) {
465465
$criteria= $xpdo->getCriteria($className, $criteria, $cacheFlag);
466466
}
@@ -516,7 +516,7 @@ public static function loadCollectionGraph(xPDO & $xpdo, $className, $graph, $cr
516516
$query->bindGraph($graph);
517517
$rows = array();
518518
$fromCache = false;
519-
$collectionCaching = (integer) $xpdo->getOption(xPDO::OPT_CACHE_DB_COLLECTIONS, array(), 1);
519+
$collectionCaching = (int) $xpdo->getOption(xPDO::OPT_CACHE_DB_COLLECTIONS, array(), 1);
520520
if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag) {
521521
$rows= $xpdo->fromCache($query);
522522
$fromCache = !empty($rows);
@@ -797,7 +797,7 @@ public function set($k, $v= null, $vType= '') {
797797
//type validation
798798
$phptype= $this->_fieldMeta[$k]['phptype'];
799799
$dbtype= $this->_fieldMeta[$k]['dbtype'];
800-
$allowNull= isset($this->_fieldMeta[$k]['null']) ? (boolean) $this->_fieldMeta[$k]['null'] : true;
800+
$allowNull= isset($this->_fieldMeta[$k]['null']) ? (bool) $this->_fieldMeta[$k]['null'] : true;
801801
if ($v === null) {
802802
if ($allowNull) {
803803
$this->_fields[$k]= null;
@@ -813,7 +813,7 @@ public function set($k, $v= null, $vType= '') {
813813
$ts= false;
814814
if (preg_match('/int/i', $dbtype)) {
815815
if (strtolower($vType) == 'integer' || is_int($v) || $v == '0') {
816-
$ts= (integer) $v;
816+
$ts= (int) $v;
817817
} else {
818818
$ts= strtotime($v);
819819
}
@@ -842,7 +842,7 @@ public function set($k, $v= null, $vType= '') {
842842
case 'date' :
843843
if (preg_match('/int/i', $dbtype)) {
844844
if (strtolower($vType) == 'integer' || is_int($v) || $v == '0') {
845-
$ts= (integer) $v;
845+
$ts= (int) $v;
846846
} else {
847847
$ts= strtotime($v);
848848
}
@@ -974,7 +974,7 @@ public function get($k, $format = null, $formatTemplate= null) {
974974
if ($value !== null) {
975975
switch ($fieldType) {
976976
case 'boolean' :
977-
$value= (boolean) $value;
977+
$value= (bool) $value;
978978
break;
979979
case 'integer' :
980980
$value= intval($value);
@@ -1707,8 +1707,8 @@ public function remove(array $ancestors= array ()) {
17071707
array(
17081708
xPDO::OPT_CACHE_KEY => $this->getOption('cache_db_key', null, 'db'),
17091709
xPDO::OPT_CACHE_HANDLER => $this->getOption(xPDO::OPT_CACHE_DB_HANDLER, null, $this->getOption(xPDO::OPT_CACHE_HANDLER, null, 'xPDO\\Cache\\xPDOFileCache')),
1710-
xPDO::OPT_CACHE_FORMAT => (integer) $this->getOption('cache_db_format', null, $this->getOption(xPDO::OPT_CACHE_FORMAT, null, xPDOCacheManager::CACHE_PHP)),
1711-
xPDO::OPT_CACHE_EXPIRES => (integer) $this->getOption(xPDO::OPT_CACHE_DB_EXPIRES, null, $this->getOption(xPDO::OPT_CACHE_EXPIRES, null, 0)),
1710+
xPDO::OPT_CACHE_FORMAT => (int) $this->getOption('cache_db_format', null, $this->getOption(xPDO::OPT_CACHE_FORMAT, null, xPDOCacheManager::CACHE_PHP)),
1711+
xPDO::OPT_CACHE_EXPIRES => (int) $this->getOption(xPDO::OPT_CACHE_DB_EXPIRES, null, $this->getOption(xPDO::OPT_CACHE_EXPIRES, null, 0)),
17121712
xPDO::OPT_CACHE_PREFIX => $this->getOption('cache_db_prefix', null, xPDOCacheManager::CACHE_DIR)
17131713
)
17141714
);
@@ -2402,7 +2402,7 @@ public function setDirty($key= '') {
24022402
* the database.
24032403
*/
24042404
public function isNew() {
2405-
return (boolean) $this->_new;
2405+
return (bool) $this->_new;
24062406
}
24072407

24082408
/**
@@ -2481,7 +2481,7 @@ protected function _setRaw($key, $val) {
24812481
case 'int':
24822482
case 'integer':
24832483
case 'boolean':
2484-
$this->_fields[$key] = (integer) $val;
2484+
$this->_fields[$key] = (int) $val;
24852485
$set = true;
24862486
break;
24872487
case 'float':
@@ -2519,7 +2519,7 @@ protected function _setRaw($key, $val) {
25192519
case 'datetime':
25202520
case 'timestamp':
25212521
if (preg_match('/int/i', $dbtype)) {
2522-
$this->_fields[$key] = (integer) $val;
2522+
$this->_fields[$key] = (int) $val;
25232523
$set = true;
25242524
break;
25252525
}

0 commit comments

Comments
 (0)