Skip to content

Commit

Permalink
Fixed issue of list() using same variable for PHP-7
Browse files Browse the repository at this point in the history
In PHP 7 the processing is made from right to left instead of left to right, causing an issue when the same variable is used on the list(). See https://wiki.php.net/rfc/abstract_syntax_tree
  • Loading branch information
jrbasso committed Jan 24, 2015
1 parent ca5dee7 commit 4c7af86
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/I18n/Time.php
Expand Up @@ -113,7 +113,8 @@ class Time extends Carbon implements JsonSerializable
public function __construct($time = null, $tz = null)
{
if ($time instanceof \DateTime) {
list($time, $tz) = [$time->format('Y-m-d H:i:s'), $time->getTimeZone()];
$tz = $time->getTimeZone();
$time = $time->format('Y-m-d H:i:s');
}

if (is_numeric($time)) {
Expand Down Expand Up @@ -694,7 +695,8 @@ public static function parseDateTime($time, $format = null)
$timeFormat = $pattern = null;

if (is_array($dateFormat)) {
list($dateFormat, $timeFormat) = $dateFormat;
list($newDateFormat, $timeFormat) = $dateFormat;
$dateFormat = $newDateFormat;
} else {
$pattern = $dateFormat;
$dateFormat = null;
Expand Down

0 comments on commit 4c7af86

Please sign in to comment.