Skip to content

Commit

Permalink
PHP error messages lose '.' in PHP 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fisharebest committed Jan 16, 2018
1 parent 427cfd2 commit d30c982
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,9 @@
CHANGE LOG
==========

## 2.4.0 (2018-01-15)
- PHP error messages changed slightly in 7.2.0

## 2.3.1 (2018-01-15)
- Update PHPdoc to use int/bool instead of integer/boolean

Expand Down
12 changes: 9 additions & 3 deletions src/Shim.php
Expand Up @@ -196,7 +196,9 @@ private static function calDaysInMonthCalendar(CalendarInterface $calendar, $yea
try {
return $calendar->daysInMonth($year, $month);
} catch (InvalidArgumentException $ex) {
return trigger_error('invalid date.', E_USER_WARNING);
$error_msg = PHP_VERSION_ID < 70200 ? 'invalid date.' : 'invalid date';

return trigger_error($error_msg, E_USER_WARNING);
}
}

Expand All @@ -214,7 +216,9 @@ private static function calDaysInMonthFrench($year, $month) {
if ($month == 13 && $year == 14 && self::shouldEmulateBug67976()) {
return -2380948;
} elseif ($year > 14) {
return trigger_error('invalid date.', E_USER_WARNING);
$error_msg = PHP_VERSION_ID < 70200 ? 'invalid date.' : 'invalid date';

return trigger_error($error_msg, E_USER_WARNING);
} else {
return self::calDaysInMonthCalendar(self::$french_calendar, $year, $month);
}
Expand Down Expand Up @@ -648,7 +652,9 @@ public static function jdToGregorian($julian_day) {
public static function jdToJewish($julian_day, $hebrew, $fl) {
if ($hebrew) {
if ($julian_day < 347998 || $julian_day > 4000075) {
return trigger_error('Year out of range (0-9999).', E_USER_WARNING);
$error_msg = PHP_VERSION_ID < 70200 ? 'Year out of range (0-9999).' : 'Year out of range (0-9999)';

return trigger_error($error_msg, E_USER_WARNING);
}

return self::$jewish_calendar->jdToHebrew(
Expand Down
48 changes: 24 additions & 24 deletions test/ShimTest.php
Expand Up @@ -132,7 +132,7 @@ public function testCalDaysInMonthFrenchBug67976() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthFrenchInvalidMonth1() {
Expand All @@ -143,7 +143,7 @@ public function testCalDaysInMonthFrenchInvalidMonth1() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthFrenchInvalidMonth2() {
Expand All @@ -154,7 +154,7 @@ public function testCalDaysInMonthFrenchInvalidMonth2() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthFrenchZeroYear1() {
Expand All @@ -165,7 +165,7 @@ public function testCalDaysInMonthFrenchZeroYear1() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthFrenchZeroYear2() {
Expand All @@ -176,7 +176,7 @@ public function testCalDaysInMonthFrenchZeroYear2() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthFrenchNegativeYear1() {
Expand All @@ -187,7 +187,7 @@ public function testCalDaysInMonthFrenchNegativeYear1() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthFrenchNegativeYear2() {
Expand All @@ -198,7 +198,7 @@ public function testCalDaysInMonthFrenchNegativeYear2() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthFrenchHighYear1() {
Expand All @@ -209,7 +209,7 @@ public function testCalDaysInMonthFrenchHighYear1() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthFrenchHighYear2() {
Expand Down Expand Up @@ -237,7 +237,7 @@ public function testCalDaysInMonthGregorian() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthGregorianInvalidMonth1() {
Expand All @@ -248,7 +248,7 @@ public function testCalDaysInMonthGregorianInvalidMonth1() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthGregorianInvalidMonth2() {
Expand All @@ -259,7 +259,7 @@ public function testCalDaysInMonthGregorianInvalidMonth2() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthGregorianInvalidYear1() {
Expand All @@ -270,7 +270,7 @@ public function testCalDaysInMonthGregorianInvalidYear1() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthGregorianInvalidYear2() {
Expand Down Expand Up @@ -313,7 +313,7 @@ public function testCalDaysInMonthJewish() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthJewishInvalidMonth1() {
Expand All @@ -324,7 +324,7 @@ public function testCalDaysInMonthJewishInvalidMonth1() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthJewishInvalidMonth2() {
Expand All @@ -335,7 +335,7 @@ public function testCalDaysInMonthJewishInvalidMonth2() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthJewishInvalidYear1() {
Expand All @@ -346,7 +346,7 @@ public function testCalDaysInMonthJewishInvalidYear1() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthJewishInvalidYear2() {
Expand All @@ -357,7 +357,7 @@ public function testCalDaysInMonthJewishInvalidYear2() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthJulianInvalidMonth1() {
Expand All @@ -368,7 +368,7 @@ public function testCalDaysInMonthJulianInvalidMonth1() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthJulianInvalidMonth2() {
Expand All @@ -379,7 +379,7 @@ public function testCalDaysInMonthJulianInvalidMonth2() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthJulianInvalidYear1() {
Expand All @@ -390,7 +390,7 @@ public function testCalDaysInMonthJulianInvalidYear1() {
* Test the implementation of Shim::calDaysInMonth() against cal_days_in_month()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage invalid date.
* @expectedExceptionMessage invalid date
* @return void
*/
public function testCalDaysInMonthJulianInvalidYear2() {
Expand Down Expand Up @@ -1086,7 +1086,7 @@ public function testJdToJewishHebrew() {
* Test the implementation of Shim::calFromJd() against cal_from_jd()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage Year out of range (0-9999).
* @expectedExceptionMessage Year out of range (0-9999)
* @return void
*/
public function testJdToJewishHebrewOutOfRangeLow1() {
Expand All @@ -1100,7 +1100,7 @@ public function testJdToJewishHebrewOutOfRangeLow1() {
* Test the implementation of Shim::calFromJd() against cal_from_jd()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage Year out of range (0-9999).
* @expectedExceptionMessage Year out of range (0-9999)
* @return void
*/
public function testJdToJewishHebrewOutOfRangeLow2() {
Expand All @@ -1114,7 +1114,7 @@ public function testJdToJewishHebrewOutOfRangeLow2() {
* Test the implementation of Shim::calFromJd() against cal_from_jd()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage Year out of range (0-9999).
* @expectedExceptionMessage Year out of range (0-9999)
* @return void
*/
public function testJdToJewishHebrewOutOfRangeHigh1() {
Expand All @@ -1128,7 +1128,7 @@ public function testJdToJewishHebrewOutOfRangeHigh1() {
* Test the implementation of Shim::calFromJd() against cal_from_jd()
*
* @expectedException \PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage Year out of range (0-9999).
* @expectedExceptionMessage Year out of range (0-9999)
* @return void
*/
public function testJdToJewishHebrewOutOfRangeHigh2() {
Expand Down

0 comments on commit d30c982

Please sign in to comment.