Skip to content

Latest commit

Β 

History

History
1221 lines (791 loc) Β· 27.2 KB

rules.md

File metadata and controls

1221 lines (791 loc) Β· 27.2 KB

Rules Overview

american_english

Ensure only American English is used.

Groups [@Sonata, @Symfony]

Checks

Pattern Message
/(B|b)ehaviour(s)?/ Please use American English for: %s
/(I|i)nitialise/i Please use American English for: %s
/normalise/i Please use American English for: %s
/organise/i Please use American English for: %s
/recognise/i Please use American English for: %s
/centre/i Please use American English for: %s
/colour/i Please use American English for: %s
/flavour/i Please use American English for: %s
/licence/i Please use American English for: %s
Valid Examples πŸ‘
This is a nice behavior...
Invalid Examples πŸ‘Ž
This is a nice behaviour...

argument_variable_must_match_type

Make sure argument variable name match for type

Configuration options

Name Required Allowed Types Default
arguments false array []

avoid_repetetive_words

Make sure that a word is not used twice in a row.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
Please do not use it this way...
Invalid Examples πŸ‘Ž
Please do not not use it this way...

be_kind_to_newcomers

Do not use belittling words!

Groups [@Experimental]

Checks

Pattern Message
/simply/i Please remove the word: %s
/easy/i Please remove the word: %s
/easily/i Please remove the word: %s
/obvious/i Please remove the word: %s
/trivial/i Please remove the word: %s
/of course/i Please remove the word: %s
/logically/i Please remove the word: %s
/merely/i Please remove the word: %s
/basic/i Please remove the word: %s

blank_line_after_anchor

Make sure you have a blank line after anchor (.. anchor:).

Groups [@Sonata, @Symfony]

blank_line_after_colon

Make sure you have a blank line after a sentence which ends with a colon (:).

Groups [@Sonata, @Symfony]

blank_line_after_directive

Make sure you have a blank line after each directive.

Groups [@Sonata, @Symfony]

blank_line_after_filepath_in_code_block

Make sure you have a blank line after a filepath in a code block. This rule respects PHP, YAML, XML and Twig.

Groups [@Sonata, @Symfony]

blank_line_after_filepath_in_php_code_block

Make sure you have a blank line after a filepath in a PHP code block.

blank_line_after_filepath_in_twig_code_block

Make sure you have a blank line after a filepath in a Twig code block.

blank_line_after_filepath_in_xml_code_block

Make sure you have a blank line after a filepath in a XML code block.

blank_line_after_filepath_in_yaml_code_block

Make sure you have a blank line after a filepath in a YAML code block.

blank_line_before_directive

Make sure you have a blank line before each directive.

Groups [@Sonata, @Symfony]

composer_dev_option_at_the_end

Make sure Composer --dev option for require command is used at the end.

Groups [@Sonata]

Valid Examples πŸ‘
composer require symfony/var-dumper --dev
Invalid Examples πŸ‘Ž
composer require --dev symfony/var-dumper

composer_dev_option_not_at_the_end

Make sure Composer --dev option for require command is not used at the end.

Groups [@Symfony]

Valid Examples πŸ‘
composer require --dev symfony/var-dumper
Invalid Examples πŸ‘Ž
composer require symfony/var-dumper --dev

correct_code_block_directive_based_on_the_content

Groups [@Sonata, @Symfony]

deprecated_directive_major_version

Groups [@Symfony]

Configuration options

Name Required
major_version true

deprecated_directive_min_version

Groups [@Symfony]

Configuration options

Name Required
min_version true

deprecated_directive_should_have_version

Ensure a deprecated directive has a version which follows SemVer.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
.. deprecated:: 3.4
Invalid Examples πŸ‘Ž
.. deprecated::
.. deprecated:: foo-bar

ensure_bash_prompt_before_composer_command

Make sure Composer command in a terminal/bash code block is prefixed with a $.

Groups [@Symfony]

Valid Examples πŸ‘
$ composer require symfony/var-dumper
Invalid Examples πŸ‘Ž
composer require symfony/var-dumper

ensure_correct_format_for_phpfunction

Ensure phpfunction directive do not end with ().

Valid Examples πŸ‘
:phpfunction:`mb_detect_encoding`.
Invalid Examples πŸ‘Ž
:phpfunction:`mb_detect_encoding()`.

ensure_exactly_one_space_before_directive_type

Ensure exactly one space before directive type.

Groups [@Symfony]

Valid Examples πŸ‘
.. code-block:: php
Invalid Examples πŸ‘Ž
..  code-block:: php

ensure_exactly_one_space_between_link_definition_and_link

Ensure exactly one space between link definition and link.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
.. _DOCtor-RST: https://github.com/OskarStark/DOCtor-RST
Invalid Examples πŸ‘Ž
.. _DOCtor-RST:     https://github.com/OskarStark/DOCtor-RST

ensure_explicit_nullable_types

Ensure explicit nullable types in method arguments.

Groups [@Symfony]

Valid Examples πŸ‘
function foo(?string $bar = null)
function foo(string|null $bar = null)
Invalid Examples πŸ‘Ž
function foo(string $bar = null)

ensure_github_directive_start_with_prefix

Configuration options

Name Required
prefix true

ensure_link_bottom

Ensure link lines are at the bottom of the file.

Groups [@Symfony]

ensure_link_definition_contains_valid_url

Ensure link definition contains valid link.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
.. _DOCtor-RST: https://github.com/OskarStark/DOCtor-RST
Invalid Examples πŸ‘Ž
.. _DOCtor-RST: htt//github.com/OskarStark/DOCtor-RST

ensure_order_of_code_blocks_in_configuration_block

Groups [@Sonata, @Symfony]

ensure_php_reference_syntax

Ensure php reference syntax is valid.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
The :class:`Symfony\Component\Notifier\Transport` class
Invalid Examples πŸ‘Ž
The :class:`Symfony\Component\Notifier\Transport`` class

extend_abstract_admin

Ensure AbstractAdmin and the corresponding namespace Sonata\AdminBundle\Admin\AbstractAdmin is used.

Groups [@Sonata]

extend_abstract_controller

Ensure AbstractController and the corresponding namespace Symfony\Bundle\FrameworkBundle\Controller\AbstractController is used. Instead of Symfony\Bundle\FrameworkBundle\Controller\Controller.

Groups [@Symfony]

extend_controller

Ensure Controller and the corresponding namespace Symfony\Bundle\FrameworkBundle\Controller\Controller is used. Instead of Symfony\Bundle\FrameworkBundle\Controller\AbstractController.

Groups [@Symfony]

extension_xlf_instead_of_xliff

Make sure to only use .xlf instead of .xliff.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
messages.xlf
Invalid Examples πŸ‘Ž
messages.xliff

filename_uses_dashes_only

Ensures a filename uses only dashes (-), but are allowed to start with underscore (_). It is a common practice to prefix included files with underscores (_).

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
custom-extensions.rst
_custom-extensions.rst
Invalid Examples πŸ‘Ž
custom_extensions.rst

filename_uses_underscores_only

Ensures a filename uses only underscores (_).

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
custom_extensions.rst
_custom_extensions.rst
Invalid Examples πŸ‘Ž
custom-extensions.rst

final_admin_classes

Groups [@Sonata]

final_admin_extension_classes

Groups [@Sonata]

forbidden_directives

Make sure forbidden directives are not used

Groups [@Symfony]

Configuration options

Name Required Allowed Types Default
directives false array []

indention

Groups [@Experimental]

Configuration options

Name Required Allowed Types Default
size false int 4

kernel_instead_of_app_kernel

Groups [@Sonata]

line_length

Configuration options

Name Required Allowed Types Default
max false int 80

lowercase_as_in_use_statements

Groups [@Sonata, @Symfony]

max_blank_lines

Groups [@Sonata, @Symfony]

Configuration options

Name Required Allowed Types Default
max false int 2

max_colons

Make sure you have max 2 colons (::).

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
composer require symfony/var-dumper --dev
Invalid Examples πŸ‘Ž
composer require --dev symfony/var-dumper

no_admin_yaml

Groups [@Sonata]

no_app_bundle

Groups [@Sonata]

no_app_console

Groups [@Sonata, @Symfony]

no_attribute_redundant_parenthesis

Make sure there is no redundant parenthesis on attribute

Groups [@Symfony]

Valid Examples πŸ‘
#[Bar]
#[Bar('foo')]
Invalid Examples πŸ‘Ž
#[Bar()]

no_bash_prompt

Ensure no bash prompt $ is used before commands in bash, shell or terminal code blocks.

Groups [@Sonata]

Valid Examples πŸ‘
bin/console list
Invalid Examples πŸ‘Ž
$ bin/console list

no_blank_line_after_filepath_in_code_block

no_blank_line_after_filepath_in_php_code_block

Groups [@Symfony]

no_blank_line_after_filepath_in_twig_code_block

Groups [@Symfony]

no_blank_line_after_filepath_in_xml_code_block

Groups [@Symfony]

no_blank_line_after_filepath_in_yaml_code_block

Groups [@Symfony]

no_brackets_in_method_directive

Ensure a :method: directive has special format.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
:method:`Symfony\\Component\\OptionsResolver\\Options::offsetGet`
Invalid Examples πŸ‘Ž
:method:`Symfony\\Component\\OptionsResolver\\Options::offsetGet()`

no_broken_ref_directive

Ensure only valid :ref: directives.

Groups [@Symfony]

Valid Examples πŸ‘
See this :ref:`Foo`
Invalid Examples πŸ‘Ž
See this ref:`Foo`

no_composer_phar

Groups [@Sonata]

no_composer_req

Groups [@Symfony]

no_config_yaml

Groups [@Sonata, @Symfony]

no_contraction

Ensure contractions are not used.

Groups [@Symfony]

Checks

Pattern Message
/(^|[^[:alnum:]])(?<contraction>i\'m)/i Please do not use contraction for: %s
/(^|[^[:alnum:]])(?<contraction>(you|we|they)\'re)/i Please do not use contraction for: %s
/(^|[^[:alnum:]])(?<contraction>(he|she|it)\'s)/i Please do not use contraction for: %s
/(^|[^[:alnum:]])(?<contraction>(you|we|they)\'ve)/i Please do not use contraction for: %s
/(^|[^[:alnum:]])(?<contraction>(i|you|he|she|it|we|they)\'ll)/i Please do not use contraction for: %s
/(^|[^[:alnum:]])(?<contraction>(i|you|he|she|it|we|they)\'d)/i Please do not use contraction for: %s
/(^|[^[:alnum:]])(?<contraction>(aren|can|couldn|didn|hasn|haven|isn|mustn|shan|shouldn|wasn|weren|won|wouldn)\'t)/i Please do not use contraction for: %s
Valid Examples πŸ‘
It is an example
Invalid Examples πŸ‘Ž
It's an example

no_directive_after_shorthand

Ensure that no directive follows the shorthand ::. This could lead to broken markup.

Groups [@Sonata, @Symfony]

no_duplicate_use_statements

Ensure there is not same use statement twice

Groups [@Symfony]

no_explicit_use_of_code_block_php

Groups [@Symfony]

no_footnotes

Make sure there is no footnotes

Groups [@Symfony]

Invalid Examples πŸ‘Ž
.. [5] A numerical footnote. Note

no_inheritdoc_in_code_examples

Groups [@Sonata, @Symfony]

no_merge_conflict

Ensure that the files does not contain merge conflicts.

Groups [@Symfony]

no_namespace_after_use_statements

Groups [@Sonata, @Symfony]

no_php_open_tag_in_code_block_php_directive

Groups [@Sonata, @Symfony]

no_php_prefix_before_bin_console

Ensure bin/console is not prefixed with php.

Groups [@Sonata]

Valid Examples πŸ‘
bin/console list
Invalid Examples πŸ‘Ž
php bin/console list

no_php_prefix_before_composer

Groups [@Sonata]

no_space_before_self_xml_closing_tag

Groups [@Sonata]

non_static_phpunit_assertions

Use $this->assert* over static calls.

Groups [@Symfony]

Valid Examples πŸ‘
$this->assertTrue($foo);
Invalid Examples πŸ‘Ž
self::assertTrue($foo);

only_backslashes_in_namespace_in_php_code_block

A namespace declaration in a PHP code-block should only contain backslashes.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
namespace Foo\Bar;
Invalid Examples πŸ‘Ž
namespace Foo/Bar;

only_backslashes_in_use_statements_in_php_code_block

A use statement in a PHP code-block should only contain backslashes.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
use Foo\Bar;
Invalid Examples πŸ‘Ž
use Foo/Bar;

ordered_use_statements

Groups [@Sonata, @Symfony]

php_open_tag_in_code_block_php_directive

php_prefix_before_bin_console

Ensure bin/console is prefixed with php to be safe executable on Microsoft Windows.

Groups [@Symfony]

Valid Examples πŸ‘
php bin/console list
Invalid Examples πŸ‘Ž
bin/console list

remove_trailing_whitespace

Make sure there is not trailing whitespace.

Groups [@Symfony]

Valid Examples πŸ‘
Valid sentence
Invalid Examples πŸ‘Ž
Invalid sentence 

replace_code_block_types

Propose alternatives for disallowed code block types.

Groups [@Sonata, @Symfony]

Checks

Pattern Message
jinja Please do not use type "jinja" for code-block, use "twig" instead
html+jinja Please do not use type "html+jinja" for code-block, use "html+twig" instead
js Please do not use type "js" for code-block, use "javascript" instead

replacement

Groups [@Sonata, @Symfony]

Checks

Pattern Message
/^([\s]+)?\/\/.\.(\.)?$/ Please replace "%s" with "// ..."
/^([\s]+)?#.\.(\.)?$/ Please replace "%s" with "# ..."
/^([\s]+)?<!--(.\.(\.)?|[\s]+\.\.[\s]+)-->$/ Please replace "%s" with ""
/^([\s]+)?{#(.\.(\.)?|[\s]+\.\.[\s]+)#}$/ Please replace "%s" with "{# ... #}"
/apps/ Please replace "%s" with "applications"
/Apps/ Please replace "%s" with "Applications"
/typehint/ Please replace "%s" with "type-hint"
/Typehint/ Please replace "%s" with "Type-hint"
/encoding="utf-8"/ Please replace "%s" with "encoding="UTF-8""
/\$fileSystem/ Please replace "%s" with "$filesystem"
/Content-type/ Please replace "%s" with "Content-Type"
/\-\-env prod/ Please replace "%s" with "--env=prod"
/\-\-env test/ Please replace "%s" with "--env=test"
/End 2 End/i Please replace "%s" with "End-to-End"
/E2E/ Please replace "%s" with "End-to-End"
/informations/ Please replace "%s" with "information"
/Informations/ Please replace "%s" with "Information"
/performances/ Please replace "%s" with "performance"
/Performances/ Please replace "%s" with "Performance"
/``'%kernel.debug%'``/ Please replace "%s" with "%%kernel.debug%%"
/PHPdoc/ Please replace "%s" with "PHPDoc"
/eg\./ Please replace "%s" with "e.g."

short_array_syntax

Groups [@Sonata]

space_before_self_xml_closing_tag

space_between_label_and_link_in_doc

Ensure a space between label and link in :doc: directive.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
:doc:`File </reference/constraints/File>`
Invalid Examples πŸ‘Ž
:doc:`File</reference/constraints/File>`

space_between_label_and_link_in_ref

Ensure a space between label and link in :ref: directive.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
:ref:`receiving them via a worker <messenger-worker>`
Invalid Examples πŸ‘Ž
:ref:`receiving them via a worker<messenger-worker>`

string_replacement

Groups [@Symfony]

Checks

Pattern Message
`type: ``int``` Please replace "%s" with "type: integer"
`type: ``bool``` Please replace "%s" with "type: boolean"

title_underline_length_must_match_title_length

typo

Report common typos.

Groups [@Sonata, @Symfony]

Checks

Pattern Message
/compsoer/i Typo in word "%s"
/registerbundles\(\)/ Typo in word "%s", use "registerBundles()"
/retun/ Typo in word "%s"
/displayes/i Typo in word "%s"
/mantains/i Typo in word "%s"
/doctine/i Typo in word "%s"
/adress/i Typo in word "%s"
/argon21/ Typo in word "%s", use "argon2i"
/descritpion/i Typo in word "%s"
/recalcuate/i Typo in word "%s"
/achived/i Typo in word "%s"
/overriden/i Typo in word "%s"
/succesfully/i Typo in word "%s"
/optionnally/i Typo in word "%s"
/esimated/i Typo in word "%s"
/strengh/i Typo in word "%s"
/mehtod/i Typo in word "%s"
/contraint/i Typo in word "%s"
/instanciation/i Typo in word "%s", use "instantiation"

unused_links

Report all links which are defined, but not used in the file anymore.

Groups [@Sonata, @Symfony]

use_deprecated_directive_instead_of_versionadded

Groups [@Sonata, @Symfony]

use_https_xsd_urls

Groups [@Sonata, @Symfony]

use_named_constructor_without_new_keyword_rule

Ensures that named constructor is used without "new" keyword.

Valid Examples πŸ‘
new Uuid()
Invalid Examples πŸ‘Ž
new Uuid::fromString()

valid_inline_highlighted_namespaces

Ensures to have 2 backslashes when highlighting a namespace to have valid output.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
``App\Entity\Foo``
`App\\Entity\\Foo`
Invalid Examples πŸ‘Ž
``App\\Entity\\Foo``
`App\Entity\Foo`

valid_use_statements

Groups [@Sonata, @Symfony]

versionadded_directive_major_version

Groups [@Symfony]

Configuration options

Name Required
major_version true

versionadded_directive_min_version

Groups [@Symfony]

Configuration options

Name Required
min_version true

versionadded_directive_should_have_version

Ensure a versionadded directive has a version which follows SemVer.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
.. versionadded:: 3.4
Invalid Examples πŸ‘Ž
.. versionadded::
.. versionadded:: foo-bar

yaml_instead_of_yml_suffix

Make sure to only use yaml instead of yml.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
.travis.yml
..code-block:: yaml
Please add this to your services.yaml file.
Invalid Examples πŸ‘Ž
..code-block:: yml
Please add this to your services.yml file.

yarn_dev_option_at_the_end

Make sure yarn --dev option for add command is used at the end.

Groups [@Sonata, @Symfony]

Valid Examples πŸ‘
yarn add jquery --dev
Invalid Examples πŸ‘Ž
yarn add --dev jquery

yarn_dev_option_not_at_the_end

Make sure yarn --dev option for add command is used at the end.

Valid Examples πŸ‘
yarn add --dev jquery
Invalid Examples πŸ‘Ž
yarn add jquery --dev