src/YearMonth.php
public function withYear(int $year) : YearMonth
    {
        if ($year === $this->year) {
            return $this;
        }

        Field\Year::check($year);

        return new YearMonth($year, $this->month);
    }
public function withYear(int $year) : YearMonth
    {
        if ($year === $this->year) {
            return $this;
        }

        Field\Year::check($year);

        return new YearMonth($year, $this->month);
    }
public function withYear ( int $ year ) : YearMonth { if ( $ year === $ this -> year ) { return $ this ; } Field \ Year :: check ( $ year ) ; return new YearMonth ( $ year , $ this -> month ) ; }
Returns a copy of this YearMonth with the year altered.

@param int $year

@return YearMonth

@throws DateTimeException If the year is not valid.
Returns a copy of this YearMonth with the year altered .