Skip to content

Commit

Permalink
Merge 3.x into 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI authored Dec 8, 2023
2 parents 5fb52ac + 302aef7 commit 1936188
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 16 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,18 @@ jobs:
- php-version: '8.2'
dependencies: highest
allowed-to-fail: false
symfony-require: 6.2.*
variant: symfony/symfony:"6.2.*"
symfony-require: 6.3.*
variant: symfony/symfony:"6.3.*"
- php-version: '8.2'
dependencies: highest
allowed-to-fail: false
symfony-require: 6.3.*
variant: symfony/symfony:"6.3.*"
symfony-require: 6.4.*
variant: symfony/symfony:"6.4.*"
- php-version: '8.2'
dependencies: highest
allowed-to-fail: false
symfony-require: 7.0.*
variant: symfony/symfony:"7.0.*"

steps:
- name: Checkout
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [3.2.0](https://github.com/sonata-project/SonataIntlBundle/compare/3.1.0...3.2.0) - 2023-12-07
### Added
- [[#595](https://github.com/sonata-project/SonataIntlBundle/pull/595)] Support for packages from `symfony/*` 7.x ([@phansys](https://github.com/phansys))

### Fixed
- [[#598](https://github.com/sonata-project/SonataIntlBundle/pull/598)] Passing an empty string as argument 1 to `\DateTimeZone` at `DateTimeFormatter::getDatetime()` ([@phansys](https://github.com/phansys))

## [3.1.0](https://github.com/sonata-project/SonataIntlBundle/compare/3.0.2...3.1.0) - 2023-04-25
### Removed
- [[#578](https://github.com/sonata-project/SonataIntlBundle/pull/578)] Drop support for Symfony 6.0 and 6.1. ([@jordisala1991](https://github.com/jordisala1991))
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
"homepage": "https://docs.sonata-project.org/projects/SonataIntlBundle",
"require": {
"php": "^8.0",
"symfony/config": "^5.4 || ^6.2",
"symfony/dependency-injection": "^5.4 || ^6.2",
"symfony/http-foundation": "^5.4 || ^6.2",
"symfony/http-kernel": "^5.4 || ^6.2",
"symfony/intl": "^5.4 || ^6.2",
"symfony/config": "^5.4 || ^6.2 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.2 || ^7.0",
"symfony/http-foundation": "^5.4 || ^6.2 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.2 || ^7.0",
"symfony/intl": "^5.4 || ^6.2 || ^7.0",
"symfony/translation-contracts": "^2.5 || ^3.0",
"twig/twig": "^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.4",
"matthiasnoback/symfony-config-test": "^4.2",
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"matthiasnoback/symfony-config-test": "^4.2 || ^5.1",
"matthiasnoback/symfony-dependency-injection-test": "^4.0 || ^5.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
Expand All @@ -45,7 +45,7 @@
"psalm/plugin-symfony": "^5.0",
"rector/rector": "^0.18",
"symfony/phpunit-bridge": "^6.2",
"symfony/security-core": "^5.4 || ^6.2",
"symfony/security-core": "^5.4 || ^6.2 || ^7.0",
"vimeo/psalm": "^5.0"
},
"conflict": {
Expand Down
4 changes: 1 addition & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
final class Configuration implements ConfigurationInterface
{
/**
* @psalm-suppress PossiblyNullReference, UndefinedInterfaceMethod
*
* @see https://github.com/psalm/psalm-plugin-symfony/issues/174
* @psalm-suppress UndefinedInterfaceMethod
*/
public function getConfigTreeBuilder(): TreeBuilder
{
Expand Down
2 changes: 2 additions & 0 deletions src/DependencyInjection/SonataIntlExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ private function configureLocale(ContainerBuilder $container, array $config): vo
* @param array<string> $timezones
*
* @throws \RuntimeException If one of the locales is invalid
*
* @phpstan-param array<non-empty-string> $timezones
*/
private function validateTimezones(array $timezones): void
{
Expand Down
8 changes: 7 additions & 1 deletion src/Helper/DateTimeFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,15 @@ public function getDatetime(
}
}

$timezone ??= $this->timezoneDetector->getTimezone();

if (null === $timezone || '' === $timezone) {
throw new \InvalidArgumentException('Invalid timezone provided');
}

$date = new \DateTime();
$date->setTimestamp($data);
$date->setTimezone(new \DateTimeZone($timezone ?? $this->timezoneDetector->getTimezone() ?? ''));
$date->setTimezone(new \DateTimeZone($timezone));

return $date;
}
Expand Down
11 changes: 11 additions & 0 deletions src/Helper/DateTimeFormatterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ interface DateTimeFormatterInterface
{
/**
* @param int|null $dateType See \IntlDateFormatter::getDateType
*
* @phpstan-param non-empty-string|null $timezone
*/
public function formatDate(
\DateTimeInterface|string|int $date,
Expand All @@ -35,6 +37,8 @@ public function formatDate(
/**
* @param int|null $dateType See \IntlDateFormatter::getDateType
* @param int|null $timeType See \IntlDateFormatter::getTimeType
*
* @phpstan-param non-empty-string|null $timezone
*/
public function formatDateTime(
\DateTimeInterface|string|int $datetime,
Expand All @@ -46,6 +50,8 @@ public function formatDateTime(

/**
* @param int|null $timeType See \IntlDateFormatter::getTimeType
*
* @phpstan-param non-empty-string|null $timezone
*/
public function formatTime(
\DateTimeInterface|string|int $time,
Expand All @@ -54,6 +60,9 @@ public function formatTime(
?int $timeType = null
): string;

/**
* @phpstan-param non-empty-string|null $timezone
*/
public function format(
\DateTimeInterface|string|int $datetime,
string $pattern,
Expand All @@ -63,6 +72,8 @@ public function format(

/**
* Gets a date time instance by a given data and timezone.
*
* @phpstan-param non-empty-string|null $timezone
*/
public function getDatetime(
\DateTimeInterface|string|int $data,
Expand Down
9 changes: 9 additions & 0 deletions src/Twig/DateTimeRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function __construct(private DateTimeFormatterInterface $helper)
{
}

/**
* @phpstan-param non-empty-string|null $timezone
*/
public function formatDate(
\DateTimeInterface|string|int $date,
?string $pattern = null,
Expand All @@ -36,6 +39,9 @@ public function formatDate(
return $this->helper->formatDate($date, $locale, $timezone, $dateType);
}

/**
* @phpstan-param non-empty-string|null $timezone
*/
public function formatTime(
\DateTimeInterface|string|int $time,
?string $pattern = null,
Expand All @@ -50,6 +56,9 @@ public function formatTime(
return $this->helper->formatTime($time, $locale, $timezone, $timeType);
}

/**
* @phpstan-param non-empty-string|null $timezone
*/
public function formatDatetime(
\DateTimeInterface|string|int $time,
?string $pattern = null,
Expand Down

0 comments on commit 1936188

Please sign in to comment.