diff --git a/src/JsonSchema/Tests/fixtures/array-object-nullable/.jane b/src/JsonSchema/Tests/fixtures/array-object-nullable/.jane new file mode 100644 index 0000000000..854a0abcdc --- /dev/null +++ b/src/JsonSchema/Tests/fixtures/array-object-nullable/.jane @@ -0,0 +1,10 @@ + __DIR__ . '/schema.json', + 'root-class' => 'Test', + 'namespace' => 'Jane\JsonSchema\Tests\Expected', + 'directory' => __DIR__ . '/generated', + 'use-fixer' => false, + 'strict' => true, +]; diff --git a/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Model/Attributes.php b/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Model/Attributes.php new file mode 100644 index 0000000000..6d853ccc46 --- /dev/null +++ b/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Model/Attributes.php @@ -0,0 +1,34 @@ +foo; + } + /** + * + * + * @param string $foo + * + * @return self + */ + public function setFoo(string $foo) : self + { + $this->foo = $foo; + return $this; + } +} \ No newline at end of file diff --git a/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Model/Document.php b/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Model/Document.php new file mode 100644 index 0000000000..1c871bede6 --- /dev/null +++ b/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Model/Document.php @@ -0,0 +1,34 @@ +attributes; + } + /** + * + * + * @param Attributes[]|null $attributes + * + * @return self + */ + public function setAttributes(?array $attributes) : self + { + $this->attributes = $attributes; + return $this; + } +} \ No newline at end of file diff --git a/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Normalizer/AttributesNormalizer.php b/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Normalizer/AttributesNormalizer.php new file mode 100644 index 0000000000..7ebbc758b3 --- /dev/null +++ b/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Normalizer/AttributesNormalizer.php @@ -0,0 +1,50 @@ +{'$ref'})) { + return new Reference($data->{'$ref'}, $context['document-origin']); + } + if (isset($data->{'$recursiveRef'})) { + return new Reference($data->{'$recursiveRef'}, $context['document-origin']); + } + $object = new \Jane\JsonSchema\Tests\Expected\Model\Attributes(); + if (property_exists($data, 'foo')) { + $object->setFoo($data->{'foo'}); + } + return $object; + } + public function normalize($object, $format = null, array $context = array()) + { + $data = new \stdClass(); + if (null !== $object->getFoo()) { + $data->{'foo'} = $object->getFoo(); + } + return $data; + } +} \ No newline at end of file diff --git a/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Normalizer/DocumentNormalizer.php b/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Normalizer/DocumentNormalizer.php new file mode 100644 index 0000000000..1fdfe9415e --- /dev/null +++ b/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Normalizer/DocumentNormalizer.php @@ -0,0 +1,68 @@ +{'$ref'})) { + return new Reference($data->{'$ref'}, $context['document-origin']); + } + if (isset($data->{'$recursiveRef'})) { + return new Reference($data->{'$recursiveRef'}, $context['document-origin']); + } + $object = new \Jane\JsonSchema\Tests\Expected\Model\Document(); + if (property_exists($data, 'attributes')) { + $value = $data->{'attributes'}; + if (is_array($data->{'attributes'})) { + $values = array(); + foreach ($data->{'attributes'} as $value_1) { + $values[] = $this->denormalizer->denormalize($value_1, 'Jane\\JsonSchema\\Tests\\Expected\\Model\\Attributes', 'json', $context); + } + $value = $values; + } elseif (is_null($data->{'attributes'})) { + $value = $data->{'attributes'}; + } + $object->setAttributes($value); + } + return $object; + } + public function normalize($object, $format = null, array $context = array()) + { + $data = new \stdClass(); + $value = $object->getAttributes(); + if (is_array($object->getAttributes())) { + $values = array(); + foreach ($object->getAttributes() as $value_1) { + $values[] = $this->normalizer->normalize($value_1, 'json', $context); + } + $value = $values; + } elseif (is_null($object->getAttributes())) { + $value = $object->getAttributes(); + } + $data->{'attributes'} = $value; + return $data; + } +} \ No newline at end of file diff --git a/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Normalizer/NormalizerFactory.php b/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Normalizer/NormalizerFactory.php new file mode 100644 index 0000000000..9fed6cfab7 --- /dev/null +++ b/src/JsonSchema/Tests/fixtures/array-object-nullable/expected/Normalizer/NormalizerFactory.php @@ -0,0 +1,16 @@ +