diff --git a/src/Chronos.php b/src/Chronos.php index a46f1d39..39766845 100644 --- a/src/Chronos.php +++ b/src/Chronos.php @@ -155,29 +155,21 @@ class Chronos extends DateTimeImmutable implements Stringable * * There is a single test now for all date/time classes provided by Chronos. * This aims to emulate stubbing out 'now' which is a single global fact. - * - * @var \Cake\Chronos\Chronos|null */ protected static ?Chronos $testNow = null; /** * Format to use for __toString method when type juggling occurs. - * - * @var string */ protected static string $toStringFormat = self::DEFAULT_TO_STRING_FORMAT; /** * Days of weekend - * - * @var array */ protected static array $weekendDays = [Chronos::SATURDAY, Chronos::SUNDAY]; /** * Names of days of the week. - * - * @var array */ protected static array $days = [ Chronos::MONDAY => 'Monday', @@ -191,37 +183,27 @@ class Chronos extends DateTimeImmutable implements Stringable /** * First day of week - * - * @var int */ protected static int $weekStartsAt = Chronos::MONDAY; /** * Last day of week - * - * @var int */ protected static int $weekEndsAt = Chronos::SUNDAY; /** * Instance of the diff formatting object. - * - * @var \Cake\Chronos\DifferenceFormatterInterface|null */ protected static ?DifferenceFormatterInterface $diffFormatter = null; /** * Regex for relative period. - * - * @var string */ // phpcs:disable Generic.Files.LineLength.TooLong protected static string $relativePattern = '/this|next|last|tomorrow|yesterday|midnight|today|[+-]|first|last|ago/i'; /** * Errors from last time createFromFormat() was called. - * - * @var array|false */ protected static array|false $lastErrors = false; @@ -298,7 +280,6 @@ public function __construct( * parameter of null. * * @param \Cake\Chronos\Chronos|string|null $testNow The instance to use for all future instances. - * @return void */ public static function setTestNow(Chronos|string|null $testNow = null): void { @@ -365,8 +346,6 @@ public static function hasRelativeKeywords(?string $time): bool /** * Get weekend days - * - * @return array */ public static function getWeekendDays(): array { @@ -377,7 +356,6 @@ public static function getWeekendDays(): array * Set weekend days * * @param array $days Which days are 'weekends'. - * @return void */ public static function setWeekendDays(array $days): void { @@ -386,8 +364,6 @@ public static function setWeekendDays(array $days): void /** * Get the first day of week - * - * @return int */ public static function getWeekStartsAt(): int { @@ -398,7 +374,6 @@ public static function getWeekStartsAt(): int * Set the first day of week * * @param int $day The day the week starts with. - * @return void */ public static function setWeekStartsAt(int $day): void { @@ -407,8 +382,6 @@ public static function setWeekStartsAt(int $day): void /** * Get the last day of week - * - * @return int */ public static function getWeekEndsAt(): int { @@ -419,7 +392,6 @@ public static function getWeekEndsAt(): int * Set the last day of week * * @param int $day The day the week ends with. - * @return void */ public static function setWeekEndsAt(int $day): void { @@ -449,7 +421,6 @@ public static function diffFormatter(?DifferenceFormatterInterface $formatter = * Create an instance from a DateTimeInterface * * @param \DateTimeInterface $other The datetime instance to convert. - * @return static */ public static function instance(DateTimeInterface $other): static { @@ -464,7 +435,6 @@ public static function instance(DateTimeInterface $other): static * * @param \Cake\Chronos\ChronosDate|\Cake\Chronos\ChronosTime|\DateTimeInterface|string|int|null $time The strtotime compatible string to parse * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name. - * @return static */ public static function parse( ChronosDate|ChronosTime|DateTimeInterface|string|int|null $time = 'now', @@ -477,7 +447,6 @@ public static function parse( * Get an instance for the current date and time * * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name. - * @return static */ public static function now(DateTimeZone|string|null $timezone = null): static { @@ -488,7 +457,6 @@ public static function now(DateTimeZone|string|null $timezone = null): static * Create an instance for today * * @param \DateTimeZone|string|null $timezone The timezone to use. - * @return static */ public static function today(DateTimeZone|string|null $timezone = null): static { @@ -499,7 +467,6 @@ public static function today(DateTimeZone|string|null $timezone = null): static * Create an instance for tomorrow * * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name the new instance should use. - * @return static */ public static function tomorrow(DateTimeZone|string|null $timezone = null): static { @@ -510,7 +477,6 @@ public static function tomorrow(DateTimeZone|string|null $timezone = null): stat * Create an instance for yesterday * * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name the new instance should use. - * @return static */ public static function yesterday(DateTimeZone|string|null $timezone = null): static { @@ -519,8 +485,6 @@ public static function yesterday(DateTimeZone|string|null $timezone = null): sta /** * Create an instance for the greatest supported date. - * - * @return static */ public static function maxValue(): static { @@ -529,8 +493,6 @@ public static function maxValue(): static /** * Create an instance for the lowest supported date. - * - * @return static */ public static function minValue(): static { @@ -558,7 +520,6 @@ public static function minValue(): static * @param int|null $second The second to create an instance with. * @param int|null $microsecond The microsecond to create an instance with. * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name the new instance should use. - * @return static */ public static function create( ?int $year = null, @@ -602,7 +563,6 @@ public static function create( * @param int|null $month The month to create an instance with. * @param int|null $day The day to create an instance with. * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name the new instance should use. - * @return static */ public static function createFromDate( ?int $year = null, @@ -621,7 +581,6 @@ public static function createFromDate( * @param int|null $second The second to create an instance with. * @param int|null $microsecond The microsecond to create an instance with. * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name the new instance should use. - * @return static */ public static function createFromTime( ?int $hour = null, @@ -639,7 +598,6 @@ public static function createFromTime( * @param string $format The date() compatible format string. * @param string $time The formatted date string to interpret. * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name the new instance should use. - * @return static * @throws \InvalidArgumentException */ public static function createFromFormat( @@ -696,7 +654,6 @@ public static function getLastErrors(): array|false * - timezone * * @param array $values Array of date and time values. - * @return static */ public static function createFromArray(array $values): static { @@ -738,7 +695,6 @@ public static function createFromArray(array $values): static * * @param float|int $timestamp The timestamp to create an instance from. * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name the new instance should use. - * @return static */ public static function createFromTimestamp(float|int $timestamp, DateTimeZone|string|null $timezone = null): static { @@ -751,7 +707,6 @@ public static function createFromTimestamp(float|int $timestamp, DateTimeZone|st * Creates a DateTimeZone from a string or a DateTimeZone * * @param \DateTimeZone|string|null $object The value to convert. - * @return \DateTimeZone */ protected static function safeCreateDateTimeZone(DateTimeZone|string|null $object): DateTimeZone { @@ -777,7 +732,6 @@ protected static function safeCreateDateTimeZone(DateTimeZone|string|null $objec * @param int|null $minutes The minutes to use. * @param int|null $seconds The seconds to use. * @param int|null $microseconds The microseconds to use. - * @return \DateInterval */ public static function createInterval( ?int $years = null, @@ -849,7 +803,6 @@ public static function createInterval( * * @param int|null $value Time unit value * @param int $max Time unit max value - * @return int|null */ protected static function rolloverTime(?int &$value, int $max): ?int { @@ -872,7 +825,6 @@ protected static function rolloverTime(?int &$value, int $max): ?int * @param int $hour The hour to set. * @param int $minute The minute to set. * @param int $second The second to set. - * @return static */ public function setDateTime( int $year, @@ -891,7 +843,6 @@ public function setDateTime( * @param int $year The year to set. * @param int $month The month to set. * @param int $day The day to set. - * @return static */ public function setDate(int $year, int $month, int $day): static { @@ -904,7 +855,6 @@ public function setDate(int $year, int $month, int $day): static * @param int $year Year of the date. * @param int $week Week of the date. * @param int $dayOfWeek Offset from the first day of the week. - * @return static */ public function setISODate(int $year, int $week, int $dayOfWeek = 1): static { @@ -918,7 +868,6 @@ public function setISODate(int $year, int $week, int $dayOfWeek = 1): static * @param int $minutes Minutes of the time * @param int $seconds Seconds of the time * @param int $microseconds Microseconds of the time - * @return static */ public function setTime(int $hours, int $minutes, int $seconds = 0, int $microseconds = 0): static { @@ -929,7 +878,6 @@ public function setTime(int $hours, int $minutes, int $seconds = 0, int $microse * Creates a new instance with date modified according to DateTimeImmutable::modifier(). * * @param string $modifier Date modifier - * @return static * @throws \InvalidArgumentException * @see https://www.php.net/manual/en/datetimeimmutable.modify.php */ @@ -948,7 +896,6 @@ public function modify(string $modifier): static * * @param \DateTimeInterface $target Target instance * @param bool $absolute Whether the interval is forced to be positive - * @return \DateInterval */ public function diff(DateTimeInterface $target, bool $absolute = false): DateInterval { @@ -959,7 +906,6 @@ public function diff(DateTimeInterface $target, bool $absolute = false): DateInt * Returns formatted date string according to DateTimeImmutable::format(). * * @param string $format String format - * @return string */ public function format(string $format): string { @@ -968,8 +914,6 @@ public function format(string $format): string /** * Returns the timezone offset. - * - * @return int */ public function getOffset(): int { @@ -980,7 +924,6 @@ public function getOffset(): int * Sets the date and time based on a Unix timestamp. * * @param int $timestamp Unix timestamp representing the date - * @return static */ public function setTimestamp(int $timestamp): static { @@ -989,8 +932,6 @@ public function setTimestamp(int $timestamp): static /** * Gets the Unix timestamp for this instance. - * - * @return int */ public function getTimestamp(): int { @@ -1001,7 +942,6 @@ public function getTimestamp(): int * Set the instance's timezone from a string or object * * @param \DateTimeZone|string $value The DateTimeZone object or timezone name to use. - * @return static */ public function setTimezone(DateTimeZone|string $value): static { @@ -1010,8 +950,6 @@ public function setTimezone(DateTimeZone|string $value): static /** * Return time zone set for this instance. - * - * @return \DateTimeZone */ public function getTimezone(): DateTimeZone { @@ -1027,7 +965,6 @@ public function getTimezone(): DateTimeZone * Set the time by time string * * @param string $time Time as string. - * @return static */ public function setTimeFromTimeString(string $time): static { @@ -1043,7 +980,6 @@ public function setTimeFromTimeString(string $time): static * Set the instance's timestamp * * @param int $value The timestamp value to set. - * @return static */ public function timestamp(int $value): static { @@ -1054,7 +990,6 @@ public function timestamp(int $value): static * Set the instance's year * * @param int $value The year value. - * @return static */ public function year(int $value): static { @@ -1065,7 +1000,6 @@ public function year(int $value): static * Set the instance's month * * @param int $value The month value. - * @return static */ public function month(int $value): static { @@ -1076,7 +1010,6 @@ public function month(int $value): static * Set the instance's day * * @param int $value The day value. - * @return static */ public function day(int $value): static { @@ -1087,7 +1020,6 @@ public function day(int $value): static * Set the instance's hour * * @param int $value The hour value. - * @return static */ public function hour(int $value): static { @@ -1098,7 +1030,6 @@ public function hour(int $value): static * Set the instance's minute * * @param int $value The minute value. - * @return static */ public function minute(int $value): static { @@ -1109,7 +1040,6 @@ public function minute(int $value): static * Set the instance's second * * @param int $value The seconds value. - * @return static */ public function second(int $value): static { @@ -1120,7 +1050,6 @@ public function second(int $value): static * Set the instance's microsecond * * @param int $value The microsecond value. - * @return static */ public function microsecond(int $value): static { @@ -1143,7 +1072,6 @@ public function microsecond(int $value): static * ``` * * @param int $value The number of years to add. - * @return static */ public function addYears(int $value): static { @@ -1163,7 +1091,6 @@ public function addYears(int $value): static * Has the same behavior as `addYears()`. * * @param int $value The number of years to remove. - * @return static */ public function subYears(int $value): static { @@ -1183,7 +1110,6 @@ public function subYears(int $value): static * ``` * * @param int $value The number of years to add. - * @return static */ public function addYearsWithOverflow(int $value): static { @@ -1196,7 +1122,6 @@ public function addYearsWithOverflow(int $value): static * Has the same behavior as `addYeasrWithOverflow()`. * * @param int $value The number of years to remove. - * @return static */ public function subYearsWithOverflow(int $value): static { @@ -1220,7 +1145,6 @@ public function subYearsWithOverflow(int $value): static * ``` * * @param int $value The number of months to add. - * @return static */ public function addMonths(int $value): static { @@ -1240,7 +1164,6 @@ public function addMonths(int $value): static * Has the same behavior as `addMonths()`. * * @param int $value The number of months to remove. - * @return static */ public function subMonths(int $value): static { @@ -1260,7 +1183,6 @@ public function subMonths(int $value): static * ``` * * @param int $value The number of months to add. - * @return static */ public function addMonthsWithOverflow(int $value): static { @@ -1280,7 +1202,6 @@ public function addMonthsWithOverflow(int $value): static * ``` * * @param int $value The number of months to remove. - * @return static */ public function subMonthsWithOverflow(int $value): static { @@ -1292,7 +1213,6 @@ public function subMonthsWithOverflow(int $value): static * negative $value travels into the past. * * @param int $value The number of days to add. - * @return static */ public function addDays(int $value): static { @@ -1303,7 +1223,6 @@ public function addDays(int $value): static * Remove days from the instance * * @param int $value The number of days to remove. - * @return static */ public function subDays(int $value): static { @@ -1315,7 +1234,6 @@ public function subDays(int $value): static * negative $value travels into the past. * * @param int $value The number of weekdays to add. - * @return static */ public function addWeekdays(int $value): static { @@ -1326,7 +1244,6 @@ public function addWeekdays(int $value): static * Remove weekdays from the instance * * @param int $value The number of weekdays to remove. - * @return static */ public function subWeekdays(int $value): static { @@ -1338,7 +1255,6 @@ public function subWeekdays(int $value): static * negative $value travels into the past. * * @param int $value The number of weeks to add. - * @return static */ public function addWeeks(int $value): static { @@ -1349,7 +1265,6 @@ public function addWeeks(int $value): static * Remove weeks to the instance * * @param int $value The number of weeks to remove. - * @return static */ public function subWeeks(int $value): static { @@ -1361,7 +1276,6 @@ public function subWeeks(int $value): static * negative $value travels into the past. * * @param int $value The number of hours to add. - * @return static */ public function addHours(int $value): static { @@ -1372,7 +1286,6 @@ public function addHours(int $value): static * Remove hours from the instance * * @param int $value The number of hours to remove. - * @return static */ public function subHours(int $value): static { @@ -1384,7 +1297,6 @@ public function subHours(int $value): static * negative $value travels into the past. * * @param int $value The number of minutes to add. - * @return static */ public function addMinutes(int $value): static { @@ -1395,7 +1307,6 @@ public function addMinutes(int $value): static * Remove minutes from the instance * * @param int $value The number of minutes to remove. - * @return static */ public function subMinutes(int $value): static { @@ -1407,7 +1318,6 @@ public function subMinutes(int $value): static * negative $value travels into the past. * * @param int $value The number of seconds to add. - * @return static */ public function addSeconds(int $value): static { @@ -1418,7 +1328,6 @@ public function addSeconds(int $value): static * Remove seconds from the instance * * @param int $value The number of seconds to remove. - * @return static */ public function subSeconds(int $value): static { @@ -1427,8 +1336,6 @@ public function subSeconds(int $value): static /** * Sets the time to 00:00:00 - * - * @return static */ public function startOfDay(): static { @@ -1440,7 +1347,6 @@ public function startOfDay(): static * if `$microseconds` is true. * * @param bool $microseconds Whether to set microseconds - * @return static */ public function endOfDay(bool $microseconds = false): static { @@ -1453,8 +1359,6 @@ public function endOfDay(bool $microseconds = false): static /** * Sets the date to the first day of the month and the time to 00:00:00 - * - * @return static */ public function startOfMonth(): static { @@ -1463,8 +1367,6 @@ public function startOfMonth(): static /** * Sets the date to end of the month and time to 23:59:59 - * - * @return static */ public function endOfMonth(): static { @@ -1473,8 +1375,6 @@ public function endOfMonth(): static /** * Sets the date to the first day of the year and the time to 00:00:00 - * - * @return static */ public function startOfYear(): static { @@ -1483,8 +1383,6 @@ public function startOfYear(): static /** * Sets the date to end of the year and time to 23:59:59 - * - * @return static */ public function endOfYear(): static { @@ -1493,8 +1391,6 @@ public function endOfYear(): static /** * Sets the date to the first day of the decade and the time to 00:00:00 - * - * @return static */ public function startOfDecade(): static { @@ -1505,8 +1401,6 @@ public function startOfDecade(): static /** * Sets the date to end of the decade and time to 23:59:59 - * - * @return static */ public function endOfDecade(): static { @@ -1517,8 +1411,6 @@ public function endOfDecade(): static /** * Sets the date to the first day of the century and the time to 00:00:00 - * - * @return static */ public function startOfCentury(): static { @@ -1531,8 +1423,6 @@ public function startOfCentury(): static /** * Sets the date to end of the century and time to 23:59:59 - * - * @return static */ public function endOfCentury(): static { @@ -1550,8 +1440,6 @@ public function endOfCentury(): static /** * Sets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00 - * - * @return static */ public function startOfWeek(): static { @@ -1565,8 +1453,6 @@ public function startOfWeek(): static /** * Sets the date to end of week (defined in $weekEndsAt) and time to 23:59:59 - * - * @return static */ public function endOfWeek(): static { @@ -1585,7 +1471,6 @@ public function endOfWeek(): static * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function next(?int $dayOfWeek = null): static { @@ -1605,7 +1490,6 @@ public function next(?int $dayOfWeek = null): static * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function previous(?int $dayOfWeek = null): static { @@ -1625,7 +1509,6 @@ public function previous(?int $dayOfWeek = null): static * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function firstOfMonth(?int $dayOfWeek = null): static { @@ -1641,7 +1524,6 @@ public function firstOfMonth(?int $dayOfWeek = null): static * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function lastOfMonth(?int $dayOfWeek = null): static { @@ -1676,7 +1558,6 @@ public function nthOfMonth(int $nth, int $dayOfWeek): static|false * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function firstOfQuarter(?int $dayOfWeek = null): static { @@ -1693,7 +1574,6 @@ public function firstOfQuarter(?int $dayOfWeek = null): static * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function lastOfQuarter(?int $dayOfWeek = null): static { @@ -1730,7 +1610,6 @@ public function nthOfQuarter(int $nth, int $dayOfWeek): static|false * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function firstOfYear(?int $dayOfWeek = null): static { @@ -1746,7 +1625,6 @@ public function firstOfYear(?int $dayOfWeek = null): static * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function lastOfYear(?int $dayOfWeek = null): static { @@ -1776,7 +1654,6 @@ public function nthOfYear(int $nth, int $dayOfWeek): static|false * Determines if the instance is equal to another * * @param \DateTimeInterface $other The instance to compare with. - * @return bool */ public function equals(DateTimeInterface $other): bool { @@ -1787,7 +1664,6 @@ public function equals(DateTimeInterface $other): bool * Determines if the instance is not equal to another * * @param \DateTimeInterface $other The instance to compare with. - * @return bool */ public function notEquals(DateTimeInterface $other): bool { @@ -1798,7 +1674,6 @@ public function notEquals(DateTimeInterface $other): bool * Determines if the instance is greater (after) than another * * @param \DateTimeInterface $other The instance to compare with. - * @return bool */ public function greaterThan(DateTimeInterface $other): bool { @@ -1809,7 +1684,6 @@ public function greaterThan(DateTimeInterface $other): bool * Determines if the instance is greater (after) than or equal to another * * @param \DateTimeInterface $other The instance to compare with. - * @return bool */ public function greaterThanOrEquals(DateTimeInterface $other): bool { @@ -1820,7 +1694,6 @@ public function greaterThanOrEquals(DateTimeInterface $other): bool * Determines if the instance is less (before) than another * * @param \DateTimeInterface $other The instance to compare with. - * @return bool */ public function lessThan(DateTimeInterface $other): bool { @@ -1831,7 +1704,6 @@ public function lessThan(DateTimeInterface $other): bool * Determines if the instance is less (before) or equal to another * * @param \DateTimeInterface $other The instance to compare with. - * @return bool */ public function lessThanOrEquals(DateTimeInterface $other): bool { @@ -1844,7 +1716,6 @@ public function lessThanOrEquals(DateTimeInterface $other): bool * @param \DateTimeInterface $start Start of target range * @param \DateTimeInterface $end End of target range * @param bool $equals Whether to include the beginning and end of range - * @return bool */ public function between(DateTimeInterface $start, DateTimeInterface $end, bool $equals = true): bool { @@ -1865,7 +1736,6 @@ public function between(DateTimeInterface $start, DateTimeInterface $end, bool $ * @param \DateTimeInterface $first The instance to compare with. * @param \DateTimeInterface $second The instance to compare with. * @param \DateTimeInterface ...$others Others instances to compare with. - * @return static */ public function closest(DateTimeInterface $first, DateTimeInterface $second, DateTimeInterface ...$others): static { @@ -1892,7 +1762,6 @@ public function closest(DateTimeInterface $first, DateTimeInterface $second, Dat * @param \DateTimeInterface $first The instance to compare with. * @param \DateTimeInterface $second The instance to compare with. * @param \DateTimeInterface ...$others Others instances to compare with. - * @return static */ public function farthest(DateTimeInterface $first, DateTimeInterface $second, DateTimeInterface ...$others): static { @@ -1917,7 +1786,6 @@ public function farthest(DateTimeInterface $first, DateTimeInterface $second, Da * Get the minimum instance between a given instance (default now) and the current instance. * * @param \DateTimeInterface|null $other The instance to compare with. - * @return static */ public function min(?DateTimeInterface $other = null): static { @@ -1934,7 +1802,6 @@ public function min(?DateTimeInterface $other = null): static * Get the maximum instance between a given instance (default now) and the current instance. * * @param \DateTimeInterface|null $other The instance to compare with. - * @return static */ public function max(?DateTimeInterface $other = null): static { @@ -1951,7 +1818,6 @@ public function max(?DateTimeInterface $other = null): static * Modify the current instance to the average of a given instance (default now) and the current instance. * * @param \DateTimeInterface|null $other The instance to compare with. - * @return static */ public function average(?DateTimeInterface $other = null): static { @@ -1962,8 +1828,6 @@ public function average(?DateTimeInterface $other = null): static /** * Determines if the instance is a weekday - * - * @return bool */ public function isWeekday(): bool { @@ -1972,8 +1836,6 @@ public function isWeekday(): bool /** * Determines if the instance is a weekend day - * - * @return bool */ public function isWeekend(): bool { @@ -1982,8 +1844,6 @@ public function isWeekend(): bool /** * Determines if the instance is yesterday - * - * @return bool */ public function isYesterday(): bool { @@ -1992,8 +1852,6 @@ public function isYesterday(): bool /** * Determines if the instance is today - * - * @return bool */ public function isToday(): bool { @@ -2002,8 +1860,6 @@ public function isToday(): bool /** * Determines if the instance is tomorrow - * - * @return bool */ public function isTomorrow(): bool { @@ -2012,8 +1868,6 @@ public function isTomorrow(): bool /** * Determines if the instance is within the next week - * - * @return bool */ public function isNextWeek(): bool { @@ -2022,8 +1876,6 @@ public function isNextWeek(): bool /** * Determines if the instance is within the last week - * - * @return bool */ public function isLastWeek(): bool { @@ -2032,8 +1884,6 @@ public function isLastWeek(): bool /** * Determines if the instance is within the next month - * - * @return bool */ public function isNextMonth(): bool { @@ -2042,8 +1892,6 @@ public function isNextMonth(): bool /** * Determines if the instance is within the last month - * - * @return bool */ public function isLastMonth(): bool { @@ -2052,8 +1900,6 @@ public function isLastMonth(): bool /** * Determines if the instance is within the next year - * - * @return bool */ public function isNextYear(): bool { @@ -2062,8 +1908,6 @@ public function isNextYear(): bool /** * Determines if the instance is within the last year - * - * @return bool */ public function isLastYear(): bool { @@ -2072,8 +1916,6 @@ public function isLastYear(): bool /** * Determines if the instance is within the first half of year - * - * @return bool */ public function isFirstHalf(): bool { @@ -2082,8 +1924,6 @@ public function isFirstHalf(): bool /** * Determines if the instance is within the second half of year - * - * @return bool */ public function isSecondHalf(): bool { @@ -2092,8 +1932,6 @@ public function isSecondHalf(): bool /** * Determines if the instance is in the future, ie. greater (after) than now - * - * @return bool */ public function isFuture(): bool { @@ -2102,8 +1940,6 @@ public function isFuture(): bool /** * Determines if the instance is in the past, ie. less (before) than now - * - * @return bool */ public function isPast(): bool { @@ -2112,8 +1948,6 @@ public function isPast(): bool /** * Determines if the instance is a leap year - * - * @return bool */ public function isLeapYear(): bool { @@ -2124,7 +1958,6 @@ public function isLeapYear(): bool * Checks if the passed in date is the same day as the instance current day. * * @param \DateTimeInterface $other The instance to check against. - * @return bool */ public function isSameDay(DateTimeInterface $other): bool { @@ -2139,7 +1972,6 @@ public function isSameDay(DateTimeInterface $other): bool * Returns whether the passed in date is the same month and year. * * @param \DateTimeInterface $other The instance to check against. - * @return bool */ public function isSameMonth(DateTimeInterface $other): bool { @@ -2150,7 +1982,6 @@ public function isSameMonth(DateTimeInterface $other): bool * Returns whether passed in date is the same year. * * @param \DateTimeInterface $other The instance to check against. - * @return bool */ public function isSameYear(DateTimeInterface $other): bool { @@ -2159,8 +1990,6 @@ public function isSameYear(DateTimeInterface $other): bool /** * Checks if this day is a Sunday. - * - * @return bool */ public function isSunday(): bool { @@ -2169,8 +1998,6 @@ public function isSunday(): bool /** * Checks if this day is a Monday. - * - * @return bool */ public function isMonday(): bool { @@ -2179,8 +2006,6 @@ public function isMonday(): bool /** * Checks if this day is a Tuesday. - * - * @return bool */ public function isTuesday(): bool { @@ -2189,8 +2014,6 @@ public function isTuesday(): bool /** * Checks if this day is a Wednesday. - * - * @return bool */ public function isWednesday(): bool { @@ -2199,8 +2022,6 @@ public function isWednesday(): bool /** * Checks if this day is a Thursday. - * - * @return bool */ public function isThursday(): bool { @@ -2209,8 +2030,6 @@ public function isThursday(): bool /** * Checks if this day is a Friday. - * - * @return bool */ public function isFriday(): bool { @@ -2219,8 +2038,6 @@ public function isFriday(): bool /** * Checks if this day is a Saturday. - * - * @return bool */ public function isSaturday(): bool { @@ -2229,8 +2046,6 @@ public function isSaturday(): bool /** * Returns true if this object represents a date within the current week - * - * @return bool */ public function isThisWeek(): bool { @@ -2239,8 +2054,6 @@ public function isThisWeek(): bool /** * Returns true if this object represents a date within the current month - * - * @return bool */ public function isThisMonth(): bool { @@ -2249,8 +2062,6 @@ public function isThisMonth(): bool /** * Returns true if this object represents a date within the current year - * - * @return bool */ public function isThisYear(): bool { @@ -2261,7 +2072,6 @@ public function isThisYear(): bool * Check if its the birthday. Compares the date/month values of the two dates. * * @param \DateTimeInterface|null $other The instance to compare with or null to use current day. - * @return bool */ public function isBirthday(?DateTimeInterface $other = null): bool { @@ -2275,7 +2085,6 @@ public function isBirthday(?DateTimeInterface $other = null): bool * * @param string|int $timeInterval the numeric value with space then time type. * Example of valid types: 6 hours, 2 days, 1 minute. - * @return bool */ public function wasWithinLast(string|int $timeInterval): bool { @@ -2291,7 +2100,6 @@ public function wasWithinLast(string|int $timeInterval): bool * * @param string|int $timeInterval the numeric value with space then time type. * Example of valid types: 6 hours, 2 days, 1 minute. - * @return bool */ public function isWithinNext(string|int $timeInterval): bool { @@ -2310,7 +2118,6 @@ public function isWithinNext(string|int $timeInterval): bool * @param \DateTimeInterface|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php} - * @return int */ public function diffFiltered( DateInterval $interval, @@ -2344,7 +2151,6 @@ public function diffFiltered( * * @param \DateTimeInterface|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference - * @return int */ public function diffInYears(?DateTimeInterface $other = null, bool $absolute = true): int { @@ -2358,7 +2164,6 @@ public function diffInYears(?DateTimeInterface $other = null, bool $absolute = t * * @param \DateTimeInterface|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference - * @return int */ public function diffInMonths(?DateTimeInterface $other = null, bool $absolute = true): int { @@ -2378,7 +2183,6 @@ public function diffInMonths(?DateTimeInterface $other = null, bool $absolute = * * @param \DateTimeInterface|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference - * @return int */ public function diffInMonthsIgnoreTimezone(?DateTimeInterface $other = null, bool $absolute = true): int { @@ -2396,7 +2200,6 @@ public function diffInMonthsIgnoreTimezone(?DateTimeInterface $other = null, boo * * @param \DateTimeInterface|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference - * @return int */ public function diffInWeeks(?DateTimeInterface $other = null, bool $absolute = true): int { @@ -2408,7 +2211,6 @@ public function diffInWeeks(?DateTimeInterface $other = null, bool $absolute = t * * @param \DateTimeInterface|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference - * @return int */ public function diffInDays(?DateTimeInterface $other = null, bool $absolute = true): int { @@ -2424,7 +2226,6 @@ public function diffInDays(?DateTimeInterface $other = null, bool $absolute = tr * @param \DateTimeInterface|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php} - * @return int */ public function diffInDaysFiltered( callable $callback, @@ -2442,7 +2243,6 @@ public function diffInDaysFiltered( * @param \DateTimeInterface|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php} - * @return int */ public function diffInHoursFiltered( callable $callback, @@ -2459,7 +2259,6 @@ public function diffInHoursFiltered( * @param \DateTimeInterface|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php} - * @return int */ public function diffInWeekdays(?DateTimeInterface $other = null, bool $absolute = true, int $options = 0): int { @@ -2474,7 +2273,6 @@ public function diffInWeekdays(?DateTimeInterface $other = null, bool $absolute * @param \DateTimeInterface|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php} - * @return int */ public function diffInWeekendDays(?DateTimeInterface $other = null, bool $absolute = true, int $options = 0): int { @@ -2488,7 +2286,6 @@ public function diffInWeekendDays(?DateTimeInterface $other = null, bool $absolu * * @param \DateTimeInterface|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference - * @return int */ public function diffInHours(?DateTimeInterface $other = null, bool $absolute = true): int { @@ -2504,7 +2301,6 @@ public function diffInHours(?DateTimeInterface $other = null, bool $absolute = t * * @param \DateTimeInterface|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference - * @return int */ public function diffInMinutes(?DateTimeInterface $other = null, bool $absolute = true): int { @@ -2516,7 +2312,6 @@ public function diffInMinutes(?DateTimeInterface $other = null, bool $absolute = * * @param \DateTimeInterface|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference - * @return int */ public function diffInSeconds(?DateTimeInterface $other = null, bool $absolute = true): int { @@ -2528,8 +2323,6 @@ public function diffInSeconds(?DateTimeInterface $other = null, bool $absolute = /** * The number of seconds since midnight. - * - * @return int */ public function secondsSinceMidnight(): int { @@ -2538,8 +2331,6 @@ public function secondsSinceMidnight(): int /** * The number of seconds until 23:59:59. - * - * @return int */ public function secondsUntilEndOfDay(): int { @@ -2580,7 +2371,6 @@ public static function fromNow(DateTimeInterface $other): DateInterval|bool * * @param \DateTimeInterface|null $other The datetime to compare with. * @param bool $absolute removes time difference modifiers ago, after, etc - * @return string */ public function diffForHumans(?DateTimeInterface $other = null, bool $absolute = false): string { @@ -2591,8 +2381,6 @@ public function diffForHumans(?DateTimeInterface $other = null, bool $absolute = * Returns a DateTimeImmutable instance * * This method returns a PHP DateTimeImmutable without Chronos extensions. - * - * @return \DateTimeImmutable */ public function toNative(): DateTimeImmutable { @@ -2689,20 +2477,16 @@ public function __isset(string $name): bool /** * Return properties for debugging. - * - * @return array */ public function __debugInfo(): array { /** @var \DateTimeZone $timezone */ $timezone = $this->getTimezone(); - $properties = [ + return [ 'hasFixedNow' => static::hasTestNow(), 'time' => $this->format('Y-m-d H:i:s.u'), 'timezone' => $timezone->getName(), ]; - - return $properties; } } diff --git a/src/ChronosDate.php b/src/ChronosDate.php index 85bad798..a1639c27 100644 --- a/src/ChronosDate.php +++ b/src/ChronosDate.php @@ -57,15 +57,11 @@ class ChronosDate implements Stringable /** * Format to use for __toString method when type juggling occurs. - * - * @var string */ protected static string $toStringFormat = self::DEFAULT_TO_STRING_FORMAT; /** * Names of days of the week. - * - * @var array */ protected static array $days = [ Chronos::MONDAY => 'Monday', @@ -79,21 +75,14 @@ class ChronosDate implements Stringable /** * Instance of the diff formatting object. - * - * @var \Cake\Chronos\DifferenceFormatterInterface|null */ protected static ?DifferenceFormatterInterface $diffFormatter = null; /** * Errors from last time createFromFormat() was called. - * - * @var array|false */ protected static array|false $lastErrors = false; - /** - * @var \DateTimeImmutable - */ protected DateTimeImmutable $native; /** @@ -123,7 +112,6 @@ public function __construct( * * @param \Cake\Chronos\ChronosDate|\DateTimeInterface|string $time Fixed or relative time * @param \DateTimeZone|string|null $timezone The time zone used for 'now' - * @return \DateTimeImmutable */ protected function createNative( ChronosDate|DateTimeInterface|string $time, @@ -155,7 +143,6 @@ protected function createNative( * Get today's date. * * @param \DateTimeZone|string|null $timezone Time zone to use for now. - * @return static */ public static function now(DateTimeZone|string|null $timezone = null): static { @@ -166,7 +153,6 @@ public static function now(DateTimeZone|string|null $timezone = null): static * Get today's date. * * @param \DateTimeZone|string|null $timezone Time zone to use for today. - * @return static */ public static function today(DateTimeZone|string|null $timezone = null): static { @@ -177,7 +163,6 @@ public static function today(DateTimeZone|string|null $timezone = null): static * Get tomorrow's date. * * @param \DateTimeZone|string|null $timezone Time zone to use for tomorrow. - * @return static */ public static function tomorrow(DateTimeZone|string|null $timezone = null): static { @@ -188,7 +173,6 @@ public static function tomorrow(DateTimeZone|string|null $timezone = null): stat * Get yesterday's date. * * @param \DateTimeZone|string|null $timezone Time zone to use for yesterday. - * @return static */ public static function yesterday(DateTimeZone|string|null $timezone = null): static { @@ -202,7 +186,6 @@ public static function yesterday(DateTimeZone|string|null $timezone = null): sta * (new Chronos('Monday next week'))->fn() * * @param \Cake\Chronos\ChronosDate|\DateTimeInterface|string $time The strtotime compatible string to parse - * @return static */ public static function parse(ChronosDate|DateTimeInterface|string $time): static { @@ -215,7 +198,6 @@ public static function parse(ChronosDate|DateTimeInterface|string $time): static * @param int $year The year to create an instance with. * @param int $month The month to create an instance with. * @param int $day The day to create an instance with. - * @return static */ public static function create(int $year, int $month, int $day): static { @@ -232,7 +214,6 @@ public static function create(int $year, int $month, int $day): static * * @param string $format The date() compatible format string. * @param string $time The formatted date string to interpret. - * @return static * @throws \InvalidArgumentException */ public static function createFromFormat( @@ -273,7 +254,6 @@ public static function getLastErrors(): array|false * - day * * @param array $values Array of date and time values. - * @return static */ public static function createFromArray(array $values): static { @@ -345,7 +325,6 @@ public function sub(DateInterval $interval): static * Attempting to change a time component will raise an exception * * @param string $modifier Date modifier - * @return static */ public function modify(string $modifier): static { @@ -373,7 +352,6 @@ public function modify(string $modifier): static * @param int $year The year to set. * @param int $month The month to set. * @param int $day The day to set. - * @return static */ public function setDate(int $year, int $month, int $day): static { @@ -389,7 +367,6 @@ public function setDate(int $year, int $month, int $day): static * @param int $year Year of the date. * @param int $week Week of the date. * @param int $dayOfWeek Offset from the first day of the week. - * @return static */ public function setISODate(int $year, int $week, int $dayOfWeek = 1): static { @@ -404,7 +381,6 @@ public function setISODate(int $year, int $week, int $dayOfWeek = 1): static * * @param \Cake\Chronos\ChronosDate $target Target instance * @param bool $absolute Whether the interval is forced to be positive - * @return \DateInterval */ public function diff(ChronosDate $target, bool $absolute = false): DateInterval { @@ -415,7 +391,6 @@ public function diff(ChronosDate $target, bool $absolute = false): DateInterval * Returns formatted date string according to DateTimeImmutable::format(). * * @param string $format String format - * @return string */ public function format(string $format): string { @@ -426,7 +401,6 @@ public function format(string $format): string * Set the instance's year * * @param int $value The year value. - * @return static */ public function year(int $value): static { @@ -437,7 +411,6 @@ public function year(int $value): static * Set the instance's month * * @param int $value The month value. - * @return static */ public function month(int $value): static { @@ -448,7 +421,6 @@ public function month(int $value): static * Set the instance's day * * @param int $value The day value. - * @return static */ public function day(int $value): static { @@ -471,7 +443,6 @@ public function day(int $value): static * ``` * * @param int $value The number of years to add. - * @return static */ public function addYears(int $value): static { @@ -491,7 +462,6 @@ public function addYears(int $value): static * Has the same behavior as `addYears()`. * * @param int $value The number of years to remove. - * @return static */ public function subYears(int $value): static { @@ -511,7 +481,6 @@ public function subYears(int $value): static * ``` * * @param int $value The number of years to add. - * @return static */ public function addYearsWithOverflow(int $value): static { @@ -524,7 +493,6 @@ public function addYearsWithOverflow(int $value): static * Has the same behavior as `addYeasrWithOverflow()`. * * @param int $value The number of years to remove. - * @return static */ public function subYearsWithOverflow(int $value): static { @@ -548,7 +516,6 @@ public function subYearsWithOverflow(int $value): static * ``` * * @param int $value The number of months to add. - * @return static */ public function addMonths(int $value): static { @@ -568,7 +535,6 @@ public function addMonths(int $value): static * Has the same behavior as `addMonths()`. * * @param int $value The number of months to remove. - * @return static */ public function subMonths(int $value): static { @@ -588,7 +554,6 @@ public function subMonths(int $value): static * ``` * * @param int $value The number of months to add. - * @return static */ public function addMonthsWithOverflow(int $value): static { @@ -608,7 +573,6 @@ public function addMonthsWithOverflow(int $value): static * ``` * * @param int $value The number of months to remove. - * @return static */ public function subMonthsWithOverflow(int $value): static { @@ -620,7 +584,6 @@ public function subMonthsWithOverflow(int $value): static * negative $value travels into the past. * * @param int $value The number of days to add. - * @return static */ public function addDays(int $value): static { @@ -631,7 +594,6 @@ public function addDays(int $value): static * Remove days from the instance * * @param int $value The number of days to remove. - * @return static */ public function subDays(int $value): static { @@ -643,7 +605,6 @@ public function subDays(int $value): static * negative $value travels into the past. * * @param int $value The number of weekdays to add. - * @return static */ public function addWeekdays(int $value): static { @@ -654,7 +615,6 @@ public function addWeekdays(int $value): static * Remove weekdays from the instance * * @param int $value The number of weekdays to remove. - * @return static */ public function subWeekdays(int $value): static { @@ -666,7 +626,6 @@ public function subWeekdays(int $value): static * negative $value travels into the past. * * @param int $value The number of weeks to add. - * @return static */ public function addWeeks(int $value): static { @@ -677,7 +636,6 @@ public function addWeeks(int $value): static * Remove weeks to the instance * * @param int $value The number of weeks to remove. - * @return static */ public function subWeeks(int $value): static { @@ -686,8 +644,6 @@ public function subWeeks(int $value): static /** * Resets the date to the first day of the month - * - * @return static */ public function startOfMonth(): static { @@ -696,8 +652,6 @@ public function startOfMonth(): static /** * Resets the date to end of the month - * - * @return static */ public function endOfMonth(): static { @@ -706,8 +660,6 @@ public function endOfMonth(): static /** * Resets the date to the first day of the year - * - * @return static */ public function startOfYear(): static { @@ -716,8 +668,6 @@ public function startOfYear(): static /** * Resets the date to end of the year - * - * @return static */ public function endOfYear(): static { @@ -726,8 +676,6 @@ public function endOfYear(): static /** * Resets the date to the first day of the decade - * - * @return static */ public function startOfDecade(): static { @@ -738,8 +686,6 @@ public function startOfDecade(): static /** * Resets the date to end of the decade - * - * @return static */ public function endOfDecade(): static { @@ -750,8 +696,6 @@ public function endOfDecade(): static /** * Resets the date to the first day of the century - * - * @return static */ public function startOfCentury(): static { @@ -764,8 +708,6 @@ public function startOfCentury(): static /** * Resets the date to end of the century and time to 23:59:59 - * - * @return static */ public function endOfCentury(): static { @@ -783,8 +725,6 @@ public function endOfCentury(): static /** * Resets the date to the first day of week (defined in $weekStartsAt) - * - * @return static */ public function startOfWeek(): static { @@ -798,8 +738,6 @@ public function startOfWeek(): static /** * Resets the date to end of week (defined in $weekEndsAt) and time to 23:59:59 - * - * @return static */ public function endOfWeek(): static { @@ -818,7 +756,6 @@ public function endOfWeek(): static * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function next(?int $dayOfWeek = null): static { @@ -838,7 +775,6 @@ public function next(?int $dayOfWeek = null): static * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function previous(?int $dayOfWeek = null): static { @@ -858,7 +794,6 @@ public function previous(?int $dayOfWeek = null): static * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function firstOfMonth(?int $dayOfWeek = null): static { @@ -874,7 +809,6 @@ public function firstOfMonth(?int $dayOfWeek = null): static * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function lastOfMonth(?int $dayOfWeek = null): static { @@ -909,7 +843,6 @@ public function nthOfMonth(int $nth, int $dayOfWeek): static|false * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function firstOfQuarter(?int $dayOfWeek = null): static { @@ -926,7 +859,6 @@ public function firstOfQuarter(?int $dayOfWeek = null): static * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function lastOfQuarter(?int $dayOfWeek = null): static { @@ -963,7 +895,6 @@ public function nthOfQuarter(int $nth, int $dayOfWeek): static|false * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function firstOfYear(?int $dayOfWeek = null): static { @@ -979,7 +910,6 @@ public function firstOfYear(?int $dayOfWeek = null): static * to indicate the desired dayOfWeek, ex. Chronos::MONDAY. * * @param int|null $dayOfWeek The day of the week to move to. - * @return static */ public function lastOfYear(?int $dayOfWeek = null): static { @@ -1009,7 +939,6 @@ public function nthOfYear(int $nth, int $dayOfWeek): static|false * Determines if the instance is equal to another * * @param \Cake\Chronos\ChronosDate $other The instance to compare with. - * @return bool */ public function equals(ChronosDate $other): bool { @@ -1020,7 +949,6 @@ public function equals(ChronosDate $other): bool * Determines if the instance is not equal to another * * @param \Cake\Chronos\ChronosDate $other The instance to compare with. - * @return bool */ public function notEquals(ChronosDate $other): bool { @@ -1031,7 +959,6 @@ public function notEquals(ChronosDate $other): bool * Determines if the instance is greater (after) than another * * @param \Cake\Chronos\ChronosDate $other The instance to compare with. - * @return bool */ public function greaterThan(ChronosDate $other): bool { @@ -1042,7 +969,6 @@ public function greaterThan(ChronosDate $other): bool * Determines if the instance is greater (after) than or equal to another * * @param \Cake\Chronos\ChronosDate $other The instance to compare with. - * @return bool */ public function greaterThanOrEquals(ChronosDate $other): bool { @@ -1053,7 +979,6 @@ public function greaterThanOrEquals(ChronosDate $other): bool * Determines if the instance is less (before) than another * * @param \Cake\Chronos\ChronosDate $other The instance to compare with. - * @return bool */ public function lessThan(ChronosDate $other): bool { @@ -1064,7 +989,6 @@ public function lessThan(ChronosDate $other): bool * Determines if the instance is less (before) or equal to another * * @param \Cake\Chronos\ChronosDate $other The instance to compare with. - * @return bool */ public function lessThanOrEquals(ChronosDate $other): bool { @@ -1077,7 +1001,6 @@ public function lessThanOrEquals(ChronosDate $other): bool * @param \Cake\Chronos\ChronosDate $start Start of target range * @param \Cake\Chronos\ChronosDate $end End of target range * @param bool $equals Whether to include the beginning and end of range - * @return bool */ public function between(ChronosDate $start, ChronosDate $end, bool $equals = true): bool { @@ -1098,7 +1021,6 @@ public function between(ChronosDate $start, ChronosDate $end, bool $equals = tru * @param \Cake\Chronos\ChronosDate $first The instance to compare with. * @param \Cake\Chronos\ChronosDate $second The instance to compare with. * @param \Cake\Chronos\ChronosDate ...$others Others instance to compare with. - * @return self */ public function closest(ChronosDate $first, ChronosDate $second, ChronosDate ...$others): ChronosDate { @@ -1121,7 +1043,6 @@ public function closest(ChronosDate $first, ChronosDate $second, ChronosDate ... * @param \Cake\Chronos\ChronosDate $first The instance to compare with. * @param \Cake\Chronos\ChronosDate $second The instance to compare with. * @param \Cake\Chronos\ChronosDate ...$others Others instance to compare with. - * @return self */ public function farthest(ChronosDate $first, ChronosDate $second, ChronosDate ...$others): ChronosDate { @@ -1140,8 +1061,6 @@ public function farthest(ChronosDate $first, ChronosDate $second, ChronosDate .. /** * Determines if the instance is a weekday - * - * @return bool */ public function isWeekday(): bool { @@ -1150,8 +1069,6 @@ public function isWeekday(): bool /** * Determines if the instance is a weekend day - * - * @return bool */ public function isWeekend(): bool { @@ -1162,7 +1079,6 @@ public function isWeekend(): bool * Determines if the instance is yesterday * * @param \DateTimeZone|string|null $timezone Time zone to use for now. - * @return bool */ public function isYesterday(DateTimeZone|string|null $timezone = null): bool { @@ -1173,7 +1089,6 @@ public function isYesterday(DateTimeZone|string|null $timezone = null): bool * Determines if the instance is today * * @param \DateTimeZone|string|null $timezone Time zone to use for now. - * @return bool */ public function isToday(DateTimeZone|string|null $timezone = null): bool { @@ -1184,7 +1099,6 @@ public function isToday(DateTimeZone|string|null $timezone = null): bool * Determines if the instance is tomorrow * * @param \DateTimeZone|string|null $timezone Time zone to use for now. - * @return bool */ public function isTomorrow(DateTimeZone|string|null $timezone = null): bool { @@ -1195,7 +1109,6 @@ public function isTomorrow(DateTimeZone|string|null $timezone = null): bool * Determines if the instance is within the next week * * @param \DateTimeZone|string|null $timezone Time zone to use for now. - * @return bool */ public function isNextWeek(DateTimeZone|string|null $timezone = null): bool { @@ -1206,7 +1119,6 @@ public function isNextWeek(DateTimeZone|string|null $timezone = null): bool * Determines if the instance is within the last week * * @param \DateTimeZone|string|null $timezone Time zone to use for now. - * @return bool */ public function isLastWeek(DateTimeZone|string|null $timezone = null): bool { @@ -1217,7 +1129,6 @@ public function isLastWeek(DateTimeZone|string|null $timezone = null): bool * Determines if the instance is within the next month * * @param \DateTimeZone|string|null $timezone Time zone to use for now. - * @return bool */ public function isNextMonth(DateTimeZone|string|null $timezone = null): bool { @@ -1228,7 +1139,6 @@ public function isNextMonth(DateTimeZone|string|null $timezone = null): bool * Determines if the instance is within the last month * * @param \DateTimeZone|string|null $timezone Time zone to use for now. - * @return bool */ public function isLastMonth(DateTimeZone|string|null $timezone = null): bool { @@ -1239,7 +1149,6 @@ public function isLastMonth(DateTimeZone|string|null $timezone = null): bool * Determines if the instance is within the next year * * @param \DateTimeZone|string|null $timezone Time zone to use for now. - * @return bool */ public function isNextYear(DateTimeZone|string|null $timezone = null): bool { @@ -1250,7 +1159,6 @@ public function isNextYear(DateTimeZone|string|null $timezone = null): bool * Determines if the instance is within the last year * * @param \DateTimeZone|string|null $timezone Time zone to use for now. - * @return bool */ public function isLastYear(DateTimeZone|string|null $timezone = null): bool { @@ -1259,8 +1167,6 @@ public function isLastYear(DateTimeZone|string|null $timezone = null): bool /** * Determines if the instance is within the first half of year - * - * @return bool */ public function isFirstHalf(): bool { @@ -1269,8 +1175,6 @@ public function isFirstHalf(): bool /** * Determines if the instance is within the second half of year - * - * @return bool */ public function isSecondHalf(): bool { @@ -1281,7 +1185,6 @@ public function isSecondHalf(): bool * Determines if the instance is in the future, ie. greater (after) than now * * @param \DateTimeZone|string|null $timezone Time zone to use for now. - * @return bool */ public function isFuture(DateTimeZone|string|null $timezone = null): bool { @@ -1292,7 +1195,6 @@ public function isFuture(DateTimeZone|string|null $timezone = null): bool * Determines if the instance is in the past, ie. less (before) than now * * @param \DateTimeZone|string|null $timezone Time zone to use for now. - * @return bool */ public function isPast(DateTimeZone|string|null $timezone = null): bool { @@ -1301,8 +1203,6 @@ public function isPast(DateTimeZone|string|null $timezone = null): bool /** * Determines if the instance is a leap year - * - * @return bool */ public function isLeapYear(): bool { @@ -1311,8 +1211,6 @@ public function isLeapYear(): bool /** * Checks if this day is a Sunday. - * - * @return bool */ public function isSunday(): bool { @@ -1321,8 +1219,6 @@ public function isSunday(): bool /** * Checks if this day is a Monday. - * - * @return bool */ public function isMonday(): bool { @@ -1331,8 +1227,6 @@ public function isMonday(): bool /** * Checks if this day is a Tuesday. - * - * @return bool */ public function isTuesday(): bool { @@ -1341,8 +1235,6 @@ public function isTuesday(): bool /** * Checks if this day is a Wednesday. - * - * @return bool */ public function isWednesday(): bool { @@ -1351,8 +1243,6 @@ public function isWednesday(): bool /** * Checks if this day is a Thursday. - * - * @return bool */ public function isThursday(): bool { @@ -1361,8 +1251,6 @@ public function isThursday(): bool /** * Checks if this day is a Friday. - * - * @return bool */ public function isFriday(): bool { @@ -1371,8 +1259,6 @@ public function isFriday(): bool /** * Checks if this day is a Saturday. - * - * @return bool */ public function isSaturday(): bool { @@ -1384,7 +1270,6 @@ public function isSaturday(): bool * * @param string|int $timeInterval the numeric value with space then time type. * Example of valid types: 6 hours, 2 days, 1 minute. - * @return bool */ public function wasWithinLast(string|int $timeInterval): bool { @@ -1400,7 +1285,6 @@ public function wasWithinLast(string|int $timeInterval): bool * * @param string|int $timeInterval the numeric value with space then time type. * Example of valid types: 6 hours, 2 days, 1 minute. - * @return bool */ public function isWithinNext(string|int $timeInterval): bool { @@ -1419,7 +1303,6 @@ public function isWithinNext(string|int $timeInterval): bool * @param \Cake\Chronos\ChronosDate|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php} - * @return int */ public function diffFiltered( DateInterval $interval, @@ -1456,7 +1339,6 @@ public function diffFiltered( * * @param \Cake\Chronos\ChronosDate|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference - * @return int */ public function diffInYears(?ChronosDate $other = null, bool $absolute = true): int { @@ -1470,7 +1352,6 @@ public function diffInYears(?ChronosDate $other = null, bool $absolute = true): * * @param \Cake\Chronos\ChronosDate|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference - * @return int */ public function diffInMonths(?ChronosDate $other = null, bool $absolute = true): int { @@ -1485,7 +1366,6 @@ public function diffInMonths(?ChronosDate $other = null, bool $absolute = true): * * @param \Cake\Chronos\ChronosDate|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference - * @return int */ public function diffInWeeks(?ChronosDate $other = null, bool $absolute = true): int { @@ -1497,7 +1377,6 @@ public function diffInWeeks(?ChronosDate $other = null, bool $absolute = true): * * @param \Cake\Chronos\ChronosDate|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference - * @return int */ public function diffInDays(?ChronosDate $other = null, bool $absolute = true): int { @@ -1513,7 +1392,6 @@ public function diffInDays(?ChronosDate $other = null, bool $absolute = true): i * @param \Cake\Chronos\ChronosDate|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php} - * @return int */ public function diffInDaysFiltered( callable $callback, @@ -1530,7 +1408,6 @@ public function diffInDaysFiltered( * @param \Cake\Chronos\ChronosDate|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php} - * @return int */ public function diffInWeekdays(?ChronosDate $other = null, bool $absolute = true, int $options = 0): int { @@ -1545,7 +1422,6 @@ public function diffInWeekdays(?ChronosDate $other = null, bool $absolute = true * @param \Cake\Chronos\ChronosDate|null $other The instance to difference from. * @param bool $absolute Get the absolute of the difference * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php} - * @return int */ public function diffInWeekendDays(?ChronosDate $other = null, bool $absolute = true, int $options = 0): int { @@ -1571,7 +1447,6 @@ public function diffInWeekendDays(?ChronosDate $other = null, bool $absolute = t * * @param \Cake\Chronos\ChronosDate|null $other The datetime to compare with. * @param bool $absolute removes difference modifiers ago, after, etc - * @return string */ public function diffForHumans(?ChronosDate $other = null, bool $absolute = false): string { @@ -1582,7 +1457,6 @@ public function diffForHumans(?ChronosDate $other = null, bool $absolute = false * Returns the date as a `DateTimeImmutable` instance at midnight. * * @param \DateTimeZone|string|null $timezone Time zone the DateTimeImmutable instance will be in - * @return \DateTimeImmutable */ public function toDateTimeImmutable(DateTimeZone|string|null $timezone = null): DateTimeImmutable { @@ -1601,7 +1475,6 @@ public function toDateTimeImmutable(DateTimeZone|string|null $timezone = null): * Alias of `toDateTimeImmutable()`. * * @param \DateTimeZone|string|null $timezone Time zone the DateTimeImmutable instance will be in - * @return \DateTimeImmutable */ public function toNative(DateTimeZone|string|null $timezone = null): DateTimeImmutable { @@ -1671,16 +1544,12 @@ public function __isset(string $name): bool /** * Return properties for debugging. - * - * @return array */ public function __debugInfo(): array { - $properties = [ + return [ 'hasFixedNow' => Chronos::hasTestNow(), 'date' => $this->format('Y-m-d'), ]; - - return $properties; } } diff --git a/src/ChronosDatePeriod.php b/src/ChronosDatePeriod.php index fb4e8b73..3b00e617 100644 --- a/src/ChronosDatePeriod.php +++ b/src/ChronosDatePeriod.php @@ -31,9 +31,6 @@ class ChronosDatePeriod implements Iterator */ protected Iterator $iterator; - /** - * @param \DatePeriod $period - */ public function __construct(DatePeriod $period) { /** @var \Iterator $iterator */ @@ -41,41 +38,26 @@ public function __construct(DatePeriod $period) $this->iterator = $iterator; } - /** - * @return \Cake\Chronos\ChronosDate - */ public function current(): ChronosDate { return new ChronosDate($this->iterator->current()); } - /** - * @return int - */ public function key(): int { return $this->iterator->key(); } - /** - * @return void - */ public function next(): void { $this->iterator->next(); } - /** - * @return void - */ public function rewind(): void { $this->iterator->rewind(); } - /** - * @return bool - */ public function valid(): bool { return $this->iterator->valid(); diff --git a/src/ChronosPeriod.php b/src/ChronosPeriod.php index 62e5f9f9..ca7e083e 100644 --- a/src/ChronosPeriod.php +++ b/src/ChronosPeriod.php @@ -31,9 +31,6 @@ class ChronosPeriod implements Iterator */ protected Iterator $iterator; - /** - * @param \DatePeriod $period - */ public function __construct(DatePeriod $period) { /** @var \Iterator $iterator */ @@ -41,41 +38,26 @@ public function __construct(DatePeriod $period) $this->iterator = $iterator; } - /** - * @return \Cake\Chronos\Chronos - */ public function current(): Chronos { return new Chronos($this->iterator->current()); } - /** - * @return int - */ public function key(): int { return $this->iterator->key(); } - /** - * @return void - */ public function next(): void { $this->iterator->next(); } - /** - * @return void - */ public function rewind(): void { $this->iterator->rewind(); } - /** - * @return bool - */ public function valid(): bool { return $this->iterator->valid(); diff --git a/src/ChronosTime.php b/src/ChronosTime.php index 7d65dd2a..82e30630 100644 --- a/src/ChronosTime.php +++ b/src/ChronosTime.php @@ -59,14 +59,9 @@ class ChronosTime implements Stringable /** * Format to use for __toString method. - * - * @var string */ protected static string $toStringFormat = self::DEFAULT_TO_STRING_FORMAT; - /** - * @var int - */ protected int $ticks; /** @@ -103,7 +98,6 @@ public function __construct( * * @param \Cake\Chronos\ChronosTime|\DateTimeInterface|string $time Time * @param \DateTimeZone|string|null $timezone The timezone to use for now - * @return static */ public static function parse( ChronosTime|DateTimeInterface|string|null $time = null, @@ -114,7 +108,6 @@ public static function parse( /** * @param string $time Time string in the format HH[:.]mm or HH[:.]mm[:.]ss.u - * @return int */ protected static function parseString(string $time): int { @@ -145,7 +138,6 @@ protected static function parseString(string $time): int * Returns instance set to server time. * * @param \DateTimeZone|string|null $timezone The timezone to use for now - * @return static */ public static function now(DateTimeZone|string|null $timezone = null): static { @@ -154,8 +146,6 @@ public static function now(DateTimeZone|string|null $timezone = null): static /** * Returns instance set to midnight. - * - * @return static */ public static function midnight(): static { @@ -164,8 +154,6 @@ public static function midnight(): static /** * Returns instance set to noon. - * - * @return static */ public static function noon(): static { @@ -177,7 +165,6 @@ public static function noon(): static * 23:59:59 or 23:59:59.999999 if `$microseconds` is true * * @param bool $microseconds Whether to set microseconds or not - * @return static */ public static function endOfDay(bool $microseconds = false): static { @@ -190,8 +177,6 @@ public static function endOfDay(bool $microseconds = false): static /** * Returns clock microseconds. - * - * @return int */ public function getMicroseconds(): int { @@ -202,7 +187,6 @@ public function getMicroseconds(): int * Sets clock microseconds. * * @param int $microseconds Clock microseconds - * @return static */ public function setMicroseconds(int $microseconds): static { @@ -217,8 +201,6 @@ public function setMicroseconds(int $microseconds): static /** * Return clock seconds. - * - * @return int */ public function getSeconds(): int { @@ -231,7 +213,6 @@ public function getSeconds(): int * Set clock seconds. * * @param int $seconds Clock seconds - * @return static */ public function setSeconds(int $seconds): static { @@ -246,8 +227,6 @@ public function setSeconds(int $seconds): static /** * Returns clock minutes. - * - * @return int */ public function getMinutes(): int { @@ -260,7 +239,6 @@ public function getMinutes(): int * Set clock minutes. * * @param int $minutes Clock minutes - * @return static */ public function setMinutes(int $minutes): static { @@ -275,8 +253,6 @@ public function setMinutes(int $minutes): static /** * Returns clock hours. - * - * @return int */ public function getHours(): int { @@ -289,7 +265,6 @@ public function getHours(): int * Set clock hours. * * @param int $hours Clock hours - * @return static */ public function setHours(int $hours): static { @@ -309,7 +284,6 @@ public function setHours(int $hours): static * @param int $minutes Clock minutes * @param int $seconds Clock seconds * @param int $microseconds Clock microseconds - * @return static */ public function setTime(int $hours = 0, int $minutes = 0, int $seconds = 0, int $microseconds = 0): static { @@ -328,7 +302,6 @@ public function setTime(int $hours = 0, int $minutes = 0, int $seconds = 0, int /** * @param int $a Left side * @param int $a Right side - * @return int */ protected static function mod(int $a, int $b): int { @@ -346,7 +319,6 @@ protected static function mod(int $a, int $b): int * will still be interpreted. Be sure to escape those characters first. * * @param string $format Format string - * @return string */ public function format(string $format): string { @@ -355,8 +327,6 @@ public function format(string $format): string /** * Reset the format used to the default when converting to a string - * - * @return void */ public static function resetToStringFormat(): void { @@ -367,7 +337,6 @@ public static function resetToStringFormat(): void * Set the default format used when converting to a string * * @param string $format The format to use in future __toString() calls. - * @return void */ public static function setToStringFormat(string $format): void { @@ -376,8 +345,6 @@ public static function setToStringFormat(string $format): void /** * Format the instance as a string using the set format - * - * @return string */ public function __toString(): string { @@ -388,7 +355,6 @@ public function __toString(): string * Returns whether time is equal to target time. * * @param \Cake\Chronos\ChronosTime $target Target time - * @return bool */ public function equals(ChronosTime $target): bool { @@ -399,7 +365,6 @@ public function equals(ChronosTime $target): bool * Returns whether time is greater than target time. * * @param \Cake\Chronos\ChronosTime $target Target time - * @return bool */ public function greaterThan(ChronosTime $target): bool { @@ -410,7 +375,6 @@ public function greaterThan(ChronosTime $target): bool * Returns whether time is greater than or equal to target time. * * @param \Cake\Chronos\ChronosTime $target Target time - * @return bool */ public function greaterThanOrEquals(ChronosTime $target): bool { @@ -421,7 +385,6 @@ public function greaterThanOrEquals(ChronosTime $target): bool * Returns whether time is less than target time. * * @param \Cake\Chronos\ChronosTime $target Target time - * @return bool */ public function lessThan(ChronosTime $target): bool { @@ -432,7 +395,6 @@ public function lessThan(ChronosTime $target): bool * Returns whether time is less than or equal to target time. * * @param \Cake\Chronos\ChronosTime $target Target time - * @return bool */ public function lessThanOrEquals(ChronosTime $target): bool { @@ -445,7 +407,6 @@ public function lessThanOrEquals(ChronosTime $target): bool * @param \Cake\Chronos\ChronosTime $start Start of target range * @param \Cake\Chronos\ChronosTime $end End of target range * @param bool $equals Whether to include the beginning and end of range - * @return bool */ public function between(ChronosTime $start, ChronosTime $end, bool $equals = true): bool { @@ -464,7 +425,6 @@ public function between(ChronosTime $start, ChronosTime $end, bool $equals = tru * Returns an `DateTimeImmutable` instance set to this clock time. * * @param \DateTimeZone|string|null $timezone Time zone the DateTimeImmutable instance will be in - * @return \DateTimeImmutable */ public function toDateTimeImmutable(DateTimeZone|string|null $timezone = null): DateTimeImmutable { @@ -484,7 +444,6 @@ public function toDateTimeImmutable(DateTimeZone|string|null $timezone = null): * Alias of `toDateTimeImmutable()`. * * @param \DateTimeZone|string|null $timezone Time zone the DateTimeImmutable instance will be in - * @return \DateTimeImmutable */ public function toNative(DateTimeZone|string|null $timezone = null): DateTimeImmutable { diff --git a/src/DifferenceFormatter.php b/src/DifferenceFormatter.php index 3a568c79..211dcf5a 100644 --- a/src/DifferenceFormatter.php +++ b/src/DifferenceFormatter.php @@ -28,8 +28,6 @@ class DifferenceFormatter implements DifferenceFormatterInterface { /** * The text translator object - * - * @var \Cake\Chronos\Translator */ protected Translator $translate; diff --git a/src/FormattingTrait.php b/src/FormattingTrait.php index 33a1f31b..fc414765 100644 --- a/src/FormattingTrait.php +++ b/src/FormattingTrait.php @@ -27,8 +27,6 @@ trait FormattingTrait { /** * Resets the __toString() format to ``DEFAULT_TO_STRING_FORMAT``. - * - * @return void */ public static function resetToStringFormat(): void { @@ -39,7 +37,6 @@ public static function resetToStringFormat(): void * Sets the __toString() format. * * @param string $format See ``format()`` for accepted specifiers. - * @return void */ public static function setToStringFormat(string $format): void { @@ -49,8 +46,6 @@ public static function setToStringFormat(string $format): void /** * Returns a formatted string specified by ``setToStringFormat()`` * or the default ``DEFAULT_TO_STRING_FORMAT`` format. - * - * @return string */ public function __toString(): string { @@ -59,8 +54,6 @@ public function __toString(): string /** * Format the instance as date - * - * @return string */ public function toDateString(): string { @@ -69,8 +62,6 @@ public function toDateString(): string /** * Format the instance as a readable date - * - * @return string */ public function toFormattedDateString(): string { @@ -79,8 +70,6 @@ public function toFormattedDateString(): string /** * Format the instance as time - * - * @return string */ public function toTimeString(): string { @@ -89,8 +78,6 @@ public function toTimeString(): string /** * Format the instance as date and time - * - * @return string */ public function toDateTimeString(): string { @@ -99,8 +86,6 @@ public function toDateTimeString(): string /** * Format the instance with day, date and time - * - * @return string */ public function toDayDateTimeString(): string { @@ -109,8 +94,6 @@ public function toDayDateTimeString(): string /** * Format the instance as ATOM - * - * @return string */ public function toAtomString(): string { @@ -119,8 +102,6 @@ public function toAtomString(): string /** * Format the instance as COOKIE - * - * @return string */ public function toCookieString(): string { @@ -129,8 +110,6 @@ public function toCookieString(): string /** * Format the instance as ISO8601 - * - * @return string */ public function toIso8601String(): string { @@ -140,7 +119,6 @@ public function toIso8601String(): string /** * Format the instance as RFC822 * - * @return string * @link https://tools.ietf.org/html/rfc822 */ public function toRfc822String(): string @@ -151,7 +129,6 @@ public function toRfc822String(): string /** * Format the instance as RFC850 * - * @return string * @link https://tools.ietf.org/html/rfc850 */ public function toRfc850String(): string @@ -162,7 +139,6 @@ public function toRfc850String(): string /** * Format the instance as RFC1036 * - * @return string * @link https://tools.ietf.org/html/rfc1036 */ public function toRfc1036String(): string @@ -173,7 +149,6 @@ public function toRfc1036String(): string /** * Format the instance as RFC1123 * - * @return string * @link https://tools.ietf.org/html/rfc1123 */ public function toRfc1123String(): string @@ -184,7 +159,6 @@ public function toRfc1123String(): string /** * Format the instance as RFC2822 * - * @return string * @link https://tools.ietf.org/html/rfc2822 */ public function toRfc2822String(): string @@ -195,7 +169,6 @@ public function toRfc2822String(): string /** * Format the instance as RFC3339 * - * @return string * @link https://tools.ietf.org/html/rfc3339 */ public function toRfc3339String(): string @@ -205,8 +178,6 @@ public function toRfc3339String(): string /** * Format the instance as RSS - * - * @return string */ public function toRssString(): string { @@ -215,8 +186,6 @@ public function toRssString(): string /** * Format the instance as W3C - * - * @return string */ public function toW3cString(): string { diff --git a/src/Translator.php b/src/Translator.php index 37568ae2..e15aca53 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -22,8 +22,6 @@ class Translator { /** * Translation strings. - * - * @var array */ public static array $strings = [ 'year' => '1 year',