Skip to content

Commit

Permalink
[all langs] cakephp#3766 & [fr] cakephp#3767
Browse files Browse the repository at this point in the history
  • Loading branch information
cake17 committed Feb 21, 2016
1 parent adc059b commit ada7578
Show file tree
Hide file tree
Showing 14 changed files with 187 additions and 99 deletions.
149 changes: 75 additions & 74 deletions en/contributing/cakephp-coding-conventions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Coding Standards
################

CakePHP developers will use the `PSR-2 coding style guide
<http://www.php-fig.org/psr/psr-2/>`_ in addition to the following
rules as coding standards.
<http://www.php-fig.org/psr/psr-2/>`_ in addition to the following rules as
coding standards.

It is recommended that others developing CakeIngredients follow the same
standards.
Expand Down Expand Up @@ -66,8 +66,8 @@ Use this instead::
Line Length
===========

It is recommended to keep lines at approximately 100 characters long for better code readability.
Lines must not be longer than 120 characters.
It is recommended to keep lines at approximately 100 characters long for better
code readability. Lines must not be longer than 120 characters.

In short:

Expand All @@ -88,18 +88,17 @@ Control structures are for example "``if``", "``for``", "``foreach``",
// default_action;
}

* In the control structures there should be 1 (one) space before the
first parenthesis and 1 (one) space between the last parenthesis and
the opening bracket.
* Always use curly brackets in control structures, even if they are not
needed. They increase the readability of the code, and they give you
fewer logical errors.
* Opening curly brackets should be placed on the same line as the
control structure. Closing curly brackets should be placed on new
lines, and they should have same indentation level as the control
structure. The statement included in curly brackets should begin on a
new line, and code contained within it should gain a new level of
indentation.
* In the control structures there should be 1 (one) space before the first
parenthesis and 1 (one) space between the last parenthesis and the opening
bracket.
* Always use curly brackets in control structures, even if they are not needed.
They increase the readability of the code, and they give you fewer logical
errors.
* Opening curly brackets should be placed on the same line as the control
structure. Closing curly brackets should be placed on new lines, and they
should have same indentation level as the control structure. The statement
included in curly brackets should begin on a new line, and code contained
within it should gain a new level of indentation.
* Inline assignments should not be used inside of the control structures.

::
Expand Down Expand Up @@ -130,11 +129,10 @@ Control structures are for example "``if``", "``for``", "``foreach``",
Ternary Operator
----------------

Ternary operators are permissible when the entire ternary operation fits
on one line. Longer ternaries should be split into ``if else``
statements. Ternary operators should not ever be nested. Optionally
parentheses can be used around the condition check of the ternary for
clarity::
Ternary operators are permissible when the entire ternary operation fits on one
line. Longer ternaries should be split into ``if else`` statements. Ternary
operators should not ever be nested. Optionally parentheses can be used around
the condition check of the ternary for clarity::

// Good, simple and readable
$variable = isset($options['variable']) ? $options['variable'] : true;
Expand Down Expand Up @@ -165,13 +163,13 @@ tags::
Comparison
==========

Always try to be as strict as possible. If a none strict test is deliberate it might be wise to
comment it as such to avoid confusing it for a mistake.
Always try to be as strict as possible. If a none strict test is deliberate it
might be wise to comment it as such to avoid confusing it for a mistake.

For testing if a variable is null, it is recommended to use a strict check::

if ($value === null) {
// ...
// ...
}

The value to check against should be placed on the right side::
Expand All @@ -189,14 +187,13 @@ The value to check against should be placed on the right side::
Function Calls
==============

Functions should be called without space between function's name and
starting parenthesis. There should be one space between every parameter of a
function call::
Functions should be called without space between function's name and starting
parenthesis. There should be one space between every parameter of a function
call::

$var = foo($bar, $bar2, $bar3);

As you can see above there should be one space on both sides of equals
sign (=).
As you can see above there should be one space on both sides of equals sign (=).

Method Definition
=================
Expand All @@ -211,10 +208,9 @@ Example of a method definition::
return $var;
}

Parameters with a default value, should be placed last in function
definition. Try to make your functions return something, at least ``true``
or ``false``, so it can be determined whether the function call was
successful::
Parameters with a default value, should be placed last in function definition.
Try to make your functions return something, at least ``true`` or ``false``, so
it can be determined whether the function call was successful::

public function connection($dns, $persistent = false)
{
Expand Down Expand Up @@ -250,11 +246,12 @@ We only typehint public methods, though, as typehinting is not cost-free::
{
}

Here ``$table`` must be an instance of ``\Cake\ORM\Table``, ``$array`` must be an ``array`` and
``$callback`` must be of type ``callable`` (a valid callback).
Here ``$table`` must be an instance of ``\Cake\ORM\Table``, ``$array`` must be
an ``array`` and ``$callback`` must be of type ``callable`` (a valid callback).

Note that if you want to allow ``$array`` to be also an instance of ``\ArrayObject``
you should not typehint as ``array`` accepts only the primitive type::
Note that if you want to allow ``$array`` to be also an instance of
``\ArrayObject`` you should not typehint as ``array`` accepts only the primitive
type::

/**
* Some method description.
Expand Down Expand Up @@ -291,8 +288,8 @@ indented with four spaces::
Commenting Code
===============

All comments should be written in English, and should in a clear way
describe the commented block of code.
All comments should be written in English, and should in a clear way describe
the commented block of code.

Comments can include the following `phpDocumentor <http://phpdoc.org>`_
tags:
Expand All @@ -309,8 +306,8 @@ tags:
* `@since <http://phpdoc.org/docs/latest/references/phpdoc/tags/since.html>`_
* `@version <http://phpdoc.org/docs/latest/references/phpdoc/tags/version.html>`_

PhpDoc tags are very much like JavaDoc tags in Java. Tags are only
processed if they are the first thing in a DocBlock line, for example::
PhpDoc tags are very much like JavaDoc tags in Java. Tags are only processed if
they are the first thing in a DocBlock line, for example::

/**
* Tag example.
Expand Down Expand Up @@ -341,8 +338,8 @@ processed if they are the first thing in a DocBlock line, for example::
{
}

Comment blocks, with the exception of the first block in a file, should
always be preceded by a newline.
Comment blocks, with the exception of the first block in a file, should always
be preceded by a newline.

Variable Types
--------------
Expand Down Expand Up @@ -380,7 +377,8 @@ You can also combine types using the pipe char::

For more than two types it is usually best to just use ``mixed``.

When returning the object itself, e.g. for chaining, one should use ``$this`` instead::
When returning the object itself, e.g. for chaining, one should use ``$this``
instead::

/**
* Foo function.
Expand All @@ -395,7 +393,8 @@ When returning the object itself, e.g. for chaining, one should use ``$this`` in
Including Files
===============

``include``, ``require``, ``include_once`` and ``require_once`` do not have parentheses::
``include``, ``require``, ``include_once`` and ``require_once`` do not have
parentheses::

// wrong = parentheses
require_once('ClassFileName.php');
Expand All @@ -411,24 +410,24 @@ When including files with classes or libraries, use only and always the
PHP Tags
========

Always use long tags (``<?php ?>``) Instead of short tags (``<? ?>``). The short echo
should be used in template files (**.ctp**) where appropriate.
Always use long tags (``<?php ?>``) Instead of short tags (``<? ?>``). The short
echo should be used in template files (**.ctp**) where appropriate.

Short Echo
----------

The short echo should be used in template files in place of ``<?php echo``. It should be
immediately followed by a single space, the variable or function value to ``echo``, a
single space, and the php closing tag::
The short echo should be used in template files in place of ``<?php echo``. It
should be immediately followed by a single space, the variable or function value
to ``echo``, a single space, and the php closing tag::

// wrong = semicolon, no spaces
<td><?=$name;?></td>

// good = spaces, no semicolon
<td><?= $name ?></td>

As of PHP 5.4 the short echo tag (``<?=``) is no longer to be consider a 'short tag'
is always available regardless of the ``short_open_tag`` ini directive.
As of PHP 5.4 the short echo tag (``<?=``) is no longer to be consider a 'short
tag' is always available regardless of the ``short_open_tag`` ini directive.

Naming Convention
=================
Expand All @@ -454,11 +453,11 @@ Class names should be written in CamelCase, for example::
Variables
---------

Variable names should be as descriptive as possible, but also as short
as possible. All variables should start with a lowercase letter, and
should be written in camelBack in case of multiple words. Variables
referencing objects should in some way associate to the class the
variable is an object of. Example::
Variable names should be as descriptive as possible, but also as short as
possible. All variables should start with a lowercase letter, and should be
written in camelBack in case of multiple words. Variables referencing objects
should in some way associate to the class the variable is an object of.
Example::

$user = 'John';
$users = ['John', 'Hans', 'Arne'];
Expand All @@ -468,8 +467,9 @@ variable is an object of. Example::
Member Visibility
-----------------

Use PHP5's private and protected keywords for methods and variables. Additionally,
non-public method or variable names start with a single underscore (``_``). Example::
Use PHP5's private and protected keywords for methods and variables.
Additionally, non-public method or variable names start with a single underscore
(``_``). Example::

class A
{
Expand All @@ -491,21 +491,21 @@ non-public method or variable names start with a single underscore (``_``). Exam
Example Addresses
-----------------

For all example URL and mail addresses use "example.com", "example.org"
and "example.net", for example:
For all example URL and mail addresses use "example.com", "example.org" and
"example.net", for example:

* Email: [email protected]
* WWW: `http://www.example.com <http://www.example.com>`_
* FTP: `ftp://ftp.example.com <ftp://ftp.example.com>`_

The "example.com" domain name has been reserved for this (see :rfc:`2606`) and is recommended
for use in documentation or as examples.
The "example.com" domain name has been reserved for this (see :rfc:`2606`) and
is recommended for use in documentation or as examples.

Files
-----

File names which do not contain classes should be lowercased and underscored, for
example::
File names which do not contain classes should be lowercased and underscored,
for example::

long_file_name.php

Expand All @@ -517,19 +517,20 @@ For casting we use:
Type
Description
(bool)
Cast to boolean.
Cast to boolean.
(int)
Cast to integer.
Cast to integer.
(float)
Cast to float.
Cast to float.
(string)
Cast to string.
Cast to string.
(array)
Cast to array.
Cast to array.
(object)
Cast to object.
Cast to object.

Please use ``(int)$var`` instead of ``intval($var)`` and ``(float)$var`` instead of ``floatval($var)`` when applicable.
Please use ``(int)$var`` instead of ``intval($var)`` and ``(float)$var`` instead
of ``floatval($var)`` when applicable.

Constants
---------
Expand All @@ -538,8 +539,8 @@ Constants should be defined in capital letters::

define('CONSTANT', 1);

If a constant name consists of multiple words, they should be separated
by an underscore character, for example::
If a constant name consists of multiple words, they should be separated by an
underscore character, for example::

define('LONG_NAMED_CONSTANT', 2);

Expand Down
1 change: 1 addition & 0 deletions es/console-and-shells.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ More Topics
console-and-shells/plugin-shell
console-and-shells/routes-shell
console-and-shells/upgrade-shell
console-and-shells/server-shell

.. meta::
:title lang=es: Shells, Tasks & Console Tools
Expand Down
11 changes: 11 additions & 0 deletions es/console-and-shells/server-shell.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Server Shell
############

.. note::
La documentación no es compatible actualmente con el idioma español en esta página.

Por favor, siéntase libre de enviarnos un pull request en
`Github <https://github.com/cakephp/docs>`_ o utilizar el botón **Improve this Doc** para proponer directamente los cambios.

Usted puede hacer referencia a la versión en Inglés en el menú de selección superior
para obtener información sobre el tema de esta página.
1 change: 1 addition & 0 deletions fr/console-and-shells.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,7 @@ Plus de sujets
console-and-shells/plugin-shell
console-and-shells/routes-shell
console-and-shells/upgrade-shell
console-and-shells/server-shell

.. meta::
:title lang=fr: Shells, Tasks & Outils de Console
Expand Down
21 changes: 21 additions & 0 deletions fr/console-and-shells/server-shell.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Serveur Shell
#############

``ServerShell`` vous permet de créer un serveur web simple en utilisant le
serveur web de PHP. Bien que ce serveur **ne** soit **pas** fait pour une
utilisation en production, il peut être pratique en développement quand vous
voulez rapidement essayer une idée et ne voulez pas passer du temps à configurer
Apache ou Nginx. Vous pouvez démarrer le serveur shell avec::

$ bin/cake server

Vous pourrez voir le serveur démarré sur le port 8765. Vous pouvez visiter le
sever CLI en visitant ``http://localhost:8765`` dans votre navigateur. Vous
pouvez fermer le serveur en tapant ``CTRL-C`` dans votre terminal.

Changer le Port et le Document Root
===================================

Vous pouvez personnaliser le port et le document root en utilisant les options::

$ bin/cake server --port 8080 --document_root path/to/app
Loading

0 comments on commit ada7578

Please sign in to comment.