diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index c38d2e4c..035f6eab 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -49,7 +49,7 @@ jobs:
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"
- name: "Upload coverage file"
- uses: "actions/upload-artifact@v2"
+ uses: "actions/upload-artifact@v4"
with:
name: "phpunit-${{ matrix.dependencies }}-${{ matrix.php-version }}.coverage"
path: "coverage.xml"
@@ -67,7 +67,7 @@ jobs:
fetch-depth: 2
- name: "Download coverage files"
- uses: "actions/download-artifact@v2"
+ uses: "actions/download-artifact@v4"
with:
path: "reports"
diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index 6bfc95fb..1f5a82a2 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -86,6 +86,10 @@ private function addHandlersSection(NodeBuilder $builder)
->addDefaultsIfNotSet()
->children()
->scalarNode('default_format')->defaultValue(\DateTime::RFC3339)->end()
+ ->arrayNode('default_deserialization_formats')
+ ->scalarPrototype()->end()
+ ->defaultValue([])
+ ->end()
->scalarNode('default_timezone')->defaultValue(date_default_timezone_get())->end()
->scalarNode('cdata')->defaultTrue()->end()
->end()
diff --git a/DependencyInjection/JMSSerializerExtension.php b/DependencyInjection/JMSSerializerExtension.php
index 933fc6c4..b49a266c 100644
--- a/DependencyInjection/JMSSerializerExtension.php
+++ b/DependencyInjection/JMSSerializerExtension.php
@@ -16,6 +16,7 @@
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
+use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Finder\Finder;
@@ -126,7 +127,8 @@ private function loadInternal(array $config, ScopedContainer $container, array $
$container->getDefinition('jms_serializer.datetime_handler')
->replaceArgument(0, $config['handlers']['datetime']['default_format'])
->replaceArgument(1, $config['handlers']['datetime']['default_timezone'])
- ->replaceArgument(2, $config['handlers']['datetime']['cdata']);
+ ->replaceArgument(2, $config['handlers']['datetime']['cdata'])
+ ->replaceArgument(3, [] === $config['handlers']['datetime']['default_deserialization_formats'] ? [$config['handlers']['datetime']['default_format']] : $config['handlers']['datetime']['default_deserialization_formats']);
$container->getDefinition('jms_serializer.array_collection_handler')
->replaceArgument(0, $config['handlers']['array_collection']['initialize_excluded']);
diff --git a/Resources/config/services.xml b/Resources/config/services.xml
index 847ef2e6..2cd02bfb 100644
--- a/Resources/config/services.xml
+++ b/Resources/config/services.xml
@@ -73,6 +73,7 @@
+
diff --git a/Resources/doc/configuration.rst b/Resources/doc/configuration.rst
index 12f7a6c2..9e1ae583 100644
--- a/Resources/doc/configuration.rst
+++ b/Resources/doc/configuration.rst
@@ -201,6 +201,8 @@ values:
handlers:
datetime:
default_format: "Y-m-d\\TH:i:sP" # ATOM
+ default_deserialization_formats:
+ - "Y-m-d\\TH:i:sP" # ATOM
default_timezone: "UTC" # defaults to whatever timezone set in php.ini or via date_default_timezone_set
array_collection:
initialize_excluded: false
diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php
index 9b783713..1a65d288 100644
--- a/Tests/DependencyInjection/ConfigurationTest.php
+++ b/Tests/DependencyInjection/ConfigurationTest.php
@@ -286,6 +286,14 @@ public function testDefaultDateFormat()
$this->assertEquals(\DateTime::ATOM, $config['handlers']['datetime']['default_format']);
}
+ public function testDefaultDateDeserializationFormats()
+ {
+ $processor = new Processor();
+ $config = $processor->processConfiguration(new Configuration(true), []);
+
+ $this->assertEquals([], $config['handlers']['datetime']['default_deserialization_formats']);
+ }
+
public function testDefaultUidFormat()
{
$processor = new Processor();
diff --git a/Tests/DependencyInjection/Fixture/ObjectUsingEnumDeserialize.php b/Tests/DependencyInjection/Fixture/ObjectUsingEnumDeserialize.php
index 66c4e784..d5ed6228 100644
--- a/Tests/DependencyInjection/Fixture/ObjectUsingEnumDeserialize.php
+++ b/Tests/DependencyInjection/Fixture/ObjectUsingEnumDeserialize.php
@@ -10,11 +10,11 @@ class ObjectUsingEnumDeserialize
{
private ObjectUsingEnumDeserializeCard $one;
- /** @Type("enum<'JMS\SerializerBundle\Tests\DependencyInjection\Fixture\ObjectUsingEnumDeserializeCard'>") */
- #[Type(name: 'enum<"JMS\SerializerBundle\Tests\DependencyInjection\Fixture\ObjectUsingEnumDeserializeCard">')]
+ /** @Type("enum") */
+ #[Type(name: 'enum')]
private $two;
- /** @Type("array>") */
- #[Type(name: 'array>')]
+ /** @Type("array>") */
+ #[Type(name: 'array>')]
private array $three;
public function __construct()
diff --git a/composer.json b/composer.json
index 082ab3a2..223dfc1a 100644
--- a/composer.json
+++ b/composer.json
@@ -22,13 +22,14 @@
],
"require": {
"php": "^7.4 || ^8.0",
- "jms/serializer": "^3.28",
+ "jms/serializer": "^3.31",
"jms/metadata": "^2.6",
"symfony/config": "^5.4 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
+ "doctrine/annotations": "^1.14 || ^2.0",
"doctrine/coding-standard": "^12.0",
"doctrine/orm": "^2.14",
"phpunit/phpunit": "^8.0 || ^9.0",