Skip to content

stesie/phpcs-doctrine-annotation-rules

Repository files navigation

Doctrine Annotation Coding Standard

Build Status Coverage Status PHPStan

Doctrine Annotation Coding Standard for PHP_CodeSniffer provides some additional sniffs centered on DocBlock annotations for Doctrine ORM.

This is currently very much work in progress and not yet very useful

Ideas for sniffs involve:

  • make sure all JOIN mappings have a @JoinColumn annotation, that explicitly states nullable (this is because the default value true is unexpected to many)
  • make sure @var annotation exists and is in sync with the ORM configuration

Installation

The recommended way to install Doctrine Annotation Coding Standard is through Composer.

{ "require-dev": { "stesie/phpcs-doctrine-annotation-rules": "dev-master"	} }

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:

<?xml version="1.0"?> <ruleset name="AcmeProject">	<rule ref="vendor/stesie/phpcs-doctrine-annotation-rules/src/DoctrineAnnotationCodingStandard/ruleset.xml" /> <!-- additional standards like slevomat --> </ruleset>

To check your code base for violations, run PHP_CodeSniffer from the command line:

vendor/bin/phpcs --standard=ruleset.xml --extensions=php -sp src tests 

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages