Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Serializer] Add support for auto generated custom normalizers#52905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:7.4
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
4e66fc1
fea6eeb
aaccb9d
a130539
94ebc00
d9be208
d10be79
9475e96
9ee662b
09f9bd4
0d22403
606e24e
476baa0
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?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\PropertyInfo\Extractor; | ||
/** | ||
* @author Tobias Nyholm <tobias.nyholm@gmail.com> | ||
*/ | ||
class ConstructorArgumentTypeExtractorAggregate implements ConstructorArgumentTypeExtractorInterface | ||
{ | ||
/** | ||
* @param iterable<int, ConstructorArgumentTypeExtractorInterface> $extractors | ||
*/ | ||
public function __construct( | ||
private readonly iterable $extractors = [], | ||
) { | ||
} | ||
public function getTypesFromConstructor(string $class, string $property): ?array | ||
{ | ||
$output = []; | ||
foreach ($this->extractors as $extractor) { | ||
$value = $extractor->getTypesFromConstructor($class, $property); | ||
if (null !== $value) { | ||
$output[] = $value; | ||
} | ||
} | ||
if ([] === $output) { | ||
return null; | ||
} | ||
return array_merge([], ...$output); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -17,8 +17,6 @@ | ||
* Infers the constructor argument type. | ||
* | ||
* @author Dmitrii Poddubnyi <dpoddubny@gmail.com> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I'm not a huge fan, you did this because it's used in another component? Just ignore the error for internal use between components it's fine no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Yes. It is because I used it in another component. Do you know the reason why it is internal in the first place? | ||
*/ | ||
interface ConstructorArgumentTypeExtractorInterface | ||
{ | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Ignore paths | ||
[Tests/CodeGenerator/Fixtures/**] | ||
trim_trailing_whitespace = false | ||
[Tests/Fixtures/CustomNormalizer/**/ExpectedNormalizer/**] | ||
trim_trailing_whitespace = false | ||
insert_final_newline = false | ||
indent_size = unset | ||
indent_style = unset |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
vendor/ | ||
composer.lock | ||
phpunit.xml | ||
Tests/_output |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?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\Annotation; | ||
class_exists(\Symfony\Component\Serializer\Attribute\Serializable::class); | ||
if (false) { | ||
#[\Attribute(\Attribute::TARGET_CLASS)] | ||
class Serializable extends \Symfony\Component\Serializer\Attribute\Serializable | ||
{ | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?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\Attribute; | ||
/** | ||
* Classes with this attribute will get a custom normalizer to improve speed when | ||
* serializing/deserializing. | ||
* | ||
* @author Tobias Nyholm <tobias.nyholm@gmail.com> | ||
*/ | ||
#[\Attribute(\Attribute::TARGET_CLASS)] | ||
class Serializable | ||
{ | ||
} | ||
if (!class_exists(\Symfony\Component\Serializer\Annotation\Serializable::class, false)) { | ||
class_alias(Serializable::class, \Symfony\Component\Serializer\Annotation\Serializable::class); | ||
} | ||
Nyholm marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?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\Builder; | ||
/** | ||
* @author Tobias Nyholm <tobias.nyholm@gmail.com> | ||
* | ||
* @experimental in 7.1 | ||
*/ | ||
class BuildResult | ||
{ | ||
public function __construct( | ||
// The full file location where the class is stored | ||
public readonly string $filePath, | ||
// Just the class name | ||
public readonly string $className, | ||
// Class name with namespace | ||
public readonly string $classNs, | ||
) { | ||
} | ||
public function loadClass(): void | ||
{ | ||
require_once $this->filePath; | ||
} | ||
} |
Uh oh!
There was an error while loading.Please reload this page.