Skip to content

Commit

Permalink
Reenable classmap tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarlovi committed Jul 2, 2024
1 parent 05f4346 commit 17fe771
Show file tree
Hide file tree
Showing 29 changed files with 396 additions and 62 deletions.
10 changes: 4 additions & 6 deletions Generator/NormalizerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Jane\Component\JsonSchema\Generator\Normalizer\JaneObjectNormalizerGenerator;
use Jane\Component\JsonSchema\Generator\Normalizer\NormalizerGenerator as NormalizerGeneratorTrait;
use Jane\Component\JsonSchema\Registry\Schema;
use PhpParser\Comment;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Identifier;
Expand Down Expand Up @@ -181,18 +182,15 @@ function ($key, $value) {
new Expr\ClassConstFetch(
new Name\FullyQualified($key),
new Identifier('class')
)
),
attributes: ['comments' => [new Comment('')]]
);
},
array_keys($normalizers),
$normalizers,
)
),
)
);
if (isset($propertyStmt->default->items[0]) && $propertyStmt->default->items[0] instanceof Expr\ArrayItem) {
// force the array to be dumped multiline by adding a comment
$propertyStmt->default->items[0]->setAttribute('comments', [new \PhpParser\Comment('')]);
}
$properties[] = new Stmt\PropertyProperty('normalizersCache', new Expr\Array_());

$methods = [];
Expand Down
14 changes: 12 additions & 2 deletions JsonSchema/Normalizer/JaneObjectNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface
use NormalizerAwareTrait;
use CheckArray;
use ValidatorTrait;
protected $normalizers = [\Jane\Component\JsonSchema\JsonSchema\Model\JsonSchema::class => \Jane\Component\JsonSchema\JsonSchema\Normalizer\JsonSchemaNormalizer::class, \Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\JsonSchema\Runtime\Normalizer\ReferenceNormalizer::class], $normalizersCache = [];
protected $normalizers = [

\Jane\Component\JsonSchema\JsonSchema\Model\JsonSchema::class => \Jane\Component\JsonSchema\JsonSchema\Normalizer\JsonSchemaNormalizer::class,

\Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\JsonSchema\Runtime\Normalizer\ReferenceNormalizer::class,
], $normalizersCache = [];
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return array_key_exists($type, $this->normalizers);
Expand Down Expand Up @@ -63,7 +68,12 @@ class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface
use NormalizerAwareTrait;
use CheckArray;
use ValidatorTrait;
protected $normalizers = [\Jane\Component\JsonSchema\JsonSchema\Model\JsonSchema::class => \Jane\Component\JsonSchema\JsonSchema\Normalizer\JsonSchemaNormalizer::class, \Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\JsonSchema\Runtime\Normalizer\ReferenceNormalizer::class], $normalizersCache = [];
protected $normalizers = [

\Jane\Component\JsonSchema\JsonSchema\Model\JsonSchema::class => \Jane\Component\JsonSchema\JsonSchema\Normalizer\JsonSchemaNormalizer::class,

\Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\JsonSchema\Runtime\Normalizer\ReferenceNormalizer::class,
], $normalizersCache = [];
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return array_key_exists($type, $this->normalizers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface
use NormalizerAwareTrait;
use CheckArray;
use ValidatorTrait;
protected $normalizers = [\Jane\Component\JsonSchema\Tests\Expected\Model\AdditionalProperties::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\AdditionalPropertiesNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\PatternProperties::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\PatternPropertiesNormalizer::class, \Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class], $normalizersCache = [];
protected $normalizers = [

\Jane\Component\JsonSchema\Tests\Expected\Model\AdditionalProperties::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\AdditionalPropertiesNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\PatternProperties::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\PatternPropertiesNormalizer::class,

\Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class,
], $normalizersCache = [];
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return array_key_exists($type, $this->normalizers);
Expand Down Expand Up @@ -63,7 +70,14 @@ class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface
use NormalizerAwareTrait;
use CheckArray;
use ValidatorTrait;
protected $normalizers = [\Jane\Component\JsonSchema\Tests\Expected\Model\AdditionalProperties::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\AdditionalPropertiesNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\PatternProperties::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\PatternPropertiesNormalizer::class, \Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class], $normalizersCache = [];
protected $normalizers = [

\Jane\Component\JsonSchema\Tests\Expected\Model\AdditionalProperties::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\AdditionalPropertiesNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\PatternProperties::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\PatternPropertiesNormalizer::class,

\Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class,
], $normalizersCache = [];
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return array_key_exists($type, $this->normalizers);
Expand Down
38 changes: 36 additions & 2 deletions Tests/fixtures/all-of/expected/Normalizer/JaneObjectNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,24 @@ class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface
use NormalizerAwareTrait;
use CheckArray;
use ValidatorTrait;
protected $normalizers = [\Jane\Component\JsonSchema\Tests\Expected\Model\Test::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\TestNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\Otherchildtype::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\OtherchildtypeNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\Childtype::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\ChildtypeNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\Parenttype::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\ParenttypeNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\Foo::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\FooNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\Bar::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\BarNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\Baz::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\BazNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\BazBaz::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\BazBazNormalizer::class], $normalizersCache = [];
protected $normalizers = [

\Jane\Component\JsonSchema\Tests\Expected\Model\Test::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\TestNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\Otherchildtype::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\OtherchildtypeNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\Childtype::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\ChildtypeNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\Parenttype::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\ParenttypeNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\Foo::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\FooNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\Bar::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\BarNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\Baz::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\BazNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\BazBaz::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\BazBazNormalizer::class,
], $normalizersCache = [];
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return array_key_exists($type, $this->normalizers);
Expand Down Expand Up @@ -63,7 +80,24 @@ class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface
use NormalizerAwareTrait;
use CheckArray;
use ValidatorTrait;
protected $normalizers = [\Jane\Component\JsonSchema\Tests\Expected\Model\Test::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\TestNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\Otherchildtype::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\OtherchildtypeNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\Childtype::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\ChildtypeNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\Parenttype::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\ParenttypeNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\Foo::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\FooNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\Bar::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\BarNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\Baz::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\BazNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\BazBaz::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\BazBazNormalizer::class], $normalizersCache = [];
protected $normalizers = [

\Jane\Component\JsonSchema\Tests\Expected\Model\Test::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\TestNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\Otherchildtype::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\OtherchildtypeNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\Childtype::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\ChildtypeNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\Parenttype::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\ParenttypeNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\Foo::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\FooNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\Bar::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\BarNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\Baz::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\BazNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\BazBaz::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\BazBazNormalizer::class,
], $normalizersCache = [];
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return array_key_exists($type, $this->normalizers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface
use NormalizerAwareTrait;
use CheckArray;
use ValidatorTrait;
protected $normalizers = [\Jane\Component\JsonSchema\Tests\Expected\Model\Document::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\DocumentNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\Attributes::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\AttributesNormalizer::class, \Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class], $normalizersCache = [];
protected $normalizers = [

\Jane\Component\JsonSchema\Tests\Expected\Model\Document::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\DocumentNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\Attributes::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\AttributesNormalizer::class,

\Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class,
], $normalizersCache = [];
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return array_key_exists($type, $this->normalizers);
Expand Down Expand Up @@ -63,7 +70,14 @@ class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface
use NormalizerAwareTrait;
use CheckArray;
use ValidatorTrait;
protected $normalizers = [\Jane\Component\JsonSchema\Tests\Expected\Model\Document::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\DocumentNormalizer::class, \Jane\Component\JsonSchema\Tests\Expected\Model\Attributes::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\AttributesNormalizer::class, \Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class], $normalizersCache = [];
protected $normalizers = [

\Jane\Component\JsonSchema\Tests\Expected\Model\Document::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\DocumentNormalizer::class,

\Jane\Component\JsonSchema\Tests\Expected\Model\Attributes::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\AttributesNormalizer::class,

\Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class,
], $normalizersCache = [];
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return array_key_exists($type, $this->normalizers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface
use NormalizerAwareTrait;
use CheckArray;
use ValidatorTrait;
protected $normalizers = [\Jane\Component\JsonSchema\Tests\Expected\Model\Test::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\TestNormalizer::class, \Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class], $normalizersCache = [];
protected $normalizers = [

\Jane\Component\JsonSchema\Tests\Expected\Model\Test::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\TestNormalizer::class,

\Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class,
], $normalizersCache = [];
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return array_key_exists($type, $this->normalizers);
Expand Down Expand Up @@ -63,7 +68,12 @@ class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface
use NormalizerAwareTrait;
use CheckArray;
use ValidatorTrait;
protected $normalizers = [\Jane\Component\JsonSchema\Tests\Expected\Model\Test::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\TestNormalizer::class, \Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class], $normalizersCache = [];
protected $normalizers = [

\Jane\Component\JsonSchema\Tests\Expected\Model\Test::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\TestNormalizer::class,

\Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class,
], $normalizersCache = [];
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return array_key_exists($type, $this->normalizers);
Expand Down
14 changes: 12 additions & 2 deletions Tests/fixtures/date/expected/Normalizer/JaneObjectNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface
use NormalizerAwareTrait;
use CheckArray;
use ValidatorTrait;
protected $normalizers = [\Jane\Component\JsonSchema\Tests\Expected\Model\Test::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\TestNormalizer::class, \Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class], $normalizersCache = [];
protected $normalizers = [

\Jane\Component\JsonSchema\Tests\Expected\Model\Test::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\TestNormalizer::class,

\Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class,
], $normalizersCache = [];
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return array_key_exists($type, $this->normalizers);
Expand Down Expand Up @@ -63,7 +68,12 @@ class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface
use NormalizerAwareTrait;
use CheckArray;
use ValidatorTrait;
protected $normalizers = [\Jane\Component\JsonSchema\Tests\Expected\Model\Test::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\TestNormalizer::class, \Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class], $normalizersCache = [];
protected $normalizers = [

\Jane\Component\JsonSchema\Tests\Expected\Model\Test::class => \Jane\Component\JsonSchema\Tests\Expected\Normalizer\TestNormalizer::class,

\Jane\Component\JsonSchemaRuntime\Reference::class => \Jane\Component\JsonSchema\Tests\Expected\Runtime\Normalizer\ReferenceNormalizer::class,
], $normalizersCache = [];
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return array_key_exists($type, $this->normalizers);
Expand Down
Loading

0 comments on commit 17fe771

Please sign in to comment.