Skip to content

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

@PawelSuwinski

Description

@PawelSuwinski

Description
Singularized form of adder/remover method name for collections is hardcoded to the first item from the list returned by EnglishInflector:

return $inflector->singularize($string)[0];

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

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

How to reproduce

types:
  Book:
    properties:
      languages:
        cardinality: "(1..*)"
        range: Language

gives:

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions