-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #50193 [Serializer] Fix
SerializedPath
not working with constru…
…ctor arguments (HypeMC) This PR was merged into the 6.2 branch. Discussion ---------- [Serializer] Fix `SerializedPath` not working with constructor arguments | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Currently the `#[SerializedPath]` attribute doesn't work with constructor arguments: ```php class Test { public function __construct( #[SerializedPath('[foo][bar]')] public string $bar, ) { } } $serializer->denormalize(['foo' => ['bar' => 'something']], Test::class); ``` ``` In AbstractNormalizer.php line 384: Cannot create an instance of "Test" from serialized data because its constructor requires parameter "bar" to be present. ``` Commits ------- 240c03130b [Serializer] Fix SerializedPath not working with constructor arguments
- Loading branch information
Showing
10 changed files
with
298 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
Tests/Fixtures/Annotations/SerializedPathInConstructorDummy.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; | ||
|
||
use Symfony\Component\Serializer\Annotation\SerializedPath; | ||
|
||
class SerializedPathInConstructorDummy | ||
{ | ||
public function __construct( | ||
/** | ||
* @SerializedPath("[one][two]") | ||
*/ | ||
public $three, | ||
) { | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Tests/Fixtures/Attributes/SerializedPathInConstructorDummy.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Serializer\Tests\Fixtures\Attributes; | ||
|
||
use Symfony\Component\Serializer\Annotation\SerializedPath; | ||
|
||
class SerializedPathInConstructorDummy | ||
{ | ||
public function __construct( | ||
#[SerializedPath('[one][two]')] public $three, | ||
) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.