mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
feat(#46): get rid of (some) PHP deprecation warnings
- use issets, default local var values, better/newer language constructs
This commit is contained in:
parent
de95041969
commit
cc74b59637
6 changed files with 10 additions and 8 deletions
|
@ -370,6 +370,7 @@ class ContainableBehavior extends ModelBehavior {
|
|||
*/
|
||||
public function fieldDependencies(Model $Model, $map, $fields = array()) {
|
||||
if ($fields === false) {
|
||||
$fields = [];
|
||||
foreach ($map as $parent => $children) {
|
||||
foreach ($children as $type => $bindings) {
|
||||
foreach ($bindings as $dependency) {
|
||||
|
|
|
@ -838,7 +838,7 @@ class Mysql extends DboSource {
|
|||
*/
|
||||
public function value($data, $column = null, $null = true) {
|
||||
$value = parent::value($data, $column, $null);
|
||||
if (is_numeric($value) && substr($column, 0, 3) === 'set') {
|
||||
if (is_numeric($value) && $column !== null && str_starts_with($column, 'set')) {
|
||||
return $this->_connection->quote($value);
|
||||
}
|
||||
return $value;
|
||||
|
|
|
@ -3270,15 +3270,16 @@ class DboSource extends DataSource {
|
|||
}
|
||||
$sign = isset($result[3]);
|
||||
|
||||
if ($length === null) {
|
||||
// prevent deprecation warnings
|
||||
return null;
|
||||
}
|
||||
|
||||
$isFloat = in_array($type, array('dec', 'decimal', 'float', 'numeric', 'double'));
|
||||
if ($isFloat && strpos($length, ',') !== false) {
|
||||
return $length;
|
||||
}
|
||||
|
||||
if ($length === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isset($types[$type])) {
|
||||
return (int)$length;
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ class CakeText {
|
|||
$dataReplacements = array_combine($hashKeys, array_values($data));
|
||||
foreach ($dataReplacements as $tmpHash => $tmpValue) {
|
||||
$tmpValue = (is_array($tmpValue)) ? '' : $tmpValue;
|
||||
$str = str_replace($tmpHash, $tmpValue, $str);
|
||||
$str = str_replace($tmpHash, $tmpValue ?? '', $str);
|
||||
}
|
||||
|
||||
if (!isset($options['format']) && isset($options['before'])) {
|
||||
|
|
|
@ -483,7 +483,7 @@ class Inflector {
|
|||
*/
|
||||
public static function underscore($camelCasedWord) {
|
||||
if (!($result = static::_cache(__FUNCTION__, $camelCasedWord))) {
|
||||
$underscoredWord = preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord);
|
||||
$underscoredWord = preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord ?? '');
|
||||
$result = mb_strtolower($underscoredWord);
|
||||
static::_cache(__FUNCTION__, $camelCasedWord, $result);
|
||||
}
|
||||
|
|
|
@ -573,7 +573,7 @@ class Helper extends CakeObject {
|
|||
if ($setScope === true) {
|
||||
$this->_modelScope = $entity;
|
||||
}
|
||||
$parts = array_values(Hash::filter(explode('.', $entity)));
|
||||
$parts = $entity !== null ? array_values(Hash::filter(explode('.', $entity))) : [];
|
||||
if (empty($parts)) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue