mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-22 06:47:19 +00:00
Fix some deprecation warnings (#64)
* Fix PHP 8.1 deprecation warnings on Helper and FormHelper - fix deprecation warning when Helper::_entityPath is null - fix `strftime` function deprecation warning on FormHelper::_getDateTimeValue method ref: ARCH-11 * Switch deprecated utf8_encode function to mb_convert_encoding function ref: ARCH-13 * Hide strftime deprecation warning Since CakePHP 2 doesn't require the installation of `intl` PHP extension in it's documentation, I can't use the alternative `IntlDateFormatter::format` because it relies such extension. ref: ARCH-13 * Roll back the use of strftime ref: ARCH-11 * Fix preg_split subject param null deprecated on FormHelper::dateTime * Fix preg_split deprecated null param limit on CakeResponse::checkNotModified * fix: get rid of (some) PHP deprecation warnings - CakeResponse.php strotime() and preg_split() warnings * Ignore hide srtftime function deprecation warning from PHPCS * Fix typo on phpcs ignore comments --------- Co-authored-by: Jan Pešek <jan@sinch.cz>
This commit is contained in:
parent
a83e9c77bb
commit
32459b11b6
6 changed files with 35 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -10,6 +10,7 @@
|
||||||
/dist
|
/dist
|
||||||
/tags
|
/tags
|
||||||
*.mo
|
*.mo
|
||||||
|
.phpunit.result.cache
|
||||||
|
|
||||||
# IDE and editor specific files #
|
# IDE and editor specific files #
|
||||||
#################################
|
#################################
|
||||||
|
|
10
Makefile
Normal file
10
Makefile
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
.PHONY: bash up down
|
||||||
|
|
||||||
|
up:
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
down:
|
||||||
|
docker-compose down -v
|
||||||
|
|
||||||
|
bash:
|
||||||
|
docker-compose exec web bash
|
|
@ -279,7 +279,9 @@ class CakeTimeTest extends CakeTestCase {
|
||||||
$this->assertEquals('on 2007-09-25', $result);
|
$this->assertEquals('on 2007-09-25', $result);
|
||||||
|
|
||||||
$result = $this->Time->timeAgoInWords('2007-9-25', '%x');
|
$result = $this->Time->timeAgoInWords('2007-9-25', '%x');
|
||||||
$this->assertEquals('on ' . strftime('%x', strtotime('2007-9-25')), $result);
|
// @codingStandardsIgnoreStart
|
||||||
|
$this->assertEquals('on ' . @strftime('%x', strtotime('2007-9-25')), $result);
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
|
|
||||||
$result = $this->Time->timeAgoInWords(
|
$result = $this->Time->timeAgoInWords(
|
||||||
strtotime('+2 weeks +2 days'),
|
strtotime('+2 weeks +2 days'),
|
||||||
|
@ -303,7 +305,9 @@ class CakeTimeTest extends CakeTestCase {
|
||||||
strtotime('+2 months +2 days'),
|
strtotime('+2 months +2 days'),
|
||||||
array('end' => '1 month', 'format' => '%x')
|
array('end' => '1 month', 'format' => '%x')
|
||||||
);
|
);
|
||||||
$this->assertEquals('on ' . strftime('%x', strtotime('+2 months +2 days')), $result);
|
// @codingStandardsIgnoreStart
|
||||||
|
$this->assertEquals('on ' . @strftime('%x', strtotime('+2 months +2 days')), $result);
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1174,7 +1178,9 @@ class CakeTimeTest extends CakeTestCase {
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$result = $this->Time->i18nFormat($time, '%c');
|
$result = $this->Time->i18nFormat($time, '%c');
|
||||||
$expected = 'jue 14 ene 2010 13:59:28 ' . utf8_encode(strftime('%Z', $time));
|
// @codingStandardsIgnoreStart
|
||||||
|
$expected = 'jue 14 ene 2010 13:59:28 ' . mb_convert_encoding(@strftime('%Z', $time), 'UTF-8', 'ISO-8859-1');
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x');
|
$result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x');
|
||||||
|
@ -1188,7 +1194,9 @@ class CakeTimeTest extends CakeTestCase {
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$result = $this->Time->i18nFormat($time, '%c');
|
$result = $this->Time->i18nFormat($time, '%c');
|
||||||
$expected = 'mié 13 ene 2010 13:59:28 ' . utf8_encode(strftime('%Z', $time));
|
// @codingStandardsIgnoreStart
|
||||||
|
$expected = 'mié 13 ene 2010 13:59:28 ' . mb_convert_encoding(@strftime('%Z', $time), 'UTF-8', 'ISO-8859-1');
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x');
|
$result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x');
|
||||||
|
|
|
@ -1167,7 +1167,9 @@ class CakeTime {
|
||||||
* @return string formatted string with correct encoding.
|
* @return string formatted string with correct encoding.
|
||||||
*/
|
*/
|
||||||
protected static function _strftime($format, $timestamp) {
|
protected static function _strftime($format, $timestamp) {
|
||||||
$format = strftime($format, $timestamp);
|
// @codingStandardsIgnoreStart
|
||||||
|
$format = @strftime($format, $timestamp);
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
$encoding = Configure::read('App.encoding');
|
$encoding = Configure::read('App.encoding');
|
||||||
if (!empty($encoding) && $encoding === 'UTF-8') {
|
if (!empty($encoding) && $encoding === 'UTF-8') {
|
||||||
if (function_exists('mb_check_encoding')) {
|
if (function_exists('mb_check_encoding')) {
|
||||||
|
@ -1176,7 +1178,7 @@ class CakeTime {
|
||||||
$valid = Multibyte::checkMultibyte($format);
|
$valid = Multibyte::checkMultibyte($format);
|
||||||
}
|
}
|
||||||
if (!$valid) {
|
if (!$valid) {
|
||||||
$format = utf8_encode($format);
|
$format = mb_convert_encoding($format, 'UTF-8', 'ISO-8859-1');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $format;
|
return $format;
|
||||||
|
|
|
@ -632,7 +632,7 @@ class Helper extends CakeObject {
|
||||||
* @return array An array containing the identity elements of an entity
|
* @return array An array containing the identity elements of an entity
|
||||||
*/
|
*/
|
||||||
public function entity() {
|
public function entity() {
|
||||||
return explode('.', $this->_entityPath);
|
return explode('.', (string)$this->_entityPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2708,7 +2708,7 @@ class FormHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
$selects = array();
|
$selects = array();
|
||||||
foreach (preg_split('//', $dateFormat, -1, PREG_SPLIT_NO_EMPTY) as $char) {
|
foreach (preg_split('//', (string)$dateFormat, -1, PREG_SPLIT_NO_EMPTY) as $char) {
|
||||||
switch ($char) {
|
switch ($char) {
|
||||||
case 'Y':
|
case 'Y':
|
||||||
$attrs['Year']['value'] = $year;
|
$attrs['Year']['value'] = $year;
|
||||||
|
@ -2767,7 +2767,9 @@ class FormHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($value)) {
|
if (is_numeric($value)) {
|
||||||
$value = strftime('%Y-%m-%d %H:%M:%S', $value);
|
// @codingStandardsIgnoreStart
|
||||||
|
$value = @strftime('%Y-%m-%d %H:%M:%S', $value);
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
}
|
}
|
||||||
$meridian = 'am';
|
$meridian = 'am';
|
||||||
$pos = strpos($value, '-');
|
$pos = strpos($value, '-');
|
||||||
|
@ -3021,7 +3023,9 @@ class FormHelper extends AppHelper {
|
||||||
$data = $options['monthNames'];
|
$data = $options['monthNames'];
|
||||||
} else {
|
} else {
|
||||||
for ($m = 1; $m <= 12; $m++) {
|
for ($m = 1; $m <= 12; $m++) {
|
||||||
$data[sprintf("%02s", $m)] = strftime("%m", mktime(1, 1, 1, $m, 1, 1999));
|
// @codingStandardsIgnoreStart
|
||||||
|
$data[sprintf("%02s", $m)] = @strftime("%m", mktime(1, 1, 1, $m, 1, 1999));
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue