janephp icon indicating copy to clipboard operation
janephp copied to clipboard

feat: derive JaneObjectNormalizer::getSupportedTypes from $this->norm…

Open dkarlovi opened this issue 9 months ago • 5 comments

…alizers

Closes #837

dkarlovi avatar Mar 11 '25 10:03 dkarlovi

@Korbeil this one is puzzling. :thinking:

dkarlovi avatar Mar 11 '25 10:03 dkarlovi

I was checking if I could put your PR in the release but it will need more work, in src/Component/JsonSchema/Tests/generated/Normalizer/JsonSchemaNormalizer.php you can see the base JsonSchema normalizer.

The getSupportedTypes method is containing following code:

public function getSupportedTypes(?string $format = null): array
{
    return array_combine(array_keys($this->normalizers), array_fill(0, count($this->normalizers), false));
}

But there is no $normalizers property in this class.

Korbeil avatar Apr 17 '25 13:04 Korbeil

@Korbeil it seems this class is somehow "special", like it's being generated by this code, but also by something else. :thinking:

What if we streamline it to look like all the other classes and add the normalizers property to it, even if it has only one entry?

dkarlovi avatar Apr 17 '25 13:04 dkarlovi

Yes it is ! the one in src/Component/JsonSchema/JsonSchema/Normalizer/JsonSchemaNormalizer.php is a generated version of the JsonSchema specification. And we do verify if our generation process is fine by generating it in tests: src/Component/JsonSchema/Tests/generated/Normalizer/JsonSchemaNormalizer.php.

Also, it's not only in this normalizer we don't have the $normalizers variable, usually we only have it in JaneObjectNormalizer classes (and there is only one per generated schema).

Korbeil avatar Apr 17 '25 13:04 Korbeil

That's what I meant: if we check the other normalizers, they have the single FQCN embedded in the method. What if we moved that one FQCN into the normalizers prop (which we add) and by that way we streamline all the normalizers? This way they're all basically the same structure.

dkarlovi avatar Apr 17 '25 15:04 dkarlovi

Hey, this PR seems stalled since last April, I'll close it for now, please re-open it if you have any time working on it :pray:

Korbeil avatar Sep 16 '25 11:09 Korbeil