Skip to content

feat(datetime): Introduce DateTime component #789

feat(datetime): Introduce DateTime component

feat(datetime): Introduce DateTime component #789

Triggered via pull request March 31, 2024 22:49
@azjezzazjezz
synchronize #446
feat/datetime
Status Failure
Total duration 5m 53s
Artifacts

mutation-tests.yml

on: pull_request
Matrix: mutation tests
Fit to window
Zoom out
Zoom in

Annotations

1 error and 10 warnings
mutation tests (8.3, ubuntu-latest)
Process completed with exit code 2.
mutation tests (8.3, ubuntu-latest): src/Psl/DateTime/DateTime.php#L77
Escaped Mutant for Mutator "LessThan": --- Original +++ New @@ @@ */ private function __construct(Timezone $timezone, Timestamp $timestamp, int $year, int $month, int $day, int $hours, int $minutes, int $seconds, int $nanoseconds) { - if ($nanoseconds < 0 || $nanoseconds >= NANOSECONDS_PER_SECOND || $seconds < 0 || $seconds >= 60 || $minutes < 0 || $minutes >= 60 || $hours < 0 || $hours >= 24 || $month < 1 || $month > 12 || $day < 1 || $day > 31 || $day > Month::from($month)->getDaysForYear($year)) { + if ($nanoseconds < 0 || $nanoseconds >= NANOSECONDS_PER_SECOND || $seconds < 0 || $seconds >= 60 || $minutes < 0 || $minutes >= 60 || $hours < 0 || $hours >= 24 || $month <= 1 || $month > 12 || $day < 1 || $day > 31 || $day > Month::from($month)->getDaysForYear($year)) { throw new Exception\InvalidArgumentException('One or more components of the date-time are out of valid ranges.'); } $this->timestamp = $timestamp;
mutation tests (8.3, ubuntu-latest): src/Psl/DateTime/DateTime.php#L77
Escaped Mutant for Mutator "GreaterThan": --- Original +++ New @@ @@ */ private function __construct(Timezone $timezone, Timestamp $timestamp, int $year, int $month, int $day, int $hours, int $minutes, int $seconds, int $nanoseconds) { - if ($nanoseconds < 0 || $nanoseconds >= NANOSECONDS_PER_SECOND || $seconds < 0 || $seconds >= 60 || $minutes < 0 || $minutes >= 60 || $hours < 0 || $hours >= 24 || $month < 1 || $month > 12 || $day < 1 || $day > 31 || $day > Month::from($month)->getDaysForYear($year)) { + if ($nanoseconds < 0 || $nanoseconds >= NANOSECONDS_PER_SECOND || $seconds < 0 || $seconds >= 60 || $minutes < 0 || $minutes >= 60 || $hours < 0 || $hours >= 24 || $month < 1 || $month >= 12 || $day < 1 || $day > 31 || $day > Month::from($month)->getDaysForYear($year)) { throw new Exception\InvalidArgumentException('One or more components of the date-time are out of valid ranges.'); } $this->timestamp = $timestamp;
mutation tests (8.3, ubuntu-latest): src/Psl/DateTime/DateTime.php#L212
Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ { /** @var IntlCalendar $calendar */ $calendar = IntlCalendar::createInstance(Internal\to_intl_timezone($timezone)); - $calendar->setTime($timestamp->getSeconds() * MILLISECONDS_PER_SECOND); + $year = $calendar->get(IntlCalendar::FIELD_YEAR); $month = $calendar->get(IntlCalendar::FIELD_MONTH) + 1; $day = $calendar->get(IntlCalendar::FIELD_DAY_OF_MONTH);
mutation tests (8.3, ubuntu-latest): src/Psl/DateTime/DateTimeConvenienceMethodsTrait.php#L524
Escaped Mutant for Mutator "Coalesce": --- Original +++ New @@ @@ */ public function format(DatePattern|string|null $pattern = null, ?Timezone $timezone = null, ?Locale\Locale $locale = null) : string { - return $this->getTimestamp()->format($pattern, $timezone ?? $this->getTimezone(), $locale); + return $this->getTimestamp()->format($pattern, $this->getTimezone() ?? $timezone, $locale); } }
mutation tests (8.3, ubuntu-latest): src/Psl/DateTime/Duration.php#L477
Escaped Mutant for Mutator "Spaceship": --- Original +++ New @@ @@ return Comparison\Order::from($this->hours <=> $other->hours); } if ($this->minutes !== $other->minutes) { - return Comparison\Order::from($this->minutes <=> $other->minutes); + return Comparison\Order::from($other->minutes <=> $this->minutes); } if ($this->seconds !== $other->seconds) { return Comparison\Order::from($this->seconds <=> $other->seconds);
mutation tests (8.3, ubuntu-latest): src/Psl/DateTime/Duration.php#L614
Escaped Mutant for Mutator "Plus": --- Original +++ New @@ @@ if ($this->isZero()) { return $other; } - return self::fromParts($this->hours + $other->hours, $this->minutes + $other->minutes, $this->seconds + $other->seconds, $this->nanoseconds + $other->nanoseconds); + return self::fromParts($this->hours - $other->hours, $this->minutes + $other->minutes, $this->seconds + $other->seconds, $this->nanoseconds + $other->nanoseconds); } /** * Returns a new instance representing the difference between this instance
mutation tests (8.3, ubuntu-latest): src/Psl/DateTime/Duration.php#L643
Escaped Mutant for Mutator "Minus": --- Original +++ New @@ @@ if ($this->isZero()) { return $other; } - return self::fromParts($this->hours - $other->hours, $this->minutes - $other->minutes, $this->seconds - $other->seconds, $this->nanoseconds - $other->nanoseconds); + return self::fromParts($this->hours + $other->hours, $this->minutes - $other->minutes, $this->seconds - $other->seconds, $this->nanoseconds - $other->nanoseconds); } /** * Returns the time duration as string, useful e.g. for debugging. This is not
mutation tests (8.3, ubuntu-latest): src/Psl/DateTime/Duration.php#L661
Escaped Mutant for Mutator "IncrementInteger": --- Original +++ New @@ @@ * * @psalm-suppress MissingThrowsDocblock */ - public function toString(int $max_decimals = 3) : string + public function toString(int $max_decimals = 4) : string { $decimal_part = ''; if ($max_decimals > 0) {
mutation tests (8.3, ubuntu-latest): src/Psl/DateTime/Duration.php#L664
Escaped Mutant for Mutator "GreaterThan": --- Original +++ New @@ @@ public function toString(int $max_decimals = 3) : string { $decimal_part = ''; - if ($max_decimals > 0) { + if ($max_decimals >= 0) { $decimal_part = (string) Math\abs($this->nanoseconds); $decimal_part = Str\pad_left($decimal_part, 9, '0'); $decimal_part = Str\slice($decimal_part, 0, $max_decimals);
mutation tests (8.3, ubuntu-latest): src/Psl/DateTime/Duration.php#L691
Escaped Mutant for Mutator "LessThan": --- Original +++ New @@ @@ --$end; } $start = 0; - while ($start < $end && $values[$start][0] === '0') { + while ($start <= $end && $values[$start][0] === '0') { ++$start; } $output = [];