api-platform / api-platform/schema-generator

ambiguous EnglishInflector result may gives not expected adder/ remover method names

Abierto
#392 1 comentario 0 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
PHP
Estrellas
474
Forks
107
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

**Description**
Singularized form of adder/remover method name for collections is hardcoded to the first item from the list returned by EnglishInflector:
https://github.com/api-platform/schema-generator/blob/ed297c7e7c7670c23102176b22667efcaab8dcac/src/Model/Class_.php#L335

If transformation is ambiguous inflector return list of proposition, and in some cases first one it not we want to, for example:

```sh
$ php -r 'require "vendor/autoload.php"; echo (new Symfony\Component\String\Inflector\EnglishInflector())->singularize("languages")[0].PHP_EOL;'
languag
```

**How to reproduce**

```yaml
types:
Book:
properties:
languages:
cardinality: "(1..*)"
range: Language
```
gives:
```php
class Book
(...)
function addLanguag(Language $languag)
(...)
```

**Possible Solution**
- ability to use alternate inflector class (in.e., decoration of EnglishInflector)
- give singular form of given property in explicit by additional config paramater

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.