Skip to content

Commit 48bc56e

Browse files
authored
feat(metadata): document BackwardCompatibleFilterDescriptionTrait as public API (#8326)
1 parent 6942dc0 commit 48bc56e

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

src/Metadata/BackwardCompatibleFilterDescriptionTrait.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@
1414
namespace ApiPlatform\Metadata;
1515

1616
/**
17-
* @author Vincent Amstoutz <vincent.amstoutz.dev@gmail.com>
17+
* Lets a filter satisfy the legacy FilterInterface::getDescription() requirement without implementing it by hand.
18+
*
19+
* Use this trait in a filter that does not need to describe itself through the deprecated getDescription() mechanism:
20+
* it returns an empty array, which is the expected value now that filters are described through QueryParameter metadata.
21+
* The trait will be removed in 6.0 together with FilterInterface::getDescription().
1822
*
19-
* @internal
23+
* @author Vincent Amstoutz <vincent.amstoutz.dev@gmail.com>
2024
*/
2125
trait BackwardCompatibleFilterDescriptionTrait
2226
{
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <dunglas@gmail.com>
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+
namespace ApiPlatform\Metadata\Tests;
15+
16+
use ApiPlatform\Metadata\BackwardCompatibleFilterDescriptionTrait;
17+
use PHPUnit\Framework\TestCase;
18+
19+
final class BackwardCompatibleFilterDescriptionTraitTest extends TestCase
20+
{
21+
public function testGetDescriptionReturnsEmptyArray(): void
22+
{
23+
$filter = new class {
24+
use BackwardCompatibleFilterDescriptionTrait;
25+
};
26+
27+
$this->assertSame([], $filter->getDescription('Foo'));
28+
}
29+
}

0 commit comments

Comments
 (0)