diff --git a/.gitignore b/.gitignore index 07e7383..a9d89a1 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ composer.lock var/ vendor/ + +# Claude Code local settings +.claude/settings.local.json diff --git a/composer.json b/composer.json index 64ed83e..8d49cc0 100644 --- a/composer.json +++ b/composer.json @@ -17,30 +17,30 @@ "php": ">=8.2.22", "aimeos/map": "^3.12", "doctrine/collections": "^1.6 || ^2", - "nesbot/carbon": "^2.72", + "nesbot/carbon": "^3.0", "psr/log": "^1.1 || ^2.0 || ^3", - "symfony/console": "^6.4 || ^7.0", - "symfony/dependency-injection": "^6.4 || ^7.0", - "symfony/event-dispatcher": "^6.4 || ^7.0", - "symfony/filesystem": "^6.4 || ^7.0", - "symfony/finder": "^6.4 || ^7.0", - "symfony/http-foundation": "^6.4 || ^7.0", - "symfony/mailer": "^6.4 || ^7.0", - "symfony/options-resolver": "^6.4 || ^7.0", - "symfony/process": "^6.4 || ^7.0", - "symfony/routing": "^6.4 || ^7.0", - "symfony/stopwatch": "^6.4 || ^7.0", - "symfony/string": "^6.4 || ^7.0", - "symfony/translation": "^6.4 || ^7.0", - "symfony/twig-bridge": "^6.4 || ^7.0", - "symfony/uid": "^6.4 || ^7.0", + "symfony/console": "^7.3", + "symfony/dependency-injection": "^7.3", + "symfony/event-dispatcher": "^7.3", + "symfony/filesystem": "^7.3", + "symfony/finder": "^7.3", + "symfony/http-foundation": "^7.3", + "symfony/mailer": "^7.3", + "symfony/options-resolver": "^7.3", + "symfony/process": "^7.3", + "symfony/routing": "^7.3", + "symfony/stopwatch": "^7.3", + "symfony/string": "^7.3", + "symfony/translation": "^7.3", + "symfony/twig-bridge": "^7.3", + "symfony/uid": "^7.3", "twig/twig": "^2.13|^3.0.4", "webmozart/assert": "^1.11", "nyholm/psr7": "^1.8", "archtechx/enums": "^1.1", - "symfony/messenger": "^6.4 || ^7.0", + "symfony/messenger": "^7.3", "doctrine/orm": "^2.16 || ^3.0", - "symfony/http-kernel": "^6.4 || ^7.0" + "symfony/http-kernel": "^7.3" }, "autoload": { "psr-4": { @@ -67,7 +67,7 @@ "tomasvotruba/unused-public": "^0.3.9", "tomasvotruba/lines": "^0.5.1", "phpstan/extension-installer": "^1.4", - "phparkitect/phparkitect": "^0.3.33", + "phparkitect/phparkitect": "^0.6.0", "friendsofphp/php-cs-fixer": "^3.59" }, "config": { @@ -80,7 +80,7 @@ }, "extra": { "symfony": { - "require": "^6.4 || ^7.0" + "require": "^7.3" } } } diff --git a/src/Contracts/DateTime/DateTimeInterface.php b/src/Contracts/DateTime/DateTimeInterface.php index af82c80..4bba3e3 100644 --- a/src/Contracts/DateTime/DateTimeInterface.php +++ b/src/Contracts/DateTime/DateTimeInterface.php @@ -609,126 +609,6 @@ public function subWeekdays(int $value = 1): DateTimeInterface; public function subWeekday(): DateTimeInterface; - public function addRealMicros(int $value = 1): DateTimeInterface; - - public function addRealMicro(): DateTimeInterface; - - public function subRealMicros(int $value = 1): DateTimeInterface; - - public function subRealMicro(): DateTimeInterface; - - public function addRealMicroseconds(int $value = 1): DateTimeInterface; - - public function addRealMicrosecond(): DateTimeInterface; - - public function subRealMicroseconds(int $value = 1): DateTimeInterface; - - public function subRealMicrosecond(): DateTimeInterface; - - public function addRealMillis(int $value = 1): DateTimeInterface; - - public function addRealMilli(): DateTimeInterface; - - public function subRealMillis(int $value = 1): DateTimeInterface; - - public function subRealMilli(): DateTimeInterface; - - public function addRealMilliseconds(int $value = 1): DateTimeInterface; - - public function addRealMillisecond(): DateTimeInterface; - - public function subRealMilliseconds(int $value = 1): DateTimeInterface; - - public function subRealMillisecond(): DateTimeInterface; - - public function addRealSeconds(int $value = 1): DateTimeInterface; - - public function addRealSecond(): DateTimeInterface; - - public function subRealSeconds(int $value = 1): DateTimeInterface; - - public function subRealSecond(): DateTimeInterface; - - public function addRealMinutes(int $value = 1): DateTimeInterface; - - public function addRealMinute(): DateTimeInterface; - - public function subRealMinutes(int $value = 1): DateTimeInterface; - - public function subRealMinute(): DateTimeInterface; - - public function addRealHours(int $value = 1): DateTimeInterface; - - public function addRealHour(): DateTimeInterface; - - public function subRealHours(int $value = 1): DateTimeInterface; - - public function subRealHour(): DateTimeInterface; - - public function addRealDays(int $value = 1): DateTimeInterface; - - public function addRealDay(): DateTimeInterface; - - public function subRealDays(int $value = 1): DateTimeInterface; - - public function subRealDay(): DateTimeInterface; - - public function addRealWeeks(int $value = 1): DateTimeInterface; - - public function addRealWeek(): DateTimeInterface; - - public function subRealWeeks(int $value = 1): DateTimeInterface; - - public function subRealWeek(): DateTimeInterface; - - public function addRealMonths(int $value = 1): DateTimeInterface; - - public function addRealMonth(): DateTimeInterface; - - public function subRealMonths(int $value = 1): DateTimeInterface; - - public function subRealMonth(): DateTimeInterface; - - public function addRealQuarters(int $value = 1): DateTimeInterface; - - public function addRealQuarter(): DateTimeInterface; - - public function subRealQuarters(int $value = 1): DateTimeInterface; - - public function subRealQuarter(): DateTimeInterface; - - public function addRealYears(int $value = 1): DateTimeInterface; - - public function addRealYear(): DateTimeInterface; - - public function subRealYears(int $value = 1): DateTimeInterface; - - public function subRealYear(): DateTimeInterface; - - public function addRealDecades(int $value = 1): DateTimeInterface; - - public function addRealDecade(): DateTimeInterface; - - public function subRealDecades(int $value = 1): DateTimeInterface; - - public function subRealDecade(): DateTimeInterface; - - public function addRealCenturies(int $value = 1): DateTimeInterface; - - public function addRealCentury(): DateTimeInterface; - - public function subRealCenturies(int $value = 1): DateTimeInterface; - - public function subRealCentury(): DateTimeInterface; - - public function addRealMillennia(int $value = 1): DateTimeInterface; - - public function addRealMillennium(): DateTimeInterface; - - public function subRealMillennia(int $value = 1): DateTimeInterface; - - public function subRealMillennium(): DateTimeInterface; - /** * @param float|int $precision */ diff --git a/src/Primitives/Traits/DateTimeTrait.php b/src/Primitives/Traits/DateTimeTrait.php index 1390a41..315c702 100644 --- a/src/Primitives/Traits/DateTimeTrait.php +++ b/src/Primitives/Traits/DateTimeTrait.php @@ -55,9 +55,10 @@ public static function of( if ($datetime instanceof \DateTimeInterface) { try { - $newDateTime = Carbon::parse($datetime) - ->setTimezone($timezone) - ; + $newDateTime = Carbon::parse($datetime); + if ($timezone instanceof \DateTimeZone) { + $newDateTime->setTimezone($timezone); + } return new self($newDateTime); } catch (\Exception $exception) { @@ -67,9 +68,10 @@ public static function of( if (is_int($datetime)) { try { - $newDateTime = Carbon::createFromTimestamp($datetime) - ->setTimezone($timezone) - ; + $newDateTime = Carbon::createFromTimestamp($datetime); + if ($timezone instanceof \DateTimeZone) { + $newDateTime->setTimezone($timezone); + } return new self($newDateTime); } catch (\Exception $exception) { @@ -286,7 +288,9 @@ public function toDateTime(): \DateTimeInterface */ public function setTimezone($timezone = null): DateTimeInterface { - $this->datetime->setTimezone($timezone); + if (null !== $timezone) { + $this->datetime->setTimezone($timezone); + } return $this; } @@ -2197,426 +2201,6 @@ public function subWeekday(): DateTimeInterface return $this; } - public function addRealMicros(int $value = 1): DateTimeInterface - { - $this->datetime->addRealMicros($value); - - return $this; - } - - public function addRealMicro(): DateTimeInterface - { - $this->datetime->addRealMicro(); - - return $this; - } - - public function subRealMicros(int $value = 1): DateTimeInterface - { - $this->datetime->subRealMicros($value); - - return $this; - } - - public function subRealMicro(): DateTimeInterface - { - $this->datetime->subRealMicro(); - - return $this; - } - - public function addRealMicroseconds(int $value = 1): DateTimeInterface - { - $this->datetime->addRealMicroseconds($value); - - return $this; - } - - public function addRealMicrosecond(): DateTimeInterface - { - $this->datetime->addRealMicrosecond(); - - return $this; - } - - public function subRealMicroseconds(int $value = 1): DateTimeInterface - { - $this->datetime->subRealMicroseconds($value); - - return $this; - } - - public function subRealMicrosecond(): DateTimeInterface - { - $this->datetime->subRealMicrosecond(); - - return $this; - } - - public function addRealMillis(int $value = 1): DateTimeInterface - { - $this->datetime->addRealMillis($value); - - return $this; - } - - public function addRealMilli(): DateTimeInterface - { - $this->datetime->addRealMilli(); - - return $this; - } - - public function subRealMillis(int $value = 1): DateTimeInterface - { - $this->datetime->subRealMillis($value); - - return $this; - } - - public function subRealMilli(): DateTimeInterface - { - $this->datetime->subRealMilli(); - - return $this; - } - - public function addRealMilliseconds(int $value = 1): DateTimeInterface - { - $this->datetime->addRealMilliseconds($value); - - return $this; - } - - public function addRealMillisecond(): DateTimeInterface - { - $this->datetime->addRealMillisecond(); - - return $this; - } - - public function subRealMilliseconds(int $value = 1): DateTimeInterface - { - $this->datetime->subRealMilliseconds($value); - - return $this; - } - - public function subRealMillisecond(): DateTimeInterface - { - $this->datetime->subRealMillisecond(); - - return $this; - } - - public function addRealSeconds(int $value = 1): DateTimeInterface - { - $this->datetime->addRealSeconds($value); - - return $this; - } - - public function addRealSecond(): DateTimeInterface - { - $this->datetime->addRealSecond(); - - return $this; - } - - public function subRealSeconds(int $value = 1): DateTimeInterface - { - $this->datetime->subRealSeconds($value); - - return $this; - } - - public function subRealSecond(): DateTimeInterface - { - $this->datetime->subRealSecond(); - - return $this; - } - - public function addRealMinutes(int $value = 1): DateTimeInterface - { - $this->datetime->addRealMinutes($value); - - return $this; - } - - public function addRealMinute(): DateTimeInterface - { - $this->datetime->addRealMinute(); - - return $this; - } - - public function subRealMinutes(int $value = 1): DateTimeInterface - { - $this->datetime->subRealMinutes($value); - - return $this; - } - - public function subRealMinute(): DateTimeInterface - { - $this->datetime->subRealMinute(); - - return $this; - } - - public function addRealHours(int $value = 1): DateTimeInterface - { - $this->datetime->addRealHours($value); - - return $this; - } - - public function addRealHour(): DateTimeInterface - { - $this->datetime->addRealHour(); - - return $this; - } - - public function subRealHours(int $value = 1): DateTimeInterface - { - $this->datetime->subRealHours($value); - - return $this; - } - - public function subRealHour(): DateTimeInterface - { - $this->datetime->subRealHour(); - - return $this; - } - - public function addRealDays(int $value = 1): DateTimeInterface - { - $this->datetime->addRealDays($value); - - return $this; - } - - public function addRealDay(): DateTimeInterface - { - $this->datetime->addRealDay(); - - return $this; - } - - public function subRealDays(int $value = 1): DateTimeInterface - { - $this->datetime->subRealDays($value); - - return $this; - } - - public function subRealDay(): DateTimeInterface - { - $this->datetime->subRealDay(); - - return $this; - } - - public function addRealWeeks(int $value = 1): DateTimeInterface - { - $this->datetime->addRealWeeks($value); - - return $this; - } - - public function addRealWeek(): DateTimeInterface - { - $this->datetime->addRealWeek(); - - return $this; - } - - public function subRealWeeks(int $value = 1): DateTimeInterface - { - $this->datetime->subRealWeeks($value); - - return $this; - } - - public function subRealWeek(): DateTimeInterface - { - $this->datetime->subRealWeek(); - - return $this; - } - - public function addRealMonths(int $value = 1): DateTimeInterface - { - $this->datetime->addRealMonths($value); - - return $this; - } - - public function addRealMonth(): DateTimeInterface - { - $this->datetime->addRealMonth(); - - return $this; - } - - public function subRealMonths(int $value = 1): DateTimeInterface - { - $this->datetime->subRealMonths($value); - - return $this; - } - - public function subRealMonth(): DateTimeInterface - { - $this->datetime->subRealMonth(); - - return $this; - } - - public function addRealQuarters(int $value = 1): DateTimeInterface - { - $this->datetime->addRealQuarters($value); - - return $this; - } - - public function addRealQuarter(): DateTimeInterface - { - $this->datetime->addRealQuarter(); - - return $this; - } - - public function subRealQuarters(int $value = 1): DateTimeInterface - { - $this->datetime->subRealQuarters($value); - - return $this; - } - - public function subRealQuarter(): DateTimeInterface - { - $this->datetime->subRealQuarter(); - - return $this; - } - - public function addRealYears(int $value = 1): DateTimeInterface - { - $this->datetime->addRealYears($value); - - return $this; - } - - public function addRealYear(): DateTimeInterface - { - $this->datetime->addRealYear(); - - return $this; - } - - public function subRealYears(int $value = 1): DateTimeInterface - { - $this->datetime->subRealYears($value); - - return $this; - } - - public function subRealYear(): DateTimeInterface - { - $this->datetime->subRealYear(); - - return $this; - } - - public function addRealDecades(int $value = 1): DateTimeInterface - { - $this->datetime->addRealDecades($value); - - return $this; - } - - public function addRealDecade(): DateTimeInterface - { - $this->datetime->addRealDecade(); - - return $this; - } - - public function subRealDecades(int $value = 1): DateTimeInterface - { - $this->datetime->subRealDecades($value); - - return $this; - } - - public function subRealDecade(): DateTimeInterface - { - $this->datetime->subRealDecade(); - - return $this; - } - - public function addRealCenturies(int $value = 1): DateTimeInterface - { - $this->datetime->addRealCenturies($value); - - return $this; - } - - public function addRealCentury(): DateTimeInterface - { - $this->datetime->addRealCentury(); - - return $this; - } - - public function subRealCenturies(int $value = 1): DateTimeInterface - { - $this->datetime->subRealCenturies($value); - - return $this; - } - - public function subRealCentury(): DateTimeInterface - { - $this->datetime->subRealCentury(); - - return $this; - } - - public function addRealMillennia(int $value = 1): DateTimeInterface - { - $this->datetime->addRealMillennia($value); - - return $this; - } - - public function addRealMillennium(): DateTimeInterface - { - $this->datetime->addRealMillennium(); - - return $this; - } - - public function subRealMillennia(int $value = 1): DateTimeInterface - { - $this->datetime->subRealMillennia($value); - - return $this; - } - - public function subRealMillennium(): DateTimeInterface - { - $this->datetime->subRealMillennium(); - - return $this; - } - public function roundYear($precision = 1, string $function = 'round'): DateTimeInterface { $this->datetime->roundYear($precision, $function); diff --git a/src/Rector/Rules/ReplaceTraitUseByAliasNameRector.php b/src/Rector/Rules/ReplaceTraitUseByAliasNameRector.php index 8ce4aad..043d424 100644 --- a/src/Rector/Rules/ReplaceTraitUseByAliasNameRector.php +++ b/src/Rector/Rules/ReplaceTraitUseByAliasNameRector.php @@ -70,8 +70,7 @@ public function someMethod() $collection = Collection::of(['foo', 'bar']); } } -CODE_SAMPLE - , +CODE_SAMPLE, // Code after the rector run <<<'CODE_SAMPLE' use MyPackage\Collection as Collection_; @@ -85,8 +84,7 @@ public function someMethod() $collection = Collection_::of(['foo', 'bar']); } } -CODE_SAMPLE - , +CODE_SAMPLE, [ self::OLD_TRAIT_NAME => 'MyPackage\CollectionTrait', self::NEW_TRAIT_NAME => 'MyPackage\Collection', diff --git a/tools/phpstan/baseline.neon b/tools/phpstan/baseline.neon index 599ca96..05801f2 100644 --- a/tools/phpstan/baseline.neon +++ b/tools/phpstan/baseline.neon @@ -626,7 +626,7 @@ parameters: path: ../../src/Contracts/Collection/NumericMapInterface.php - - message: "#^Interface Atournayre\\\\Contracts\\\\DateTime\\\\DateTimeInterface has 470 methods, which exceeds the maximum of 5 \\(Elegant Object principle\\)\\.$#" + message: "#^Interface Atournayre\\\\Contracts\\\\DateTime\\\\DateTimeInterface has 410 methods, which exceeds the maximum of 5 \\(Elegant Object principle\\)\\.$#" count: 1 path: ../../src/Contracts/DateTime/DateTimeInterface.php