PHPackages                             stesie/phpcs-doctrine-annotation-rules - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. stesie/phpcs-doctrine-annotation-rules

ActiveLibrary[Testing &amp; Quality](/categories/testing)

stesie/phpcs-doctrine-annotation-rules
======================================

Additional PHP Code Sniffer sniffs focusing on annotations for Doctrine ORM.

1.2.0(8y ago)856.4k2MITPHPPHP ^7.0

Since Aug 11Pushed 8y ago2 watchersCompare

[ Source](https://github.com/stesie/phpcs-doctrine-annotation-rules)[ Packagist](https://packagist.org/packages/stesie/phpcs-doctrine-annotation-rules)[ RSS](/packages/stesie-phpcs-doctrine-annotation-rules/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (10)Versions (8)Used By (0)

Doctrine Annotation Coding Standard
===================================

[](#doctrine-annotation-coding-standard)

[![Build Status](https://camo.githubusercontent.com/30e2525bdec5366e735f4ef3f5ab0f86dd50ab3289697d112deec2d246d910f0/68747470733a2f2f7472617669732d63692e6f72672f7374657369652f70687063732d646f637472696e652d616e6e6f746174696f6e2d72756c65732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/stesie/phpcs-doctrine-annotation-rules)[![Coverage Status](https://camo.githubusercontent.com/a06052a2475cf8d5fbd5c1a7bd9c978db77a41c47157968e2e44208c7fa06283/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7374657369652f70687063732d646f637472696e652d616e6e6f746174696f6e2d72756c65732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/stesie/phpcs-doctrine-annotation-rules?branch=master)[![PHPStan](https://camo.githubusercontent.com/e43e27acff50e6ee0656e0a112d484ff55f844ff10e79b3d17641033ea51d18f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c253230372d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265266c6162656c3d7068707374616e)](https://camo.githubusercontent.com/e43e27acff50e6ee0656e0a112d484ff55f844ff10e79b3d17641033ea51d18f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c253230372d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265266c6162656c3d7068707374616e)

Doctrine Annotation Coding Standard for [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) provides some additional sniffs centered on DocBlock annotations for [Doctrine ORM](github.com/doctrine/doctrine2/).

Sniffs included in this standard
================================

[](#sniffs-included-in-this-standard)

🔧 = [Automatic errors fixing](#fixing-errors-automatically)

### DoctrineAnnotationCodingStandard.Commenting.ImplicitNullableJoinColumn

[](#doctrineannotationcodingstandardcommentingimplicitnullablejoincolumn)

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 if `nullable` is implicitly assumed to be `true`

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 🔧

[](#doctrineannotationcodingstandardcommentingvartag-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
============

[](#installation)

The recommended way to install Doctrine Annotation Coding Standard is [through Composer](http://getcomposer.org).

```
$ composer require --dev stesie/phpcs-doctrine-annotation-rules
```

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](https://github.com/slevomat/coding-standard/).

Using the standard as a whole
-----------------------------

[](#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:

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

```

Fixing errors automatically
---------------------------

[](#fixing-errors-automatically)

Sniffs in this standard marked by the 🔧 symbol support [automatic fixing of coding standard violations](#fixing-errors-automatically). To fix your code automatically, run phpcbf insteand of phpcs:

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

```

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 98.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Total

7

Last Release

3182d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/113068?v=4)[Stefan Siegl](/maintainers/stesie)[@stesie](https://github.com/stesie)

---

Top Contributors

[![stesie](https://avatars.githubusercontent.com/u/113068?v=4)](https://github.com/stesie "stesie (106 commits)")[![afurculita](https://avatars.githubusercontent.com/u/3129631?v=4)](https://github.com/afurculita "afurculita (1 commits)")[![danionut90](https://avatars.githubusercontent.com/u/206027?v=4)](https://github.com/danionut90 "danionut90 (1 commits)")

---

Tags

doctrine-annotationsphpphpcsphpcs-phpcbf

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/stesie-phpcs-doctrine-annotation-rules/health.svg)

```
[![Health](https://phpackages.com/badges/stesie-phpcs-doctrine-annotation-rules/health.svg)](https://phpackages.com/packages/stesie-phpcs-doctrine-annotation-rules)
```

###  Alternatives

[slevomat/coding-standard

Slevomat Coding Standard for PHP\_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.

1.5k130.4M2.1k](/packages/slevomat-coding-standard)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1175.2k](/packages/rcsofttech-audit-trail-bundle)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9317.2k55](/packages/open-dxp-opendxp)[concrete5/core

Concrete – an open source content management system.

20163.8k49](/packages/concrete5-core)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
