Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/Bridge/NelmioApiDoc/Parser/ApiPlatformParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ private function parseProperty(ResourceMetadata $resourceMetadata, PropertyMetad
}

if (
(self::OUT_PREFIX === $io && !$propertyMetadata->isReadableLink()) ||
(self::IN_PREFIX === $io && !$propertyMetadata->isWritableLink())
(self::OUT_PREFIX === $io && true !== $propertyMetadata->isReadableLink()) ||
(self::IN_PREFIX === $io && true !== $propertyMetadata->isWritableLink())
) {
$data['dataType'] = self::TYPE_IRI;
$data['actualType'] = DataTypes::STRING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ public function create(string $resourceClass, string $name, array $options = [])
}
}

if (null === $propertyMetadata->getDescription()) {
$propertyMetadata = $propertyMetadata->withDescription($this->propertyInfo->getShortDescription($resourceClass, $name, $options));
if (null === $propertyMetadata->getDescription() && null !== $description = $this->propertyInfo->getShortDescription($resourceClass, $name, $options)) {
$propertyMetadata = $propertyMetadata->withDescription($description);
}

if (null === $propertyMetadata->isReadable()) {
$propertyMetadata = $propertyMetadata->withReadable($this->propertyInfo->isReadable($resourceClass, $name, $options));
if (null === $propertyMetadata->isReadable() && null !== $readable = $this->propertyInfo->isReadable($resourceClass, $name, $options)) {
$propertyMetadata = $propertyMetadata->withReadable($readable);
}

if (null === $propertyMetadata->isWritable()) {
$propertyMetadata = $propertyMetadata->withWritable($this->propertyInfo->isWritable($resourceClass, $name, $options));
if (null === $propertyMetadata->isWritable() && null !== $writable = $this->propertyInfo->isWritable($resourceClass, $name, $options)) {
$propertyMetadata = $propertyMetadata->withWritable($writable);
}

return $propertyMetadata;
Expand Down
2 changes: 1 addition & 1 deletion src/Hal/Serializer/CollectionNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function normalize($object, $format = null, array $context = [])
}

$resourceClass = $this->resourceClassResolver->getResourceClass($object, $context['resource_class'] ?? null, true);
$context = $this->initContext($resourceClass, $context, $format);
$context = $this->initContext($resourceClass, $context);
$parsed = IriHelper::parseIri($context['request_uri'] ?? '/', $this->pageParameterName);
$paginated = $isPaginator = $object instanceof PaginatorInterface;

Expand Down
5 changes: 2 additions & 3 deletions src/Hal/Serializer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ public function normalize($object, $format = null, array $context = [])
return $rawData;
}

$data['_links']['self']['href'] = $this->iriConverter->getIriFromItem($object);

$data = ['_links' => ['self' => ['href' => $this->iriConverter->getIriFromItem($object)]]];
$components = $this->getComponents($object, $format, $context);
$data = $this->populateRelation($data, $object, $format, $context, $components, 'links');
$data = $this->populateRelation($data, $object, $format, $context, $components, 'embedded');

return array_merge($data, $rawData);
return $data + $rawData;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/JsonLd/ContextBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function getResourceContext(string $resourceClass, int $referenceType = U
foreach ($this->propertyNameCollectionFactory->create($resourceClass) as $propertyName) {
$propertyMetadata = $this->propertyMetadataFactory->create($resourceClass, $propertyName);

if ($propertyMetadata->isIdentifier() && !$propertyMetadata->isWritable()) {
if ($propertyMetadata->isIdentifier() && true !== $propertyMetadata->isWritable()) {
continue;
}

Expand All @@ -102,7 +102,7 @@ public function getResourceContext(string $resourceClass, int $referenceType = U
$id = sprintf('%s/%s', $prefixedShortName, $convertedName);
}

if (!$propertyMetadata->isReadableLink()) {
if (true !== $propertyMetadata->isReadableLink()) {
$context[$convertedName] = [
'@id' => $id,
'@type' => '@id',
Expand Down
12 changes: 6 additions & 6 deletions src/Metadata/Resource/ResourceMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ public function getItemOperationAttribute(string $operationName, string $key, $d
/**
* Gets an operation attribute, optionally fallback to a resource attribute.
*
* @param array $operations
* @param string $operationName
* @param string $key
* @param mixed $defaultValue
* @param bool $resourceFallback
* @param array|null $operations
* @param string $operationName
* @param string $key
* @param mixed $defaultValue
* @param bool $resourceFallback
*
* @return mixed
*/
private function getOperationAttribute(array $operations, string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
private function getOperationAttribute(array $operations = null, string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
{
if (isset($operations[$operationName][$key])) {
return $operations[$operationName][$key];
Expand Down
10 changes: 5 additions & 5 deletions src/Serializer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ final class ItemNormalizer extends AbstractItemNormalizer
*/
public function normalize($object, $format = null, array $context = [])
{
$rawData = parent::normalize($object, $format, $context);
if (!is_array($rawData)) {
return $rawData;
$data = parent::normalize($object, $format, $context);
if (!is_array($data)) {
return $data;
}

if (!isset($data['id'])) {
$data['id'] = $this->iriConverter->getIriFromItem($object);
$data = ['id' => $this->iriConverter->getIriFromItem($object)] + $data;
}

return array_merge($data, $rawData);
return $data;
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/Swagger/Serializer/DocumentationNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,13 +459,18 @@ private function getPropertySchema(PropertyMetadata $propertyMetadata) : \ArrayO

private function computeDoc(Documentation $object, \ArrayObject $definitions, \ArrayObject $paths): array
{
$doc['swagger'] = self::SWAGGER_VERSION;
$doc['info']['title'] = $object->getTitle();
$doc = [
'swagger' => self::SWAGGER_VERSION,
'info' => ['title' => $object->getTitle()],
];

if ('' !== $object->getDescription()) {
$doc['info']['description'] = $object->getDescription();
}

$doc['info']['version'] = $object->getVersion();
$doc['paths'] = $paths;

if (count($definitions) > 0) {
$doc['definitions'] = $definitions;
}
Expand Down