Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitbe70365

Browse files
committed
Be more detailed about PHPdoc coding standards
1 parent6d8720d commitbe70365

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

‎contributing/code/standards.rst‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ Structure
150150
* Use ``return null;`` when a function explicitly returns ``null`` values and
151151
use ``return;`` when the function returns ``void`` values;
152152

153+
* Do not add the ``void`` return type to methods in tests;
154+
153155
* Use braces to indicate control structure body regardless of the number of
154156
statements it contains;
155157

@@ -253,19 +255,28 @@ Service Naming Conventions
253255
Documentation
254256
~~~~~~~~~~~~~
255257

256-
* Add PHPDoc blocks for all classes, methods, and functions (though you may
257-
be asked to remove PHPDoc that do not add value);
258+
* Add PHPDoc blocks for classes, methods, and functions only when they add
259+
relevant information that does not duplicate the name, native type
260+
declaration or context (e.g. ``instanceof`` checks);
261+
262+
* Only use annotations and types defined in `the PHPDoc reference`_. In
263+
order to improve types for static analysis, the following annotations are
264+
also allowed:
265+
266+
* `Generics`_, with the exception of ``@template-covariant``.
267+
* `Conditional return types`_ using the vendor-prefixed ``@psalm-return``;
268+
* `Class constants`_;
269+
* `Callable types`_;
258270

259271
* Group annotations together so that annotations of the same type immediately
260272
follow each other, and annotations of a different type are separated by a
261273
single blank line;
262274

263-
* Omit the ``@return`` tag if the method does not return anything;
264-
265-
* The ``@package`` and ``@subpackage`` annotations are not used;
275+
* Omit the ``@return`` annotation if the method does not return anything;
266276

267-
* Don't inline PHPDoc blocks, even when they contain just one tag (e.g. don't
268-
put ``/** {@inheritdoc} */`` in a single line);
277+
* Don't use one-line PHPDoc blocks on classes, methods and functions, even
278+
when they contain just one annotation (e.g. don't put ``/** {@inheritdoc} */``
279+
in a single line);
269280

270281
* When adding a new class or when making significant changes to an existing class,
271282
an ``@author`` tag with personal contact information may be added, or expanded.
@@ -291,3 +302,8 @@ License
291302
.. _`snake_case`:https://en.wikipedia.org/wiki/Snake_case
292303
.. _`constructor property promotion`:https://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion
293304
.. _`trailing comma`:https://wiki.php.net/rfc/trailing_comma_in_parameter_list
305+
.. _`the PHPDoc reference`:https://docs.phpdoc.org/3.0/guide/references/phpdoc/index.html
306+
.. _`Conditional return types`:https://psalm.dev/docs/annotating_code/type_syntax/conditional_types/
307+
.. _`Class constants`:https://psalm.dev/docs/annotating_code/type_syntax/value_types/#regular-class-constants
308+
.. _`Callable types`:https://psalm.dev/docs/annotating_code/type_syntax/callable_types/
309+
.. _`Generics`:https://psalm.dev/docs/annotating_code/templated_annotations/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp