From 573bac3b5c37ea101ccfc906784702dfd881d7df Mon Sep 17 00:00:00 2001 From: Piotrek O Date: Tue, 9 Jan 2024 13:51:20 +0100 Subject: [PATCH 1/2] Support Symfony 7 and php82 --- .github/workflows/test.yaml | 4 ++++ composer.json | 4 ++-- src/Operand/PlatformFunction/DateAdd.php | 4 ++++ src/Operand/PlatformFunction/DateSub.php | 3 +++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index de099a41..6816099c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -18,6 +18,7 @@ jobs: - '7.3' - '7.4' - '8.0' + - '8.2' variant: [normal] include: - php-version: '7.2' @@ -32,6 +33,9 @@ jobs: - php-version: '8.0' dependencies: highest variant: 'doctrine/orm:~2.7 symfony/property-access:^6.0' + - php-version: '8.2' + dependencies: highest + variant: 'doctrine/orm:~2.7 symfony/property-access:^7.0' steps: - name: Checkout uses: actions/checkout@v2 diff --git a/composer.json b/composer.json index bcd52a03..a4b622a6 100644 --- a/composer.json +++ b/composer.json @@ -22,11 +22,11 @@ "require": { "php": ">=7.2", "doctrine/orm": "~2.5", - "symfony/property-access": "^4.0 || ^5.2 || ^6.0", + "symfony/property-access": "^4.0 || ^5.2 || ^6.0 || ^7.0", "symfony/polyfill-php80": "^1.20" }, "require-dev": { - "phpspec/phpspec": "~6.3" + "phpspec/phpspec": "~6.3 || ^7.0" }, "autoload": { "psr-4": { diff --git a/src/Operand/PlatformFunction/DateAdd.php b/src/Operand/PlatformFunction/DateAdd.php index 19f2a7a6..cb0b8a73 100644 --- a/src/Operand/PlatformFunction/DateAdd.php +++ b/src/Operand/PlatformFunction/DateAdd.php @@ -119,6 +119,10 @@ public function execute($candidate, ?string $context = null): \DateTimeImmutable $new_date = new \DateTimeImmutable($date->format('Y-m-d H:i:s'), $date->getTimezone()); + if (0 > (float) $value) { + return $new_date->modify(sprintf('%d %s', $value, $this->unit)); + } + return $new_date->modify(sprintf('+%d %s', $value, $this->unit)); } } diff --git a/src/Operand/PlatformFunction/DateSub.php b/src/Operand/PlatformFunction/DateSub.php index 6389da51..886e73e3 100644 --- a/src/Operand/PlatformFunction/DateSub.php +++ b/src/Operand/PlatformFunction/DateSub.php @@ -119,6 +119,9 @@ public function execute($candidate, ?string $context = null): \DateTimeImmutable $new_date = new \DateTimeImmutable($date->format('Y-m-d H:i:s'), $date->getTimezone()); + if (0 > (float) $value) { + return $new_date->modify(sprintf('+%d %s', abs((float) $value), $this->unit)); + } return $new_date->modify(sprintf('-%d %s', $value, $this->unit)); } } From 89d140d9c2ccacd0d08328afe9a98fe60aeaff88 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Sat, 27 Jul 2024 14:45:29 +0200 Subject: [PATCH 2/2] chore: trigger ci