Skip to content

Commit cff61ea

Browse files
authored
fix(metadata): append php file resource extractor (#7193)
1 parent cb0dd58 commit cff61ea

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/Metadata/Extractor/PhpFileResourceExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function extractPath(string $path): void
4343
$property->setValue($resource, $resolvedValue);
4444
}
4545

46-
$this->resources = [$resource];
46+
$this->resources[] = $resource;
4747
}
4848

4949
/**

src/Metadata/Tests/Extractor/PhpFileResourceExtractorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ final class PhpFileResourceExtractorTest extends TestCase
2121
{
2222
public function testItGetsResourcesFromPhpFileThatReturnsAnApiResource(): void
2323
{
24-
$extractor = new PhpFileResourceExtractor([__DIR__.'/php/valid_php_file.php']);
24+
$extractor = new PhpFileResourceExtractor([__DIR__.'/php/valid_php_file.php', __DIR__.'/php/another_valid_php_file.php']);
2525

26-
$expectedResource = new ApiResource(shortName: 'dummy');
26+
$expectedResources = [new ApiResource(shortName: 'dummy'), new ApiResource(shortName: 'another_dummy')];
2727

28-
$this->assertEquals([$expectedResource], $extractor->getResources());
28+
$this->assertEquals($expectedResources, $extractor->getResources());
2929
}
3030

3131
public function testItExcludesResourcesFromPhpFileThatDoesNotReturnAnApiResource(): void
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
use ApiPlatform\Metadata\ApiResource;
15+
16+
return new ApiResource(shortName: 'another_dummy');

0 commit comments

Comments
 (0)