Skip to content

Commit 1ce8fb1

Browse files
committed
minor #5550 [docbot] Reviewed some component chapters (WouterJ)
This PR was merged into the 2.3 branch. Discussion ---------- [docbot] Reviewed some component chapters Commits ------- 0d28306 Fixed issues discovered by the human reviewers b85837f Reviewed EventDispatcher docs a045995 Fix BOM characters 01cdbf5 Reviewed some component chapters
2 parents 1302d3a + 0d28306 commit 1ce8fb1

29 files changed

+631
-570
lines changed

components/class_loader/class_loader.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ The PSR-0 Class Loader
77
.. versionadded:: 2.1
88
The ``ClassLoader`` class was introduced in Symfony 2.1.
99

10-
If your classes and third-party libraries follow the `PSR-0`_ standard, you
11-
can use the :class:`Symfony\\Component\\ClassLoader\\ClassLoader` class to
12-
load all of your project's classes.
10+
If your classes and third-party libraries follow the `PSR-0`_ standard,
11+
you can use the :class:`Symfony\\Component\\ClassLoader\\ClassLoader` class
12+
to load all of your project's classes.
1313

1414
.. tip::
1515

16-
You can use both the ``ApcClassLoader`` and the ``XcacheClassLoader`` to
17-
:doc:`cache </components/class_loader/cache_class_loader>` a ``ClassLoader``
16+
You can use both the ``ApcClassLoader`` and the ``XcacheClassLoader``
17+
to :doc:`cache </components/class_loader/cache_class_loader>` a ``ClassLoader``
1818
instance or the ``DebugClassLoader`` to :doc:`debug </components/class_loader/debug_class_loader>`
1919
it.
2020

@@ -39,12 +39,12 @@ is straightforward::
3939

4040
.. note::
4141

42-
The autoloader is automatically registered in a Symfony application (see
43-
``app/autoload.php``).
42+
The autoloader is automatically registered in a Symfony application
43+
(see ``app/autoload.php``).
4444

45-
Use the :method:`Symfony\\Component\\ClassLoader\\ClassLoader::addPrefix` or
46-
:method:`Symfony\\Component\\ClassLoader\\ClassLoader::addPrefixes` methods to
47-
register your classes::
45+
Use :method:`Symfony\\Component\\ClassLoader\\ClassLoader::addPrefix` or
46+
:method:`Symfony\\Component\\ClassLoader\\ClassLoader::addPrefixes` to register
47+
your classes::
4848

4949
// register a single namespaces
5050
$loader->addPrefix('Symfony', __DIR__.'/vendor/symfony/symfony/src');
@@ -63,9 +63,9 @@ register your classes::
6363
'Twig_' => __DIR__.'/vendor/twig/twig/lib',
6464
));
6565

66-
Classes from a sub-namespace or a sub-hierarchy of `PEAR`_ classes can be looked
67-
for in a location list to ease the vendoring of a sub-set of classes for large
68-
projects::
66+
Classes from a sub-namespace or a sub-hierarchy of `PEAR`_ classes can be
67+
looked for in a location list to ease the vendoring of a sub-set of classes
68+
for large projects::
6969

7070
$loader->addPrefixes(array(
7171
'Doctrine\\Common' => __DIR__.'/vendor/doctrine/common/lib',
@@ -75,10 +75,10 @@ projects::
7575
));
7676

7777
In this example, if you try to use a class in the ``Doctrine\Common`` namespace
78-
or one of its children, the autoloader will first look for the class under the
79-
``doctrine-common`` directory. If not found, it will then fallback to the default
80-
``Doctrine`` directory (the last one configured) before giving up. The order
81-
of the prefix registrations is significant in this case.
78+
or one of its children, the autoloader will first look for the class under
79+
the ``doctrine-common`` directory. If not found, it will then fallback to
80+
the default ``Doctrine`` directory (the last one configured) before giving
81+
up. The order of the prefix registrations is significant in this case.
8282

8383
.. _PEAR: http://pear.php.net/manual/en/standards.naming.php
8484
.. _PSR-0: http://www.php-fig.org/psr/psr-0/

components/class_loader/class_map_generator.rst

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
The Class Map Generator
66
=======================
77

8-
Loading a class usually is an easy task given the `PSR-0`_ and `PSR-4`_ standards.
9-
Thanks to the Symfony ClassLoader component or the autoloading mechanism provided
10-
by Composer, you don't have to map your class names to actual PHP files manually.
11-
Nowadays, PHP libraries usually come with autoloading support through Composer.
8+
Loading a class usually is an easy task given the `PSR-0`_ and `PSR-4`_
9+
standards. Thanks to the Symfony ClassLoader component or the autoloading
10+
mechanism provided by Composer, you don't have to map your class names to
11+
actual PHP files manually. Nowadays, PHP libraries usually come with autoloading
12+
support through Composer.
1213

1314
But from time to time you may have to use a third-party library that comes
1415
without any autoloading support and therefore forces you to load each class
@@ -44,16 +45,17 @@ it possible to create a map of class names to files.
4445
Generating a Class Map
4546
----------------------
4647

47-
To generate the class map, simply pass the root directory of your class files
48-
to the :method:`Symfony\\Component\\ClassLoader\\ClassMapGenerator::createMap`
48+
To generate the class map, simply pass the root directory of your class
49+
files to the
50+
:method:`Symfony\\Component\\ClassLoader\\ClassMapGenerator::createMap`
4951
method::
5052

5153
use Symfony\Component\ClassLoader\ClassMapGenerator;
5254

5355
var_dump(ClassMapGenerator::createMap(__DIR__.'/library'));
5456

55-
Given the files and class from the table above, you should see an output like
56-
this:
57+
Given the files and class from the table above, you should see an output
58+
like this:
5759

5860
.. code-block:: text
5961
@@ -87,8 +89,9 @@ file in the same directory with the following contents::
8789
'Acme\\Bar' => '/var/www/library/bar/Foo.php',
8890
);
8991

90-
Instead of loading each file manually, you'll only have to register the generated
91-
class map with, for example, the :class:`Symfony\\Component\\ClassLoader\\MapClassLoader`::
92+
Instead of loading each file manually, you'll only have to register the
93+
generated class map with, for example, the
94+
:class:`Symfony\\Component\\ClassLoader\\MapClassLoader`::
9295

9396
use Symfony\Component\ClassLoader\MapClassLoader;
9497

@@ -110,8 +113,8 @@ class map with, for example, the :class:`Symfony\\Component\\ClassLoader\\MapCla
110113
component.
111114

112115
Besides dumping the class map for one directory, you can also pass an array
113-
of directories for which to generate the class map (the result actually is
114-
the same as in the example above)::
116+
of directories for which to generate the class map (the result actually
117+
is the same as in the example above)::
115118

116119
use Symfony\Component\ClassLoader\ClassMapGenerator;
117120

components/class_loader/debug_class_loader.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Debugging a Class Loader
77
.. versionadded:: 2.1
88
The ``DebugClassLoader`` class was introduced in Symfony 2.1.
99

10-
The :class:`Symfony\\Component\\ClassLoader\\DebugClassLoader` attempts to
11-
throw more helpful exceptions when a class isn't found by the registered
12-
autoloaders. All autoloaders that implement a ``findFile()`` method are replaced
13-
with a ``DebugClassLoader`` wrapper.
10+
The :class:`Symfony\\Component\\ClassLoader\\DebugClassLoader` attempts
11+
to throw more helpful exceptions when a class isn't found by the registered
12+
autoloaders. All autoloaders that implement a ``findFile()`` method are
13+
replaced with a ``DebugClassLoader`` wrapper.
1414

1515
Using the ``DebugClassLoader`` is as easy as calling its static
1616
:method:`Symfony\\Component\\ClassLoader\\DebugClassLoader::enable` method::

components/class_loader/introduction.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ Usage
1111
-----
1212

1313
Whenever you reference a class that has not been required or included yet,
14-
PHP uses the `autoloading mechanism`_ to delegate the loading of a file defining
15-
the class. Symfony provides two autoloaders, which are able to load your classes:
14+
PHP uses the `autoloading mechanism`_ to delegate the loading of a file
15+
defining the class. Symfony provides two autoloaders, which are able to
16+
load your classes:
1617

1718
* :doc:`/components/class_loader/class_loader`: loads classes that follow
18-
the `PSR-0` class naming standard;
19+
the `PSR-0`_ class naming standard;
1920

2021
* :doc:`/components/class_loader/map_class_loader`: loads classes using
2122
a static map from class name to file path.
@@ -38,5 +39,6 @@ You can install the component in 2 different ways:
3839

3940
.. include:: /components/require_autoload.rst.inc
4041

42+
.. _PSR-0: http://www.php-fig.org/psr/psr-0/
4143
.. _`autoloading mechanism`: http://php.net/manual/en/language.oop5.autoload.php
4244
.. _Packagist: https://packagist.org/packages/symfony/class-loader

components/class_loader/map_class_loader.rst

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44
MapClassLoader
55
==============
66

7-
The :class:`Symfony\\Component\\ClassLoader\\MapClassLoader` allows you to
8-
autoload files via a static map from classes to files. This is useful if you
9-
use third-party libraries which don't follow the `PSR-0`_ standards and so
10-
can't use the :doc:`PSR-0 class loader </components/class_loader/class_loader>`.
7+
The :class:`Symfony\\Component\\ClassLoader\\MapClassLoader` allows you
8+
to autoload files via a static map from classes to files. This is useful
9+
if you use third-party libraries which don't follow the `PSR-0`_ standards
10+
and so can't use the
11+
:doc:`PSR-0 class loader </components/class_loader/class_loader>`.
1112

12-
The ``MapClassLoader`` can be used along with the :doc:`PSR-0 class loader </components/class_loader/class_loader>`
13-
by configuring and calling the ``register()`` method on both.
13+
The ``MapClassLoader`` can be used along with the
14+
:doc:`PSR-0 class loader </components/class_loader/class_loader>` by
15+
configuring and calling the ``register()`` method on both.
1416

1517
.. note::
1618

1719
The default behavior is to append the ``MapClassLoader`` on the autoload
18-
stack. If you want to use it as the first autoloader, pass ``true`` when
19-
calling the ``register()`` method. Your class loader will then be prepended
20-
on the autoload stack.
20+
stack. If you want to use it as the first autoloader, pass ``true``
21+
when calling the ``register()`` method. Your class loader will then
22+
be prepended on the autoload stack.
2123

2224
Usage
2325
-----

components/config/caching.rst

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
.. index::
22
single: Config; Caching based on resources
33

4-
Caching Based on Resources
4+
Caching based on Resources
55
==========================
66

7-
When all configuration resources are loaded, you may want to process the configuration
8-
values and combine them all in one file. This file acts like a cache. Its
9-
contents don’t have to be regenerated every time the application runs – only
10-
when the configuration resources are modified.
7+
When all configuration resources are loaded, you may want to process the
8+
configuration values and combine them all in one file. This file acts
9+
like a cache. Its contents don’t have to be regenerated every time the
10+
application runs – only when the configuration resources are modified.
1111

1212
For example, the Symfony Routing component allows you to load all routes,
1313
and then dump a URL matcher or a URL generator based on these routes. In
14-
this case, when one of the resources is modified (and you are working in a
15-
development environment), the generated file should be invalidated and regenerated.
16-
This can be accomplished by making use of the :class:`Symfony\\Component\\Config\\ConfigCache`
17-
class.
18-
19-
The example below shows you how to collect resources, then generate some code
20-
based on the resources that were loaded, and write this code to the cache. The
21-
cache also receives the collection of resources that were used for generating
22-
the code. By looking at the "last modified" timestamp of these resources,
23-
the cache can tell if it is still fresh or that its contents should be regenerated::
14+
this case, when one of the resources is modified (and you are working
15+
in a development environment), the generated file should be invalidated
16+
and regenerated. This can be accomplished by making use of the
17+
:class:`Symfony\\Component\\Config\\ConfigCache` class.
18+
19+
The example below shows you how to collect resources, then generate some
20+
code based on the resources that were loaded and write this code to the
21+
cache. The cache also receives the collection of resources that were used
22+
for generating the code. By looking at the "last modified" timestamp of
23+
these resources, the cache can tell if it is still fresh or that its contents
24+
should be regenerated::
2425

2526
use Symfony\Component\Config\ConfigCache;
2627
use Symfony\Component\Config\Resource\FileResource;
@@ -52,8 +53,8 @@ the cache can tell if it is still fresh or that its contents should be regenerat
5253
// you may want to require the cached code:
5354
require $cachePath;
5455

55-
In debug mode, a ``.meta`` file will be created in the same directory as the
56-
cache file itself. This ``.meta`` file contains the serialized resources,
57-
whose timestamps are used to determine if the cache is still fresh. When not
58-
in debug mode, the cache is considered to be "fresh" as soon as it exists,
56+
In debug mode, a ``.meta`` file will be created in the same directory as
57+
the cache file itself. This ``.meta`` file contains the serialized resources,
58+
whose timestamps are used to determine if the cache is still fresh. When
59+
not in debug mode, the cache is considered to be "fresh" as soon as it exists,
5960
and therefore no ``.meta`` file will be generated.

0 commit comments

Comments
 (0)