How doctrine/inflector works
Doctrine Inflector is a PHP library for word singularization/pluralization and related string formatting. A caller selects a language factory (or configures one directly), builds an Inflector, and invokes transformations such as singularize or pluralize. The runtime combines language-specific regular, irregular, and uninflected rules, with general-purpose transformations and an optional cache. Language rule directories define the supported linguistic behavior. Edges reflect the shown excerpts, source-index references, or README; unsampled implementation details are not inferred.
Main entry points: Rules Rule Primitives · Inflector.php String Inflector · GenericLanguageInflectorFactory.php Generic Factory · WordInflector.php Word Inflector
Components 20
Public API
- Inflector Factory
src/InflectorFactory.php - Language
src/Language.php - Language Factory
src/LanguageInflectorFactory.php - Generic Factory
src/GenericLanguageInflectorFactory.php - String Inflector
src/Inflector.php - Cached Inflector
src/CachedWordInflector.php - No-op Inflector
src/NoopWordInflector.php
Inflection Engine
- Word Inflector
src/WordInflector.php - Ruleset Inflector
src/RulesetInflector.php - Ruleset
src/Rules/Ruleset.php - Rule Primitives
src/Rules
Language Rules
- English Rules
src/Rules/English - Esperanto Rules
src/Rules/Esperanto - French Rules
src/Rules/French - Italian Rules
src/Rules/Italian - Norwegian Bokmål Rules
src/Rules/NorwegianBokmal - Portuguese Rules
src/Rules/Portuguese - Spanish Rules
src/Rules/Spanish - Turkish Rules
src/Rules/Turkish
Other components
- Library Caller
Connections 24
- Library Caller → Inflector Factory: requests inflector
- Inflector Factory → Language: selects language
src/InflectorFactory.php - Inflector Factory → Language Factory: creates factory
src/InflectorFactory.php - Generic Factory → Language Factory: implements
src/GenericLanguageInflectorFactory.php - Generic Factory → Ruleset Inflector: builds
src/GenericLanguageInflectorFactory.php - Generic Factory → String Inflector: builds
src/GenericLanguageInflectorFactory.php - Generic Factory → Cached Inflector: wraps inflector
src/GenericLanguageInflectorFactory.php - Library Caller → String Inflector: inflects words
README.md - String Inflector → Word Inflector: delegates singular/plural
src/Inflector.php - Cached Inflector → Word Inflector: implements
src/CachedWordInflector.php - No-op Inflector → Word Inflector: implements
src/NoopWordInflector.php - Ruleset Inflector → Ruleset: uses rules
src/RulesetInflector.php - Ruleset Inflector → Word Inflector: implements
src/RulesetInflector.php - Ruleset → Rule Primitives: contains rule sets
src/Rules/Ruleset.php - English Rules → Rule Primitives: defines transformations
src/Rules/English/Rules.php - Esperanto Rules → Rule Primitives: defines transformations
src/Rules/Esperanto/Rules.php - French Rules → Rule Primitives: defines transformations
src/Rules/French/Rules.php - Italian Rules → Rule Primitives: defines transformations
src/Rules/Italian/Rules.php - Norwegian Bokmål Rules → Rule Primitives: defines transformations
src/Rules/NorwegianBokmal/Rules.php - Portuguese Rules → Rule Primitives: defines transformations
src/Rules/Portuguese/Rules.php - Spanish Rules → Rule Primitives: defines transformations
src/Rules/Spanish/Rules.php - Turkish Rules → Rule Primitives: defines transformations
src/Rules/Turkish/Rules.php - English Rules → String Inflector: provides English rules
src/Rules/English/Inflectible.php - Italian Rules → String Inflector: provides Italian rules
src/Rules/Italian/Inflectible.php