mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix some PHP 8.1 deprecation warnings
* Fix passing null to str_replace and preg_replace in HttpSocket * Fix dynamic props usage in ModelValidator * Fix passing null to rawurlencode in CakeRoute
This commit is contained in:
parent
2eeb1f6476
commit
84cfdfb0c3
3 changed files with 6 additions and 5 deletions
|
@ -31,6 +31,7 @@ App::uses('Hash', 'Utility');
|
||||||
* @package Cake.Model
|
* @package Cake.Model
|
||||||
* @link https://book.cakephp.org/2.0/en/data-validation.html
|
* @link https://book.cakephp.org/2.0/en/data-validation.html
|
||||||
*/
|
*/
|
||||||
|
#[\AllowDynamicProperties]
|
||||||
class ModelValidator implements ArrayAccess, IteratorAggregate, Countable {
|
class ModelValidator implements ArrayAccess, IteratorAggregate, Countable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -720,7 +720,7 @@ class HttpSocket extends CakeSocket {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uri['path'] = preg_replace('/^\//', null, $uri['path']);
|
$uri['path'] = preg_replace('/^\//', '', $uri['path']);
|
||||||
$uri['query'] = http_build_query($uri['query'], '', '&');
|
$uri['query'] = http_build_query($uri['query'], '', '&');
|
||||||
$uri['query'] = rtrim($uri['query'], '=');
|
$uri['query'] = rtrim($uri['query'], '=');
|
||||||
$stripIfEmpty = array(
|
$stripIfEmpty = array(
|
||||||
|
@ -732,16 +732,16 @@ class HttpSocket extends CakeSocket {
|
||||||
|
|
||||||
foreach ($stripIfEmpty as $key => $strip) {
|
foreach ($stripIfEmpty as $key => $strip) {
|
||||||
if (empty($uri[$key])) {
|
if (empty($uri[$key])) {
|
||||||
$uriTemplate = str_replace($strip, null, $uriTemplate);
|
$uriTemplate = str_replace($strip, '', $uriTemplate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$defaultPorts = array('http' => 80, 'https' => 443);
|
$defaultPorts = array('http' => 80, 'https' => 443);
|
||||||
if (array_key_exists($uri['scheme'], $defaultPorts) && $defaultPorts[$uri['scheme']] == $uri['port']) {
|
if (array_key_exists($uri['scheme'], $defaultPorts) && $defaultPorts[$uri['scheme']] == $uri['port']) {
|
||||||
$uriTemplate = str_replace(':%port', null, $uriTemplate);
|
$uriTemplate = str_replace(':%port', '', $uriTemplate);
|
||||||
}
|
}
|
||||||
foreach ($uri as $property => $value) {
|
foreach ($uri as $property => $value) {
|
||||||
$uriTemplate = str_replace('%' . $property, $value, $uriTemplate);
|
$uriTemplate = str_replace('%' . $property, (string)$value, $uriTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($uriTemplate === '/*') {
|
if ($uriTemplate === '/*') {
|
||||||
|
|
|
@ -498,7 +498,7 @@ class CakeRoute {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($params['pass'])) {
|
if (is_array($params['pass'])) {
|
||||||
$params['pass'] = implode('/', array_map('rawurlencode', $params['pass']));
|
$params['pass'] = implode('/', array_map(fn($param) => rawurlencode((string)$param), $params['pass']));
|
||||||
}
|
}
|
||||||
|
|
||||||
$namedConfig = Router::namedConfig();
|
$namedConfig = Router::namedConfig();
|
||||||
|
|
Loading…
Reference in a new issue