Skip to content

Commit 27f2096

Browse files
authored
test: remove legacy inflector (#5656)
* test: remove legacy inflector * mongodb
1 parent 72817e6 commit 27f2096

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

src/Metadata/Util/Inflector.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,38 @@
2323
*/
2424
final class Inflector
2525
{
26-
private static bool $keepLegacyInflector;
26+
private static bool $keepLegacyInflector = true;
2727
private static ?LegacyInflector $instance = null;
2828

2929
private static function getInstance(): LegacyInflector
3030
{
31-
return self::$instance
32-
?? self::$instance = InflectorFactory::create()->build();
31+
return static::$instance
32+
?? static::$instance = InflectorFactory::create()->build();
3333
}
3434

3535
public static function keepLegacyInflector(bool $keepLegacyInflector): void
3636
{
37-
self::$keepLegacyInflector = $keepLegacyInflector;
37+
static::$keepLegacyInflector = $keepLegacyInflector;
3838
}
3939

4040
/**
4141
* @see InflectorObject::tableize()
4242
*/
4343
public static function tableize(string $word): string
4444
{
45-
if (!self::$keepLegacyInflector) {
45+
if (!static::$keepLegacyInflector) {
4646
return (new UnicodeString($word))->snake()->toString();
4747
}
4848

49-
return self::getInstance()->tableize($word);
49+
return static::getInstance()->tableize($word);
5050
}
5151

5252
/**
5353
* @see InflectorObject::pluralize()
5454
*/
5555
public static function pluralize(string $word): string
5656
{
57-
if (!self::$keepLegacyInflector) {
57+
if (!static::$keepLegacyInflector) {
5858
$pluralize = (new EnglishInflector())->pluralize($word);
5959

6060
return end($pluralize);

tests/Fixtures/TestBundle/Entity/DummyExceptionToStatus.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
#[ApiResource(
2727
exceptionToStatus: [NotFoundHttpException::class => 400],
2828
operations: [
29-
new Get(exceptionToStatus: [NotFoundException::class => 404]),
30-
new Put(),
31-
new GetCollection(),
29+
new Get(uriTemplate: '/dummy_exception_to_statuses/{id}', exceptionToStatus: [NotFoundException::class => 404]),
30+
new Put(uriTemplate: '/dummy_exception_to_statuses/{id}'),
31+
new GetCollection(uriTemplate: '/dummy_exception_to_statuses'),
3232
]
3333
)]
3434
#[ApiFilter(RequiredFilter::class)]

tests/Fixtures/TestBundle/Entity/SecuredDummyWithPropertiesDependingOnThemselves.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
*/
2828
#[ApiResource(
2929
operations: [
30-
new Get(),
31-
new Patch(inputFormats: ['json' => ['application/merge-patch+json'], 'jsonapi']),
32-
new Post(security: 'is_granted("ROLE_ADMIN")'),
30+
new Get(uriTemplate: '/secured_dummy_with_properties_depending_on_themselves/{id}'),
31+
new Patch(uriTemplate: '/secured_dummy_with_properties_depending_on_themselves/{id}', inputFormats: ['json' => ['application/merge-patch+json'], 'jsonapi']),
32+
new Post(uriTemplate: '/secured_dummy_with_properties_depending_on_themselves', security: 'is_granted("ROLE_ADMIN")'),
3333
]
3434
)]
3535
#[ORM\Entity]

tests/Fixtures/TestBundle/Resources/config/api_resources/resources.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ resources:
4646
- graphQlOperations: null
4747
operations:
4848
ApiPlatform\Metadata\GetCollection:
49+
uriTemplate: '/spoons'
4950
provider: ApiPlatform\Tests\Fixtures\TestBundle\State\FakeProvider
5051
- graphQlOperations: ~
5152
operations:

0 commit comments

Comments
 (0)