{"id":17310854,"url":"https://github.com/stesie/phpcs-doctrine-annotation-rules","last_synced_at":"2025-04-14T14:22:53.877Z","repository":{"id":57059739,"uuid":"98818566","full_name":"stesie/phpcs-doctrine-annotation-rules","owner":"stesie","description":null,"archived":false,"fork":false,"pushed_at":"2017-11-27T14:23:07.000Z","size":181,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T14:22:46.836Z","etag":null,"topics":["doctrine-annotations","php","phpcs","phpcs-phpcbf"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stesie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-30T18:58:00.000Z","updated_at":"2024-04-01T11:08:35.000Z","dependencies_parsed_at":"2022-08-24T14:53:28.979Z","dependency_job_id":null,"html_url":"https://github.com/stesie/phpcs-doctrine-annotation-rules","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stesie%2Fphpcs-doctrine-annotation-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stesie%2Fphpcs-doctrine-annotation-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stesie%2Fphpcs-doctrine-annotation-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stesie%2Fphpcs-doctrine-annotation-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stesie","download_url":"https://codeload.github.com/stesie/phpcs-doctrine-annotation-rules/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248895015,"owners_count":21179167,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["doctrine-annotations","php","phpcs","phpcs-phpcbf"],"created_at":"2024-10-15T12:38:44.040Z","updated_at":"2025-04-14T14:22:53.837Z","avatar_url":"https://github.com/stesie.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Doctrine Annotation Coding Standard\n\n[![Build Status](https://travis-ci.org/stesie/phpcs-doctrine-annotation-rules.svg?branch=master)](https://travis-ci.org/stesie/phpcs-doctrine-annotation-rules)\n[![Coverage Status](https://coveralls.io/repos/github/stesie/phpcs-doctrine-annotation-rules/badge.svg?branch=master)](https://coveralls.io/github/stesie/phpcs-doctrine-annotation-rules?branch=master)\n![PHPStan](https://img.shields.io/badge/style-level%207-brightgreen.svg?style=flat-square\u0026label=phpstan)\n\nDoctrine Annotation Coding Standard for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) provides\nsome additional sniffs centered on DocBlock annotations for [Doctrine ORM](github.com/doctrine/doctrine2/).\n\n# Sniffs included in this standard\n\n:wrench: = [Automatic errors fixing](#fixing-errors-automatically)\n\n### DoctrineAnnotationCodingStandard.Commenting.ImplicitNullableJoinColumn\n\nApplies to DocBlocks of properties that are mapped as either `@ORM\\ManyToOne` or `@ORM\\OneToOne`.\n\n* Checks for missing `@ORM\\JoinColumn` annotation\n* If `@ORM\\JoinColumn` exists, checks if `nullable` is implicitly assumed to be `true`\n\nThe default value of `nullable` of `@ORM\\JoinColumn` is `true` (as opposed to `@ORM\\Column`),\nwhich many DEVs are unaware of and hence have NULL-able associations where they should not have ones.\nThis sniff ensures that the nullable-choice is made explicitly.\n\n\n### DoctrineAnnotationCodingStandard.Commenting.VarTag :wrench:\n\nApplies to all DocBlocks of Doctrine-mapped properties.\n\n* Checks for missing `@var` tag\n* Checks the type stated by `@var` against actual type (according to Doctrine mapping)\n\nThis sniff supports automatic fixing with `phpcbf`.\n\nSniff provides the following settings:\n\n* `doctrineExtraTypes`: list of custom Doctrine types, that are mapped as strings (instead of objects)\n\nCan be configured via `ruleset.xml` like so:\n\n```xml\n    \u003crule ref=\"DoctrineAnnotationCodingStandard.Commenting.VarTag\"\u003e\n        \u003cproperties\u003e\n            \u003cproperty name=\"doctrineExtraTypes\" type=\"array\" value=\"CustomerType,CompanySizeType\" /\u003e\n        \u003c/properties\u003e\n    \u003c/rule\u003e\n```\n\n# Installation\n\nThe recommended way to install Doctrine Annotation Coding Standard is [through Composer](http://getcomposer.org).\n\n```console\n$ composer require --dev stesie/phpcs-doctrine-annotation-rules\n```\n\nKeep in mind that this is not a full coding standard, it just augments existing ones with extra checks\non Doctrine annotations.  If unsure, I highly recommend having a look at\n[Slevomat Coding Standard](https://github.com/slevomat/coding-standard/).\n\n## Using the standard as a whole\n\nSimply mention this (additional) standard in `ruleset.xml`:\n\n```xml\n\u003c?xml version=\"1.0\"?\u003e\n\u003cruleset name=\"AcmeProject\"\u003e\n\t\u003crule ref=\"vendor/stesie/phpcs-doctrine-annotation-rules/src/DoctrineAnnotationCodingStandard/ruleset.xml\" /\u003e\n\t\u003c!-- additional standards like slevomat --\u003e\n\u003c/ruleset\u003e\n```\n\nTo check your code base for violations, run `PHP_CodeSniffer` from the command line:\n\n```\nvendor/bin/phpcs --standard=ruleset.xml --extensions=php -sp src tests\n```\n\n## Fixing errors automatically\n\nSniffs in this standard marked by the :wrench: symbol support \n[automatic fixing of coding standard violations](#fixing-errors-automatically).\nTo fix your code automatically, run phpcbf insteand of phpcs:\n\n```\nvendor/bin/phpcbf --standard=ruleset.xml --extensions=php -sp src tests\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstesie%2Fphpcs-doctrine-annotation-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstesie%2Fphpcs-doctrine-annotation-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstesie%2Fphpcs-doctrine-annotation-rules/lists"}