annotationsReader = $annotationsReader; $this->modelRegister = new ModelRegister($modelRegistry); } public function updateDefinition(\ReflectionClass $reflectionClass, Schema $schema) { /** @var SwgDefinition $swgDefinition */ if (!$swgDefinition = $this->annotationsReader->getClassAnnotation($reflectionClass, SwgDefinition::class)) { return; } // Read @Model annotations $this->modelRegister->__invoke(new Analysis([$swgDefinition])); if (!$swgDefinition->validate()) { return; } $schema->merge(json_decode(json_encode($swgDefinition))); } public function getPropertyName(\ReflectionProperty $reflectionProperty, string $default): string { /** @var SwgProperty $swgProperty */ if (!$swgProperty = $this->annotationsReader->getPropertyAnnotation($reflectionProperty, SwgProperty::class)) { return $default; } return $swgProperty->property ?? $default; } public function updateProperty(\ReflectionProperty $reflectionProperty, Schema $property, array $serializationGroups = null) { if (!$swgProperty = $this->annotationsReader->getPropertyAnnotation($reflectionProperty, SwgProperty::class)) { return; } $declaringClass = $reflectionProperty->getDeclaringClass(); $context = new Context([ 'namespace' => $declaringClass->getNamespaceName(), 'class' => $declaringClass->getShortName(), 'property' => $reflectionProperty->name, 'filename' => $declaringClass->getFileName(), ]); $swgProperty->_context = $context; // Read @Model annotations $this->modelRegister->__invoke(new Analysis([$swgProperty]), $serializationGroups); if (!$swgProperty->validate()) { return; } $property->merge(json_decode(json_encode($swgProperty))); } }