8000 [Serializer] Add support for auto generated custom normalizers by Nyholm · Pull Request #52905 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: 7.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CS
  • Loading branch information
Nyholm committed Jan 15, 2024
commit 9475e966296518667a302037ad46d58e373bd6d4
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
/src/Symfony/Component/Notifier/Bridge export-ignore
/src/Symfony/Component/Runtime export-ignore
/src/Symfony/Component/Translation/Bridge export-ignore

# Keep generated files from displaying in diffs by default
# https://docs.github.com/en/repositories/working-with-files/managing-files/customizing-how-changed-files-appear-on-github
/src/Symfony/Component/Intl/Resources/data/*/* linguist-generated=true
/src/Symfony/Component/Serializer/Tests/Fixtures/CustomNormalizer/*/ExpectedNormalizer/* linguist-generated=true
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
private DefinitionExtractor $definitionExtractor,
private array $paths,
private string $projectDir,
private ?LoggerInterface $logger = null
private ?LoggerInterface $logger = null,
) {
}

Expand All @@ -60,7 +60,7 @@ public function build(string $outputDir): iterable
}

$reflectionClass = new \ReflectionClass($classNs);
if ([] === $reflectionClass->getAttributes(Serializable::class)) {
if ([] === $reflectionClass->getAttributes(Serializable::class, \ReflectionAttribute::IS_INSTANCEOF)) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static function getDefinitionExtractor(): DefinitionExtractor
public static function getFixturesAndResultFiles(): iterable
{
$rootDir = \dirname(__DIR__).'/Fixtures/CustomNormalizer';

return [
NoTypeHints\PublicProperties::class => $rootDir.'/NoTypeHints/ExpectedNormalizer/PublicProperties.php',
NoTypeHints\ConstructorInjection::class => $rootDir.'/NoTypeHints/ExpectedNormalizer/ConstructorInjection.php',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public static function setUpBeforeClass(): void
}

/**
* If one does changes to the NormalizerBuilder, this test will probably fail.
* Run `php Tests/Builder/generateUpdatedFixtures.php` to update the fixtures.
*
* This will help reviewers to see the effect of the changes in the NormalizerBuilder.
*
* @dataProvider fixtureClassGenerator
*/
public function testBuildFixtures(string $inputClass, string $expectedOutputFile)
Expand Down
0