Skip to content

Commit bd1b079

Browse files
committed
minor #13670 [String] Deprecated the Inflector docs (javiereguiluz)
This PR was squashed before being merged into the master branch. Discussion ---------- [String] Deprecated the Inflector docs Fixes #13638. Commits ------- 495d2b0 [String] Deprecated the Inflector docs
2 parents 705e761 + 495d2b0 commit bd1b079

File tree

2 files changed

+42
-56
lines changed

2 files changed

+42
-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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,44 @@ the injected slugger is the same as the request locale::
507507
}
508508
}
509509

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy