Skip to content

Commit 1fd709a

Browse files
authored
Merge pull request #39 from assoconnect/php_8_4
Add PHP 8.4 support and require PHP 8.3+
2 parents 97a8e97 + b6125eb commit 1fd709a

6 files changed

Lines changed: 17 additions & 19 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
php-versions: ['8.2', '8.3']
14+
php-versions: ['8.3', '8.4']
1515
dependency-versions: ['lowest', 'highest']
1616
runs-on: ubuntu-latest
1717
steps:

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
},
1616
"require-dev": {
1717
"symfony/contracts": "^2.4",
18-
"symfony/translation": "^6.0|^7.0",
18+
"symfony/translation": "^7.0",
1919
"assoconnect/php-quality-config": "^1.16",
2020
"assoconnect/validator-bundle": "^2.19"
2121
},
2222
"require": {
2323
"ext-intl": "*",
24-
"php": "^7.4|^8.0",
25-
"symfony/framework-bundle": "^6.0|^7.0",
24+
"php": "^8.3",
25+
"symfony/framework-bundle": "^7.0",
2626
"assoconnect/php-date": "^2.11",
2727
"doctrine/dbal": "^2.10|^3.0",
28-
"symfony/serializer": "^6.0|^7.0",
28+
"symfony/serializer": "^7.0",
2929
"twig/twig": "^3",
30-
"symfony/clock": "^6.4|^7.3"
30+
"symfony/clock": "^7.3"
3131
},
3232
"config": {
3333
"allow-plugins": {

src/AbsoluteDateClock.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,18 @@
55
namespace AssoConnect\PHPDateBundle;
66

77
use AssoConnect\PHPDate\AbsoluteDate;
8+
use DateTimeZone;
89
use Symfony\Component\Clock\DatePoint;
910

1011
class AbsoluteDateClock
1112
{
12-
public static function now(\DateTimeZone $timeZone = null): AbsoluteDate
13+
public static function now(?DateTimeZone $timeZone = null): AbsoluteDate
1314
{
1415
return self::relative('now', $timeZone);
1516
}
1617

17-
/**
18-
* @throws \DateMalformedStringException
19-
*/
20-
public static function relative(string $relative = 'now', \DateTimeZone $timezone = null): AbsoluteDate
18+
public static function relative(string $relative = 'now', ?DateTimeZone $timezone = null): AbsoluteDate
2119
{
22-
return AbsoluteDate::createInTimezone($timezone ?? new \DateTimeZone('UTC'), new DatePoint($relative));
20+
return AbsoluteDate::createInTimezone($timezone ?? new DateTimeZone('UTC'), new DatePoint($relative));
2321
}
2422
}

src/Normalizer/AbsoluteDateNormalizer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ class AbsoluteDateNormalizer implements NormalizerInterface, DenormalizerInterfa
2424
* @param mixed[] $context
2525
* @throws InvalidArgumentException
2626
*/
27-
public function normalize($object, string $format = null, array $context = []): string
27+
public function normalize(mixed $data, ?string $format = null, array $context = []): string
2828
{
29-
if (!$object instanceof AbsoluteDate) {
29+
if (!$data instanceof AbsoluteDate) {
3030
throw new InvalidArgumentException(sprintf(
3131
'The object must be an instance of "%s".',
3232
AbsoluteDate::class
@@ -35,14 +35,14 @@ public function normalize($object, string $format = null, array $context = []):
3535

3636
$dateTimeFormat = $context[self::FORMAT_KEY] ?? AbsoluteDate::DEFAULT_DATE_FORMAT;
3737

38-
return $object->format($dateTimeFormat);
38+
return $data->format($dateTimeFormat);
3939
}
4040

4141
/**
4242
* {@inheritdoc}
4343
* @param mixed[] $context
4444
*/
45-
public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool
45+
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
4646
{
4747
return $data instanceof AbsoluteDate;
4848
}
@@ -53,7 +53,7 @@ public function supportsNormalization(mixed $data, string $format = null, array
5353
* @param mixed[] $context
5454
* @throws NotNormalizableValueException
5555
*/
56-
public function denormalize($data, string $type, string $format = null, array $context = []): ?AbsoluteDate
56+
public function denormalize($data, string $type, ?string $format = null, array $context = []): ?AbsoluteDate
5757
{
5858
$dateTimeFormat = $context[self::FORMAT_KEY] ?? AbsoluteDate::DEFAULT_DATE_FORMAT;
5959

src/Translatable/AbsoluteDateTranslatable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(
3434
$this->timezone = new DateTimeZone('UTC');
3535
}
3636

37-
public function trans(TranslatorInterface $translator, string $locale = null): string
37+
public function trans(TranslatorInterface $translator, ?string $locale = null): string
3838
{
3939
if (null === $locale) {
4040
$locale = $translator->getLocale();

src/Twig/Extension/AbsoluteDateExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function getFilters(): array
2626
];
2727
}
2828

29-
public function formatAbsoluteDate(AbsoluteDate $date, string $locale = null): string
29+
public function formatAbsoluteDate(AbsoluteDate $date, ?string $locale = null): string
3030
{
3131
return (new AbsoluteDateTranslatable($date))->trans($this->translator, $locale);
3232
}

0 commit comments

Comments
 (0)