Skip to content

Commit 34492a4

Browse files
committed
[String] Deprecated the Inflector docs
1 parent f9c71c2 commit 34492a4

File tree

2 files changed

+38
-56
lines changed

2 files changed

+38
-56
lines changed

components/inflector.rst

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,8 @@
55
The Inflector Component
66
=======================
77

8-
The Inflector component converts English words between their singular and
9-
plural forms.
8+
.. deprecated:: 5.1
109

11-
Installation
12-
------------
13-
14-
.. code-block:: terminal
15-
16-
$ composer require symfony/inflector
17-
18-
.. include:: /components/require_autoload.rst.inc
19-
20-
When you May Need an Inflector
21-
------------------------------
22-
23-
In some scenarios such as code generation and code introspection, it's usually
24-
required to convert words from/to singular/plural. For example, if you need to
25-
know which property is associated with an *adder* method, you must convert from
26-
plural to singular (``addStories()`` method -> ``$story`` property).
27-
28-
Although most human languages define simple pluralization rules, they also
29-
define lots of exceptions. For example, the general rule in English is to add an
30-
``s`` at the end of the word (``book`` -> ``books``) but there are lots of
31-
exceptions even for common words (``woman`` -> ``women``, ``life`` -> ``lives``,
32-
``news`` -> ``news``, ``radius`` -> ``radii``, etc.)
33-
34-
This component abstracts all those pluralization rules so you can convert
35-
from/to singular/plural with confidence. However, due to the complexity of the
36-
human languages, this component only provides support for the English language.
37-
38-
Usage
39-
-----
40-
41-
The Inflector component provides two static methods to convert from/to
42-
singular/plural::
43-
44-
use Symfony\Component\Inflector\Inflector;
45-
46-
Inflector::singularize('alumni'); // 'alumnus'
47-
Inflector::singularize('knives'); // 'knife'
48-
Inflector::singularize('mice'); // 'mouse'
49-
50-
Inflector::pluralize('grandchild'); // 'grandchildren'
51-
Inflector::pluralize('news'); // 'news'
52-
Inflector::pluralize('bacterium'); // 'bacteria'
53-
54-
Sometimes it's not possible to determine a unique singular/plural form for the
55-
given word. In those cases, the methods return an array with all the possible
56-
forms::
57-
58-
use Symfony\Component\Inflector\Inflector;
59-
60-
Inflector::singularize('indices'); // ['index', 'indix', 'indice']
61-
Inflector::singularize('leaves'); // ['leaf', 'leave', 'leaff']
62-
63-
Inflector::pluralize('matrix'); // ['matricies', 'matrixes']
64-
Inflector::pluralize('person'); // ['persons', 'people']
10+
The Inflector component was deprecated in Symfony 5.1 and its code was moved
11+
into the :doc:`String </components/string>` component.
12+
:ref:`Read the new Inflector docs <string-inflector>`.

components/string.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,40 @@ the injected slugger is the same as the request locale::
507507
}
508508
}
509509

510+
.. _string-inflector:
511+
512+
Inflector
513+
---------
514+
515+
In some scenarios such as code generation and code introspection, you need to
516+
convert words from/to singular/plural. For example, to know the property
517+
associated with an *adder* method, you must convert from plural
518+
(``addStories()`` method) to singular (``$story`` property).
519+
520+
Most human languages have simple pluralization rules, but at the same time they
521+
define lots of exceptions. For example, the general rule in English is to add an
522+
``s`` at the end of the word (``book`` -> ``books``) but there are lots of
523+
exceptions even for common words (``woman`` -> ``women``, ``life`` -> ``lives``,
524+
``news`` -> ``news``, ``radius`` -> ``radii``, etc.)
525+
526+
This component provides an :class:`Symfony\\Component\\String\\Inflector\\EnglishInflector`
527+
class to convert English words from/to singular/plural with confidence::
528+
529+
use Symfony\Component\String\Inflector\EnglishInflector;
530+
531+
$inflector = new EnglishInflector();
532+
533+
$result = $inflector->singularize('teeth'); // ['tooth']
534+
$result = $inflector->singularize('radii'); // ['radius']
535+
$result = $inflector->singularize('leaves'); // ['leaf', 'leave', 'leaff']
536+
537+
$result = $inflector->pluralize('bacterium'); // ['bacteria']
538+
$result = $inflector->pluralize('news'); // ['news']
539+
$result = $inflector->pluralize('person'); // ['persons', 'people']
540+
541+
The value returned by both methods is always an array because sometimes it's not
542+
possible to determine a unique singular/plural form for the given word.
543+
510544
.. _`ASCII`: https://en.wikipedia.org/wiki/ASCII
511545
.. _`Unicode`: https://en.wikipedia.org/wiki/Unicode
512546
.. _`Code points`: https://en.wikipedia.org/wiki/Code_point

0 commit comments

Comments
 (0)