Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/Metadata/Extractor/YamlResourceExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,15 @@ private function buildResources(array $resourcesYaml, string $path): void
$resourceYaml = [$resourceYaml];
}

$resourcesCount = isset($this->resources[$resourceName]) ? \count($this->resources[$resourceName]) : 0;
foreach ($resourceYaml as $key => $resourceYamlDatum) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is key always an int @vincentchalamon ?

Copy link
Contributor

@vincentchalamon vincentchalamon Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm not sure that it's always an int, cf. https://github.com/api-platform/core/blob/main/src/Metadata/Tests/Extractor/yaml/valid.yaml

To be sure, it would be better to rely on an int variable declared out of this foreach and incremented accordingly.

if (null === $resourceYamlDatum) {
$resourceYamlDatum = [];
}

try {
$base = $this->buildExtendedBase($resourceYamlDatum);
$this->resources[$resourceName][$key] = array_merge($base, [
$this->resources[$resourceName][$resourcesCount + $key] = array_merge($base, [
'operations' => $this->buildOperations($resourceYamlDatum, $base),
'graphQlOperations' => $this->buildGraphQlOperations($resourceYamlDatum, $base),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function create(string $resourceClass): ResourceMetadataCollection
}
}

$resourceMetadataCollection[$i] = $resource;
$resourceMetadataCollection[] = $resource;
}

return $resourceMetadataCollection;
Expand Down