From ef0bce6498f673308cfa223df57da76bdb1707de Mon Sep 17 00:00:00 2001 From: Diego Surita Date: Thu, 18 Jan 2024 11:57:59 -0300 Subject: [PATCH 1/9] 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 --- lib/Cake/View/Helper.php | 2 +- lib/Cake/View/Helper/FormHelper.php | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php index 5ed869461..7512e5c89 100644 --- a/lib/Cake/View/Helper.php +++ b/lib/Cake/View/Helper.php @@ -632,7 +632,7 @@ public function setEntity($entity, $setScope = false) { * @return array An array containing the identity elements of an entity */ public function entity() { - return explode('.', $this->_entityPath); + return explode('.', (string)$this->_entityPath); } /** diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 376ce8d39..9cbc156db 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2767,7 +2767,19 @@ protected function _getDateTimeValue($value, $timeFormat) { } if (is_numeric($value)) { - $value = strftime('%Y-%m-%d %H:%M:%S', $value); + try { + $value = datefmt_format( + datefmt_create( + locale: setLocale(LC_TIME, 0), + dateType: \IntlDateFormatter::FULL, + timeType: \IntlDateFormatter::FULL, + pattern: 'yyyy-MM-dd HH:mm:SS' + ), + $value + ); + } catch (\Error) { + $value = date('Y-m-d H:i:s', $value); + } } $meridian = 'am'; $pos = strpos($value, '-'); @@ -3021,7 +3033,19 @@ protected function _generateOptions($name, $options = array()) { $data = $options['monthNames']; } else { for ($m = 1; $m <= 12; $m++) { - $data[sprintf("%02s", $m)] = strftime("%m", mktime(1, 1, 1, $m, 1, 1999)); + try { + $data[sprintf("%02s", $m)] = datefmt_format( + datefmt_create( + locale: setLocale(LC_TIME, 0), + dateType: \IntlDateFormatter::FULL, + timeType: \IntlDateFormatter::FULL, + pattern: 'MM' + ), + mktime(1, 1, 1, $m, 1, 1999) + ); + } catch (\Error) { + $data[sprintf("%02s", $m)] = date('m', mktime(1, 1, 1, $m, 1, 1999)); + } } } break; From 4b62d7fc56e77c78a415f1e55afd81ca8d1c58e3 Mon Sep 17 00:00:00 2001 From: Diego Surita Date: Fri, 19 Jan 2024 11:11:30 -0300 Subject: [PATCH 2/9] Switch deprecated utf8_encode function to mb_convert_encoding function ref: ARCH-13 --- Makefile | 10 ++++++++++ lib/Cake/Test/Case/Utility/CakeTimeTest.php | 4 ++-- lib/Cake/Utility/CakeTime.php | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..e17f27731 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +.PHONY: bash up down + +up: + docker-compose up -d + +down: + docker-compose down -v + +bash: + docker-compose exec web bash diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index c0b738134..2b378b1a6 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -1174,7 +1174,7 @@ public function testI18nFormat() { $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, '%c'); - $expected = 'jue 14 ene 2010 13:59:28 ' . utf8_encode(strftime('%Z', $time)); + $expected = 'jue 14 ene 2010 13:59:28 ' . mb_convert_encoding(strftime('%Z', $time), 'UTF-8', 'ISO-8859-1'); $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x'); @@ -1188,7 +1188,7 @@ public function testI18nFormat() { $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, '%c'); - $expected = 'mié 13 ene 2010 13:59:28 ' . utf8_encode(strftime('%Z', $time)); + $expected = 'mié 13 ene 2010 13:59:28 ' . mb_convert_encoding(strftime('%Z', $time), 'UTF-8', 'ISO-8859-1'); $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x'); diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index 63911bfde..338044202 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -1176,7 +1176,7 @@ protected static function _strftime($format, $timestamp) { $valid = Multibyte::checkMultibyte($format); } if (!$valid) { - $format = utf8_encode($format); + $format = mb_convert_encoding($format, 'UTF-8', 'ISO-8859-1'); } } return $format; From ddecd9a3b59861ecb0a6ebfe8ee456209d7f64b0 Mon Sep 17 00:00:00 2001 From: Diego Surita Date: Fri, 19 Jan 2024 15:10:27 -0300 Subject: [PATCH 3/9] 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 --- .gitignore | 1 + lib/Cake/Test/Case/Utility/CakeTimeTest.php | 8 ++++---- lib/Cake/Utility/CakeTime.php | 2 +- lib/Cake/View/Helper/FormHelper.php | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 4af649de7..afebb500c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ /dist /tags *.mo +.phpunit.result.cache # IDE and editor specific files # ################################# diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index 2b378b1a6..e58291cb5 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -279,7 +279,7 @@ public function testTimeAgoInWordsWithFormat() { $this->assertEquals('on 2007-09-25', $result); $result = $this->Time->timeAgoInWords('2007-9-25', '%x'); - $this->assertEquals('on ' . strftime('%x', strtotime('2007-9-25')), $result); + $this->assertEquals('on ' . @strftime('%x', strtotime('2007-9-25')), $result); $result = $this->Time->timeAgoInWords( strtotime('+2 weeks +2 days'), @@ -303,7 +303,7 @@ public function testTimeAgoInWordsWithFormat() { strtotime('+2 months +2 days'), array('end' => '1 month', 'format' => '%x') ); - $this->assertEquals('on ' . strftime('%x', strtotime('+2 months +2 days')), $result); + $this->assertEquals('on ' . @strftime('%x', strtotime('+2 months +2 days')), $result); } /** @@ -1174,7 +1174,7 @@ public function testI18nFormat() { $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, '%c'); - $expected = 'jue 14 ene 2010 13:59:28 ' . mb_convert_encoding(strftime('%Z', $time), 'UTF-8', 'ISO-8859-1'); + $expected = 'jue 14 ene 2010 13:59:28 ' . mb_convert_encoding(@strftime('%Z', $time), 'UTF-8', 'ISO-8859-1'); $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x'); @@ -1188,7 +1188,7 @@ public function testI18nFormat() { $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, '%c'); - $expected = 'mié 13 ene 2010 13:59:28 ' . mb_convert_encoding(strftime('%Z', $time), 'UTF-8', 'ISO-8859-1'); + $expected = 'mié 13 ene 2010 13:59:28 ' . mb_convert_encoding(@strftime('%Z', $time), 'UTF-8', 'ISO-8859-1'); $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x'); diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index 338044202..fd74b29a6 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -1167,7 +1167,7 @@ public static function listTimezones($filter = null, $country = null, $options = * @return string formatted string with correct encoding. */ protected static function _strftime($format, $timestamp) { - $format = strftime($format, $timestamp); + $format = @strftime($format, $timestamp); $encoding = Configure::read('App.encoding'); if (!empty($encoding) && $encoding === 'UTF-8') { if (function_exists('mb_check_encoding')) { diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 376ce8d39..27dcfcebc 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2767,7 +2767,7 @@ protected function _getDateTimeValue($value, $timeFormat) { } if (is_numeric($value)) { - $value = strftime('%Y-%m-%d %H:%M:%S', $value); + $value = @strftime('%Y-%m-%d %H:%M:%S', $value); } $meridian = 'am'; $pos = strpos($value, '-'); @@ -3021,7 +3021,7 @@ protected function _generateOptions($name, $options = array()) { $data = $options['monthNames']; } else { for ($m = 1; $m <= 12; $m++) { - $data[sprintf("%02s", $m)] = strftime("%m", mktime(1, 1, 1, $m, 1, 1999)); + $data[sprintf("%02s", $m)] = @strftime("%m", mktime(1, 1, 1, $m, 1, 1999)); } } break; From 6fc46bff97918eb3b2003a512e2890f0a4ef65b6 Mon Sep 17 00:00:00 2001 From: Diego Surita Date: Fri, 19 Jan 2024 15:18:32 -0300 Subject: [PATCH 4/9] Roll back the use of strftime ref: ARCH-11 --- lib/Cake/View/Helper/FormHelper.php | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 9cbc156db..376ce8d39 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2767,19 +2767,7 @@ protected function _getDateTimeValue($value, $timeFormat) { } if (is_numeric($value)) { - try { - $value = datefmt_format( - datefmt_create( - locale: setLocale(LC_TIME, 0), - dateType: \IntlDateFormatter::FULL, - timeType: \IntlDateFormatter::FULL, - pattern: 'yyyy-MM-dd HH:mm:SS' - ), - $value - ); - } catch (\Error) { - $value = date('Y-m-d H:i:s', $value); - } + $value = strftime('%Y-%m-%d %H:%M:%S', $value); } $meridian = 'am'; $pos = strpos($value, '-'); @@ -3033,19 +3021,7 @@ protected function _generateOptions($name, $options = array()) { $data = $options['monthNames']; } else { for ($m = 1; $m <= 12; $m++) { - try { - $data[sprintf("%02s", $m)] = datefmt_format( - datefmt_create( - locale: setLocale(LC_TIME, 0), - dateType: \IntlDateFormatter::FULL, - timeType: \IntlDateFormatter::FULL, - pattern: 'MM' - ), - mktime(1, 1, 1, $m, 1, 1999) - ); - } catch (\Error) { - $data[sprintf("%02s", $m)] = date('m', mktime(1, 1, 1, $m, 1, 1999)); - } + $data[sprintf("%02s", $m)] = strftime("%m", mktime(1, 1, 1, $m, 1, 1999)); } } break; From c033667afe634816872399fecdafefec3757c38d Mon Sep 17 00:00:00 2001 From: Diego Surita Date: Mon, 22 Jan 2024 10:18:52 -0300 Subject: [PATCH 5/9] Fix preg_split subject param null deprecated on FormHelper::dateTime --- lib/Cake/View/Helper/FormHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 27dcfcebc..3233c614a 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2708,7 +2708,7 @@ public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $a } $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) { case 'Y': $attrs['Year']['value'] = $year; From 541157944b64fc531aa19c78eb503794d9cba7d8 Mon Sep 17 00:00:00 2001 From: Diego Surita Date: Mon, 22 Jan 2024 10:31:38 -0300 Subject: [PATCH 6/9] Fix preg_split deprecated null param limit on CakeResponse::checkNotModified --- lib/Cake/Network/CakeResponse.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index cd24b2aad..8ede7e513 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -1164,7 +1164,11 @@ public function checkNotModified(CakeRequest $request) { $ifNoneMatchHeader = $request->header('If-None-Match'); $etags = array(); if (is_string($ifNoneMatchHeader)) { - $etags = preg_split('/\s*,\s*/', $ifNoneMatchHeader, null, PREG_SPLIT_NO_EMPTY); + $etags = preg_split( + pattern: '/\s*,\s*/', + subject: $ifNoneMatchHeader, + flags: PREG_SPLIT_NO_EMPTY + ); } $modifiedSince = $request->header('If-Modified-Since'); $checks = array(); From d3c0f5c0cab8ab818e4a4c5b5dc52a441209d028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pe=C5=A1ek?= Date: Fri, 19 Jan 2024 14:43:05 +0100 Subject: [PATCH 7/9] fix: get rid of (some) PHP deprecation warnings - CakeResponse.php strotime() and preg_split() warnings --- README.md | 4 ++++ lib/Cake/Network/CakeResponse.php | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 520dfc720..b744ad198 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,10 @@ It means that composer will look at `master` branch of repository configured und ## Changelog +### 2024-01-19 + +- `strotime()` and `preg_split()` in CakeResponse deprecation warning fixes (passing null) + ### 2024-01-11 - `preg_replace` deprecation warning fixes (passing null instead of `string`) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index 8ede7e513..adf0ab72b 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -1164,11 +1164,7 @@ public function checkNotModified(CakeRequest $request) { $ifNoneMatchHeader = $request->header('If-None-Match'); $etags = array(); if (is_string($ifNoneMatchHeader)) { - $etags = preg_split( - pattern: '/\s*,\s*/', - subject: $ifNoneMatchHeader, - flags: PREG_SPLIT_NO_EMPTY - ); + $etags = preg_split('/\s*,\s*/', $ifNoneMatchHeader, 0, PREG_SPLIT_NO_EMPTY); } $modifiedSince = $request->header('If-Modified-Since'); $checks = array(); @@ -1176,7 +1172,11 @@ public function checkNotModified(CakeRequest $request) { $checks[] = in_array('*', $etags) || in_array($responseTag, $etags); } if ($modifiedSince) { - $checks[] = strtotime($this->modified()) === strtotime($modifiedSince); + if ($this->modified() === null) { + $checks[] = strtotime($modifiedSince) === false; + } else { + $checks[] = strtotime($this->modified()) === strtotime($modifiedSince); + } } if (empty($checks)) { return false; From 2bfe412ad9f12e97c92f6b6ea01e55116767e353 Mon Sep 17 00:00:00 2001 From: Diego Surita Date: Mon, 29 Jan 2024 12:39:43 -0300 Subject: [PATCH 8/9] Ignore hide srtftime function deprecation warning from PHPCS --- lib/Cake/Test/Case/Utility/CakeTimeTest.php | 8 ++++++++ lib/Cake/Utility/CakeTime.php | 4 ++++ lib/Cake/View/Helper/FormHelper.php | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index e58291cb5..e13214872 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -279,7 +279,9 @@ public function testTimeAgoInWordsWithFormat() { $this->assertEquals('on 2007-09-25', $result); $result = $this->Time->timeAgoInWords('2007-9-25', '%x'); + // @codingStandardsIgnoreStart $this->assertEquals('on ' . @strftime('%x', strtotime('2007-9-25')), $result); + // @codingStandardsIgnoreEnd $result = $this->Time->timeAgoInWords( strtotime('+2 weeks +2 days'), @@ -303,7 +305,9 @@ public function testTimeAgoInWordsWithFormat() { strtotime('+2 months +2 days'), array('end' => '1 month', 'format' => '%x') ); + // @codingStandardsIgnoreStart $this->assertEquals('on ' . @strftime('%x', strtotime('+2 months +2 days')), $result); + // @codingStandardsIgnoreEnd } /** @@ -1174,7 +1178,9 @@ public function testI18nFormat() { $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, '%c'); + // @codingStandardIgnoreStart $expected = 'jue 14 ene 2010 13:59:28 ' . mb_convert_encoding(@strftime('%Z', $time), 'UTF-8', 'ISO-8859-1'); + // @codingStandardIgnoreEnd $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x'); @@ -1188,7 +1194,9 @@ public function testI18nFormat() { $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, '%c'); + // @codingStandardIgnoreStart $expected = 'mié 13 ene 2010 13:59:28 ' . mb_convert_encoding(@strftime('%Z', $time), 'UTF-8', 'ISO-8859-1'); + // @codingStandardIgnoreEnd $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x'); diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index fd74b29a6..7c725321a 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -1167,7 +1167,9 @@ public static function listTimezones($filter = null, $country = null, $options = * @return string formatted string with correct encoding. */ protected static function _strftime($format, $timestamp) { + // @codingStandardIgnoreStart $format = @strftime($format, $timestamp); + // @codingStandardIgnoreEnd $encoding = Configure::read('App.encoding'); if (!empty($encoding) && $encoding === 'UTF-8') { if (function_exists('mb_check_encoding')) { @@ -1176,7 +1178,9 @@ protected static function _strftime($format, $timestamp) { $valid = Multibyte::checkMultibyte($format); } if (!$valid) { + // @codingStandardIgnoreStart $format = mb_convert_encoding($format, 'UTF-8', 'ISO-8859-1'); + // @codingStandardIgnoreEnd } } return $format; diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 3233c614a..a3d611a6f 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2767,7 +2767,9 @@ protected function _getDateTimeValue($value, $timeFormat) { } if (is_numeric($value)) { + // @codingStandardIgnoreStart $value = @strftime('%Y-%m-%d %H:%M:%S', $value); + // @codingStandardIgnoreEnd } $meridian = 'am'; $pos = strpos($value, '-'); @@ -3021,7 +3023,9 @@ protected function _generateOptions($name, $options = array()) { $data = $options['monthNames']; } else { for ($m = 1; $m <= 12; $m++) { + // @codingStandardIgnoreStart $data[sprintf("%02s", $m)] = @strftime("%m", mktime(1, 1, 1, $m, 1, 1999)); + // @codingStandardIgnoreEnd } } break; From d2e6ba43002b1f1ed5004be749d4736e88a680f6 Mon Sep 17 00:00:00 2001 From: Diego Surita Date: Mon, 29 Jan 2024 12:53:58 -0300 Subject: [PATCH 9/9] Fix typo on phpcs ignore comments --- lib/Cake/Test/Case/Utility/CakeTimeTest.php | 8 ++++---- lib/Cake/Utility/CakeTime.php | 6 ++---- lib/Cake/View/Helper/FormHelper.php | 8 ++++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index e13214872..f9ce1158c 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -1178,9 +1178,9 @@ public function testI18nFormat() { $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, '%c'); - // @codingStandardIgnoreStart + // @codingStandardsIgnoreStart $expected = 'jue 14 ene 2010 13:59:28 ' . mb_convert_encoding(@strftime('%Z', $time), 'UTF-8', 'ISO-8859-1'); - // @codingStandardIgnoreEnd + // @codingStandardsIgnoreEnd $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x'); @@ -1194,9 +1194,9 @@ public function testI18nFormat() { $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, '%c'); - // @codingStandardIgnoreStart + // @codingStandardsIgnoreStart $expected = 'mié 13 ene 2010 13:59:28 ' . mb_convert_encoding(@strftime('%Z', $time), 'UTF-8', 'ISO-8859-1'); - // @codingStandardIgnoreEnd + // @codingStandardsIgnoreEnd $this->assertEquals($expected, $result); $result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x'); diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index 7c725321a..75fae995e 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -1167,9 +1167,9 @@ public static function listTimezones($filter = null, $country = null, $options = * @return string formatted string with correct encoding. */ protected static function _strftime($format, $timestamp) { - // @codingStandardIgnoreStart + // @codingStandardsIgnoreStart $format = @strftime($format, $timestamp); - // @codingStandardIgnoreEnd + // @codingStandardsIgnoreEnd $encoding = Configure::read('App.encoding'); if (!empty($encoding) && $encoding === 'UTF-8') { if (function_exists('mb_check_encoding')) { @@ -1178,9 +1178,7 @@ protected static function _strftime($format, $timestamp) { $valid = Multibyte::checkMultibyte($format); } if (!$valid) { - // @codingStandardIgnoreStart $format = mb_convert_encoding($format, 'UTF-8', 'ISO-8859-1'); - // @codingStandardIgnoreEnd } } return $format; diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index a3d611a6f..89b7f1127 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2767,9 +2767,9 @@ protected function _getDateTimeValue($value, $timeFormat) { } if (is_numeric($value)) { - // @codingStandardIgnoreStart + // @codingStandardsIgnoreStart $value = @strftime('%Y-%m-%d %H:%M:%S', $value); - // @codingStandardIgnoreEnd + // @codingStandardsIgnoreEnd } $meridian = 'am'; $pos = strpos($value, '-'); @@ -3023,9 +3023,9 @@ protected function _generateOptions($name, $options = array()) { $data = $options['monthNames']; } else { for ($m = 1; $m <= 12; $m++) { - // @codingStandardIgnoreStart + // @codingStandardsIgnoreStart $data[sprintf("%02s", $m)] = @strftime("%m", mktime(1, 1, 1, $m, 1, 1999)); - // @codingStandardIgnoreEnd + // @codingStandardsIgnoreEnd } } break;