Cake\Chronos\Traits\ModifierTrait::setDate PHP Method

setDate() public method

Workaround for a PHP bug related to the first day of a month
See also: https://bugs.php.net/bug.php?id=63863
public setDate ( integer $year, integer $month, integer $day ) : static
$year integer The year to set.
$month integer The month to set.
$day integer The day to set.
return static
    public function setDate($year, $month, $day)
    {
        // Workaround for PHP issue.
        $date = $this->modify('+0 day');
        if ($this instanceof DateTimeImmutable) {
            // Reflection is necessary to access the parent method
            // of the immutable object
            $method = new \ReflectionMethod('DateTimeImmutable', 'setDate');
            return $method->invoke($date, $year, $month, $day);
        }
        return parent::setDate($year, $month, $day);
    }