If a day has changed, sets the date on the last day of the previous month.

@param   DateTime  $result  A result of months or years addition

@return  DateTime

@since   2.0.0
969944
private function fixMonth(DateTime $result)
	{
		if ($result->format('d') != $this->format('d'))
		{
			$result = $result->subMonths(1);
			$result->datetime->setDate($result->format('Y'), $result->format('m'), $result->format('t'));
		}

		return $result;
	}
569193
private function castResult($result)
    {
        try {
            $result = $this->typeAdapter->toArray($result);
        } catch (TypeCastException $exception) {
            return $result;
        }

        return $result;
    }
1130460
public function setResult($name = null, $result = null)
    {
        if (null === $result) {
            $result = $name;
            array_push($this->results, $result);

            return $this;
        }

        $this->results[(string) $name] = $result;

        return $this;
    }
580183
public function merge(DateLexerResult $result)
    {
        $this->offset = $result->offset;
        $this->data = array_merge($this->data, $result->data);
    }
1192668
public function addMonths($months)
    {
        if($months==0){
            return new DateTime($this->_time);
        }
        $year=$this->getYear();
        $month=$this->getMonth();
        $day=$this->getDay();
        if($months>0){
            $addYears=floor($months/12);
            $addMonths=$months%12;
            while ($addMonths+$month>12){
                $addYears++;
                $addMonths-=12;
            }
            $str=strval($year+$addYears)."-".strval($addMonths+$month)."-01";
            $lastDay = date("t",strtotime($str));//当月的最后一天
            if($day>$lastDay){
                $day=$lastDay;
            }
            $str=strval($year+$addYears)."-".strval($addMonths+$month)."-".$day." ".date("H:i:s",$this->_time);
            return new DateTime(strtotime($str));
        }else{
            $months=abs($months);
            $addYears=floor($months/12);
            $addMonths=$months%12;
            while($month-$addMonths<=0){
                $addYears++;
                $addMonths-=12;
            }
            $str=strval($year-$addYears)."-".strval($month-$addMonths)."-01";
            $lastDay = date("t",strtotime($str));//当月的最后一天
            if($day>$lastDay){
                $day=$lastDay;
            }
            $str=strval($year-$addYears)."-".strval($month-$addMonths)."-".$day." ".date("H:i:s",$this->_time);
            return new DateTime(strtotime($str));
        }
    }
1189151
public function setLastModified(\DateTime $date = null): self
    {
        if (null === $date) {
            $this->header->remove('Last-Modified');
        } else {
            $date = clone $date;
            $date->setTimezone(new \DateTimeZone('UTC'));
            $this->header->set('Last-Modified', $date->format('D, d M Y H:i:s') . ' GMT');
        }

        return $this;
    }
589494
public function setResults($results)
    {
        // hydrate model
        foreach ($results as $entry) {
            /** @var EntityDataModel $model */
            $model = $this->getModel();
            $model->setEntityManager($this->getEntityManager());

            // check for json
            if (array_key_exists('[json]', $entry)) {
                $entry = json_decode($entry['[json]']);
            }

            $model = $this->populate($entry, $model);

            $this->collection[] = $model;
        }

        $this->setCount(count($this->collection));

        return $this;
    }
317340
public function setLastModified(\DateTimeInterface $date = null)
    {
        if (null === $date) {
            $this->headers->remove('Last-Modified');

            return $this;
        }

        if ($date instanceof \DateTime) {
            $date = \DateTimeImmutable::createFromMutable($date);
        }

        $date = $date->setTimezone(new \DateTimeZone('UTC'));
        $this->headers->set('Last-Modified', $date->format('D, d M Y H:i:s').' GMT');

        return $this;
    }
378676
public function setPeriod(\DateTime $start = null, \DateTime $end = null)
    {
        $this->claims['nbf'] = $start->getTimestamp();
        $this->claims['exp'] = $end->getTimestamp();

        return $this;
    }
601501
public function addResult(Result $result): self
    {
        $handler = $result->getHandlerName();
        $this->results[$handler][] = $result;

        return $this;
    }
155786
public function create(Result $result)
    {
        $this->om->persist($result);
        $this->om->flush();

        return $result;
    }
604459
private function parseQueryResult($result = [])
    {
        $rdsDeliveryExecution = new RdsDeliveryExecution($this);

        if (array_key_exists(self::COLUMN_ID, $result)) {
            $rdsDeliveryExecution->setIdentifier($result[self::COLUMN_ID]);
        }

        if (array_key_exists(self::COLUMN_LABEL, $result)) {
            $rdsDeliveryExecution->setLabel($result[self::COLUMN_LABEL]);
        }

        if (array_key_exists(self::COLUMN_DELIVERY_ID, $result)) {
            $rdsDeliveryExecution->setDelivery($result[self::COLUMN_DELIVERY_ID]);
        }

        if (array_key_exists(self::COLUMN_STATUS, $result)) {
            $rdsDeliveryExecution->setState($result[self::COLUMN_STATUS]);
        }

        if (array_key_exists(self::COLUMN_USER_ID, $result)) {
            $rdsDeliveryExecution->setUserIdentifier($result[self::COLUMN_USER_ID]);
        }

        if (array_key_exists(self::COLUMN_STARTED_AT, $result)) {
            $rdsDeliveryExecution->setStartTime(new \DateTime($result[self::COLUMN_STARTED_AT]));
        }

        if (array_key_exists(self::COLUMN_FINISHED_AT, $result)) {
            $rdsDeliveryExecution->setFinishTime(new \DateTime($result[self::COLUMN_FINISHED_AT]));
        }

        return $this->propagate(new DeliveryExecution($rdsDeliveryExecution));
    }
821609
public function when($result)
    {
        if (\is_callable($result)) {
            $result = $result();
        }

        if ($this->can_proceed() && $result !== true) {
            $this->shortcircuit = true;
        }

        return $this;
    }
756885
public function setDateStatusChanged($date_status_changed){
        if(!$this->setModified('date_status_changed', $date_status_changed)->isModified()){
            return $this;
        }
        $this->date_status_changed = $date_status_changed;

        return $this;
    }
1305192
@Override
  public FutureResultImpl<T> setResult(T result) {
    this.result = result;
    succeeded = true;
    checkCallHandler();
    return this;
  }
790386
protected function datesToISO8601(array $result, Model $model)
    {
        $dateFields = $model->getDates();
        if ($dateFields && count($dateFields) > 0) {
            foreach ($dateFields as $field) {
                $value = $model->getAttributeValue($field);
                $result[$field] = $value ? $value->format($this->defaultDateTimeFormat) : $value;
            }
        }

        return $result;
    }
657364
public function setDateBirth($date_birth){
        if(!$this->setModified('date_birth', $date_birth)->isModified()){
            return $this;
        }
        $this->date_birth = $date_birth;

        return $this;
    }