Download the PHP package stesie/phpcs-doctrine-annotation-rules without Composer
On this page you can find all versions of the php package stesie/phpcs-doctrine-annotation-rules. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stesie/phpcs-doctrine-annotation-rules
More information about stesie/phpcs-doctrine-annotation-rules
Files in stesie/phpcs-doctrine-annotation-rules
Package phpcs-doctrine-annotation-rules
Short Description Additional PHP Code Sniffer sniffs focusing on annotations for Doctrine ORM.
License MIT
Informations about the package phpcs-doctrine-annotation-rules
Doctrine Annotation Coding Standard
Doctrine Annotation Coding Standard for PHP_CodeSniffer provides some additional sniffs centered on DocBlock annotations for Doctrine ORM.
Sniffs included in this standard
:wrench: = Automatic errors fixing
DoctrineAnnotationCodingStandard.Commenting.ImplicitNullableJoinColumn
Applies to DocBlocks of properties that are mapped as either @ORM\ManyToOne
or @ORM\OneToOne
.
- Checks for missing
@ORM\JoinColumn
annotation - If
@ORM\JoinColumn
exists, checks ifnullable
is implicitly assumed to betrue
The default value of nullable
of @ORM\JoinColumn
is true
(as opposed to @ORM\Column
),
which many DEVs are unaware of and hence have NULL-able associations where they should not have ones.
This sniff ensures that the nullable-choice is made explicitly.
DoctrineAnnotationCodingStandard.Commenting.VarTag :wrench:
Applies to all DocBlocks of Doctrine-mapped properties.
- Checks for missing
@var
tag - Checks the type stated by
@var
against actual type (according to Doctrine mapping)
This sniff supports automatic fixing with phpcbf
.
Sniff provides the following settings:
doctrineExtraTypes
: list of custom Doctrine types, that are mapped as strings (instead of objects)
Can be configured via ruleset.xml
like so:
Installation
The recommended way to install Doctrine Annotation Coding Standard is through Composer.
Keep in mind that this is not a full coding standard, it just augments existing ones with extra checks on Doctrine annotations. If unsure, I highly recommend having a look at Slevomat Coding Standard.
Using the standard as a whole
Simply mention this (additional) standard in ruleset.xml
:
To check your code base for violations, run PHP_CodeSniffer
from the command line:
Fixing errors automatically
Sniffs in this standard marked by the :wrench: symbol support automatic fixing of coding standard violations. To fix your code automatically, run phpcbf insteand of phpcs:
All versions of phpcs-doctrine-annotation-rules with dependencies
squizlabs/php_codesniffer Version ^3.0
doctrine/annotations Version ^1.4
doctrine/orm Version ^2.5