Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 13a9b18

Browse filesBrowse files
committed
minor #8246 Mention and recommend to use PHP-CS-Fixer when contributing code (javiereguiluz)
This PR was squashed before being merged into the 2.7 branch (closes #8246). Discussion ---------- Mention and recommend to use PHP-CS-Fixer when contributing code This article is intimidating because it looks like you have to manually review a hundred things. However, you just need to execute 1 command ... and if you forget to execute it, that's OK because we have "fabbot" to help you. Commits ------- 8bee654 Mention and recommend to use PHP-CS-Fixer when contributing code
2 parents 8ff6306 + 8bee654 commit 13a9b18
Copy full SHA for 13a9b18

File tree

Expand file treeCollapse file tree

1 file changed

+32
-15
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+32
-15
lines changed

‎contributing/code/standards.rst

Copy file name to clipboardExpand all lines: contributing/code/standards.rst
+32-15Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
Coding Standards
22
================
33

4-
When contributing code to Symfony, you must follow its coding standards. To
5-
make a long story short, here is the golden rule: **Imitate the existing
6-
Symfony code**. Most open-source Bundles and libraries used by Symfony also
7-
follow the same guidelines, and you should too.
4+
Symfony code is contributed by thousands of developers around the world. To make
5+
every piece of code look and feel familiar, Symfony defines some coding standards
6+
that all contributions must follow.
87

9-
Remember that the main advantage of standards is that every piece of code
10-
looks and feels familiar, it's not about this or that being more readable.
8+
These Symfony coding standards are based on the `PSR-1`_, `PSR-2`_ and `PSR-4`_
9+
standards, so you may already know most of them.
1110

12-
Symfony follows the standards defined in the `PSR-0`_, `PSR-1`_, `PSR-2`_ and `PSR-4`_
13-
documents.
11+
Making your Code Follow the Coding Standards
12+
--------------------------------------------
1413

15-
Since a picture - or some code - is worth a thousand words, here's a short
16-
example containing most features described below:
14+
Instead of reviewing your code manually, Symfony makes it simple to ensure that
15+
your contributed code matches the expected code syntax. First, install the
16+
`PHP CS Fixer tool`_ and then, run this command to fix any problem:
17+
18+
.. code-block:: terminal
19+
20+
$ cd your-project/
21+
$ php php-cs-fixer.phar fix -v
22+
23+
If you forget to run this command and make a pull request with any syntax issue,
24+
our automated tools will warn you about that and will provide the solution.
25+
26+
Symfony Coding Standards in Detail
27+
----------------------------------
28+
29+
If you want to learn about the Symfony coding standards in detail, here's a
30+
short example containing most features described below:
1731

1832
.. code-block:: html+php
1933

@@ -122,7 +136,7 @@ example containing most features described below:
122136
}
123137

124138
Structure
125-
---------
139+
~~~~~~~~~
126140

127141
* Add a single space after each comma delimiter;
128142

@@ -181,7 +195,7 @@ Structure
181195
* Do not use spaces around ``[`` offset accessor and before ``]`` offset accessor.
182196

183197
Naming Conventions
184-
------------------
198+
~~~~~~~~~~~~~~~~~~
185199

186200
* Use camelCase, not underscores, for variable, function and method
187201
names, arguments;
@@ -224,7 +238,7 @@ Service Naming Conventions
224238
* A group name uses the underscore notation.
225239

226240
Documentation
227-
-------------
241+
~~~~~~~~~~~~~
228242

229243
* Add PHPDoc blocks for all classes, methods, and functions (though you may
230244
be asked to remove PHPDoc that do not add value);
@@ -235,14 +249,17 @@ Documentation
235249

236250
* Omit the ``@return`` tag if the method does not return anything;
237251

238-
* The ``@package`` and ``@subpackage`` annotations are not used.
252+
* The ``@package`` and ``@subpackage`` annotations are not used;
253+
254+
* Inline the ``@inheritdoc`` tag.
239255

240256
License
241-
-------
257+
~~~~~~~
242258

243259
* Symfony is released under the MIT license, and the license block has to be
244260
present at the top of every PHP file, before the namespace.
245261

262+
.. _`PHP CS Fixer tool`: http://cs.sensiolabs.org/
246263
.. _`PSR-0`: http://www.php-fig.org/psr/psr-0/
247264
.. _`PSR-1`: http://www.php-fig.org/psr/psr-1/
248265
.. _`PSR-2`: http://www.php-fig.org/psr/psr-2/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.