├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── SECURITY.md ├── composer.json ├── composer.lock ├── example ├── .gitignore ├── PhpStormInspections.xml ├── composer.json └── phpcs.xml.dist └── src └── Standards ├── AcquiaDrupalMinimal └── ruleset.xml ├── AcquiaDrupalStrict └── ruleset.xml ├── AcquiaPHPMinimal └── ruleset.xml └── AcquiaPHPStrict └── ruleset.xml /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Acquia Coding Standards for PHP 2 | 3 | Thank you for taking the time to contribute. 4 | 5 | This project is intended first of all for Acquia internal use, so contributions will be evaluated on the basis of their independent merit as well as their potential impact on Acquia products. 6 | 7 | ## Reporting issues 8 | 9 | A great way to contribute to the project is to send a detailed report when you encounter an issue. We always appreciate a well-written, thorough bug report, and will thank you for it. 10 | 11 | Before submitting an issue please check that the [issue database](https://github.com/acquia/coding-standards/issues) does not already contain the same problem or suggestion. 12 | 13 | If you find a match you can use the "subscribe" button to get notified on updates. Please do not leave random "+1" or "I have this too" comments because they clutter the discussion and don't help resolve it. However, if you have ways to reproduce the issue or have additional information that may help resolve the issue then please leave a comment. 14 | 15 | ## Contributing code 16 | 17 | Pull requests are always welcome. Not sure if that typo is worth a pull request? Found a bug and know how to fix it? Do it! We appreciate the help. Any significant improvement should be documented as [a GitHub issue](https://github.com/acquia/coding-standards/issues) before starting working on it. 18 | 19 | We are always thrilled to receive pull requests and we do our best to process them quickly and provide feedback. 20 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Acquia Coding Standards for PHP 2 | 3 | [![Latest Stable Version](https://poser.pugx.org/acquia/coding-standards/v/stable)](https://packagist.org/packages/acquia/coding-standards) 4 | [![Total Downloads](https://poser.pugx.org/acquia/coding-standards/downloads)](https://packagist.org/packages/acquia/coding-standards) 5 | [![Latest Unstable Version](https://poser.pugx.org/acquia/coding-standards/v/unstable)](https://packagist.org/packages/acquia/coding-standards) 6 | [![License](https://poser.pugx.org/acquia/coding-standards/license)](https://packagist.org/packages/acquia/coding-standards) 7 | [![Tests](https://github.com/acquia/coding-standards-php/actions/workflows/orca.yml/badge.svg)](https://github.com/acquia/coding-standards-php/actions/workflows/orca.yml) 8 | 9 | Acquia Coding Standards for PHP is a collection of [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) rules (sniffs) for Acquia coding standards for PHP projects, including Drupal extensions. 10 | 11 | ## Rules 12 | 13 | Acquia Coding Standards for PHP includes a selection of sniffs from the following rulesets: 14 | 15 | * [Drupal Code Sniffer](https://packagist.org/packages/drupal/coder) encapsulates [Drupal coding standards](https://www.drupal.org/coding-standards ) and best practices for module development. 16 | * [PHP_CodeSniffer](https://packagist.org/packages/squizlabs/php_codesniffer) itself contains several broadly applicable rulesets. 17 | * [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility) checks for PHP cross-version compatibility with all supported language versions. 18 | * [Slevomat Coding Standard](https://github.com/slevomat/coding-standard) provides functional (safety and behavior), cleaning (dead code), and formatting (consistent look) sniffs. 19 | 20 | ## Rulesets 21 | 22 | Rules are split into rulesets according to the project *framework* and *audience*: 23 | 24 | * Projects targeting the Drupal community, e.g., Drupal modules, should adopt a *Drupal* ruleset. All others should adopt a (more generalized) *PHP* ruleset. 25 | * Public projects, e.g., open-source Drupal modules, should adopt a *non-strict* ruleset to facilitate external collaboration. All others should adopt a more opinionated *internal* ruleset. 26 | 27 | There are four permutations of these guidelines, leading to four rulesets to choose from: 28 | 29 | * [AcquiaDrupalMinimal](src/Standards/AcquiaDrupalMinimal/ruleset.xml) is based on the Drupal coding standard and is intended for use on all public Drupal projects. 30 | * [AcquiaDrupalStrict](src/Standards/AcquiaDrupalStrict/ruleset.xml) is based on AcquiaDrupal and adds the more opinionated DrupalPractice standard. It is intended for use on all internal Drupal projects. 31 | * [AcquiaPHPMinimal](src/Standards/AcquiaPHPMinimal/ruleset.xml) is based on PSR-12 and is intended for use on all public non-Drupal projects. 32 | * [AcquiaPHPStrict](src/Standards/AcquiaPHPStrict/ruleset.xml) is based on AcquiaPHP and adds additional, more opinionated standards. It is intended for use on all internal, non-Drupal projects. 33 | 34 | ## Installation & usage 35 | 36 | 1. Add Acquia Coding Standards for PHP to your project via Composer: 37 | 38 | ```bash 39 | composer require --dev acquia/coding-standards 40 | ``` 41 | 42 | 1. Inform PHP CodeSniffer of the location of the standard and its dependencies: 43 | 44 | * It is strongly recommended that you use a Composer plugin to handle this for you, e.g., [`DealerDirect/phpcodesniffer-composer-installer`](https://github.com/DealerDirect/phpcodesniffer-composer-installer): 45 | 46 | ```bash 47 | composer config extra.phpcodesniffer-search-depth 4 48 | composer require --dev dealerdirect/phpcodesniffer-composer-installer 49 | ``` 50 | 51 | * Alternatively, add a script to your `composer.json` to handle it: 52 | 53 | ```json 54 | { 55 | "scripts": { 56 | "post-install-cmd": "@install-coding-standards", 57 | "post-update-cmd" : "@install-coding-standards", 58 | "install-coding-standards": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/acquia/coding-standards/src/Standards,vendor/drupal/coder/coder_sniffer,vendor/phpcompatibility/php-compatibility,vendor/slevomat/coding-standard" 59 | } 60 | } 61 | ``` 62 | 63 | 1. Check code for standards compliance: 64 | 65 | ```bash 66 | ./vendor/bin/phpcs --standard=AcquiaDrupalStrict --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml path/to/code 67 | ``` 68 | 69 | Automatically fix any standards violations possible: 70 | 71 | ```bash 72 | ./vendor/bin/phpcbf --standard=AcquiaDrupalStrict --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml path/to/code 73 | ``` 74 | 75 | The `--extensions` argument must match the chosen code standard. For AcquiaPHP, use `--extensions=php,inc,test,css,txt,md,yml`. 76 | 77 | 1. Optionally create a [default configuration file](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file) for your project so you don't have to provide the command-line arguments every time (i.e., below). Here's a working example: [`example/phpcs.xml.dist`](example/phpcs.xml.dist). 78 | 79 | ```bash 80 | ./vendor/bin/phpcs 81 | ``` 82 | 83 | Modify `phpcs.xml.dist` to suit your project, especially to set the preferred code standard and matching extensions. 84 | 85 | 1. Optionally add code checking to your [Git pre-commit hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to prevent committing code with violations. Since client-side Git hooks are not copied when a repository is cloned, you might like to use an automated solution like [`BrainMaestro/composer-git-hooks`](https://packagist.org/packages/BrainMaestro/composer-git-hooks) to manage them, for example: [`example/composer.json`](example/composer.json). 86 | 87 | 1. Optionally [configure PHP Code Sniffer integration in PhpStorm](https://www.jetbrains.com/help/phpstorm/using-php-code-sniffer.html) or your IDE or code editor of choice. You can import [`example/PhpStormInspections.xml`](example/PhpStormInspections.xml) to set up default integration for new projects. When you open or create a new project for the first time, PhpStorm should automatically detect and set up PHPCS inspections based on these defaults. You will just need to uncheck the “installed standards paths” in the inspection settings for your project so that PhpStorm can find the Acquia Coding Standards. 88 | 89 | ## Contribution 90 | 91 | Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md). 92 | 93 | ## License 94 | 95 | Copyright (C) 2019 Acquia, Inc. 96 | 97 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. 98 | 99 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 100 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | ------- | ------------------ | 7 | | 1.x | :white_check_mark: Supported | 8 | | < 1.x | :x: Not supported | 9 | 10 | ## Reporting a Vulnerability 11 | 12 | Send us an email at security@acquia.com; do not open a public issue. For more details, see [Acquia's responsible disclosure policy](https://www.acquia.com/why-acquia/industries/security#responsible-disclosure). 13 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "acquia/coding-standards", 3 | "type": "phpcodesniffer-standard", 4 | "description": "PHP_CodeSniffer rules (sniffs) for Acquia coding standards", 5 | "keywords": [ 6 | "Drupal", 7 | "phpcs", 8 | "standards", 9 | "static analysis" 10 | ], 11 | "license": "GPL-2.0-or-later", 12 | "authors": [ 13 | { 14 | "name": "Acquia Engineering", 15 | "homepage": "https://www.acquia.com", 16 | "role": "Maintainer" 17 | } 18 | ], 19 | "require": { 20 | "drupal/coder": "^8.3", 21 | "phpcompatibility/php-compatibility": "dev-develop", 22 | "slevomat/coding-standard": "^8.4", 23 | "squizlabs/php_codesniffer": "^3.7" 24 | }, 25 | "suggest": { 26 | "brainmaestro/composer-git-hooks": "Easily manage Git hooks in your composer config.", 27 | "dealerdirect/phpcodesniffer-composer-installer": "Automatically install PHP_CodeSniffer coding standards (rulesets)." 28 | }, 29 | "config": { 30 | "allow-plugins": { 31 | "dealerdirect/phpcodesniffer-composer-installer": true 32 | }, 33 | "sort-packages": true 34 | }, 35 | "extra": { 36 | "branch-alias": { 37 | "dev-develop": "3.x-dev" 38 | } 39 | }, 40 | "autoload": { 41 | "psr-4": { 42 | "Acquia\\CodingStandards\\": "src/" 43 | } 44 | }, 45 | "minimum-stability": "dev", 46 | "prefer-stable": true, 47 | "support": { 48 | "issues": "https://github.com/acquia/coding-standards/issues", 49 | "source": "https://github.com/acquia/coding-standards" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "03b100e65e7d56fcf0964b317d49ab13", 8 | "packages": [ 9 | { 10 | "name": "dealerdirect/phpcodesniffer-composer-installer", 11 | "version": "v1.0.0", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/PHPCSStandards/composer-installer.git", 15 | "reference": "4be43904336affa5c2f70744a348312336afd0da" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", 20 | "reference": "4be43904336affa5c2f70744a348312336afd0da", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "composer-plugin-api": "^1.0 || ^2.0", 25 | "php": ">=5.4", 26 | "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" 27 | }, 28 | "require-dev": { 29 | "composer/composer": "*", 30 | "ext-json": "*", 31 | "ext-zip": "*", 32 | "php-parallel-lint/php-parallel-lint": "^1.3.1", 33 | "phpcompatibility/php-compatibility": "^9.0", 34 | "yoast/phpunit-polyfills": "^1.0" 35 | }, 36 | "type": "composer-plugin", 37 | "extra": { 38 | "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" 39 | }, 40 | "autoload": { 41 | "psr-4": { 42 | "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" 43 | } 44 | }, 45 | "notification-url": "https://packagist.org/downloads/", 46 | "license": [ 47 | "MIT" 48 | ], 49 | "authors": [ 50 | { 51 | "name": "Franck Nijhof", 52 | "email": "franck.nijhof@dealerdirect.com", 53 | "homepage": "http://www.frenck.nl", 54 | "role": "Developer / IT Manager" 55 | }, 56 | { 57 | "name": "Contributors", 58 | "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" 59 | } 60 | ], 61 | "description": "PHP_CodeSniffer Standards Composer Installer Plugin", 62 | "homepage": "http://www.dealerdirect.com", 63 | "keywords": [ 64 | "PHPCodeSniffer", 65 | "PHP_CodeSniffer", 66 | "code quality", 67 | "codesniffer", 68 | "composer", 69 | "installer", 70 | "phpcbf", 71 | "phpcs", 72 | "plugin", 73 | "qa", 74 | "quality", 75 | "standard", 76 | "standards", 77 | "style guide", 78 | "stylecheck", 79 | "tests" 80 | ], 81 | "support": { 82 | "issues": "https://github.com/PHPCSStandards/composer-installer/issues", 83 | "source": "https://github.com/PHPCSStandards/composer-installer" 84 | }, 85 | "time": "2023-01-05T11:28:13+00:00" 86 | }, 87 | { 88 | "name": "drupal/coder", 89 | "version": "8.3.25", 90 | "source": { 91 | "type": "git", 92 | "url": "https://github.com/pfrenssen/coder.git", 93 | "reference": "c58e5a0c44c0010bbc8a91fc468f4667e177b976" 94 | }, 95 | "dist": { 96 | "type": "zip", 97 | "url": "https://api.github.com/repos/pfrenssen/coder/zipball/c58e5a0c44c0010bbc8a91fc468f4667e177b976", 98 | "reference": "c58e5a0c44c0010bbc8a91fc468f4667e177b976", 99 | "shasum": "" 100 | }, 101 | "require": { 102 | "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1 || ^1.0.0", 103 | "ext-mbstring": "*", 104 | "php": ">=7.2", 105 | "sirbrillig/phpcs-variable-analysis": "^2.11.7", 106 | "slevomat/coding-standard": "^8.11", 107 | "squizlabs/php_codesniffer": "^3.9.1", 108 | "symfony/yaml": ">=3.4.0" 109 | }, 110 | "require-dev": { 111 | "phpstan/phpstan": "^1.7.12", 112 | "phpunit/phpunit": "^8.0" 113 | }, 114 | "type": "phpcodesniffer-standard", 115 | "autoload": { 116 | "psr-4": { 117 | "Drupal\\": "coder_sniffer/Drupal/", 118 | "DrupalPractice\\": "coder_sniffer/DrupalPractice/" 119 | } 120 | }, 121 | "notification-url": "https://packagist.org/downloads/", 122 | "license": [ 123 | "GPL-2.0-or-later" 124 | ], 125 | "description": "Coder is a library to review Drupal code.", 126 | "homepage": "https://www.drupal.org/project/coder", 127 | "keywords": [ 128 | "code review", 129 | "phpcs", 130 | "standards" 131 | ], 132 | "support": { 133 | "issues": "https://www.drupal.org/project/issues/coder", 134 | "source": "https://www.drupal.org/project/coder" 135 | }, 136 | "time": "2024-09-22T19:02:16+00:00" 137 | }, 138 | { 139 | "name": "phpcompatibility/php-compatibility", 140 | "version": "dev-develop", 141 | "source": { 142 | "type": "git", 143 | "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", 144 | "reference": "fc30dbb23f11186e2079d9705b0ff5299c02df1e" 145 | }, 146 | "dist": { 147 | "type": "zip", 148 | "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/fc30dbb23f11186e2079d9705b0ff5299c02df1e", 149 | "reference": "fc30dbb23f11186e2079d9705b0ff5299c02df1e", 150 | "shasum": "" 151 | }, 152 | "require": { 153 | "php": ">=5.4", 154 | "phpcsstandards/phpcsutils": "^1.0.12", 155 | "squizlabs/php_codesniffer": "^3.10.0" 156 | }, 157 | "replace": { 158 | "wimg/php-compatibility": "*" 159 | }, 160 | "require-dev": { 161 | "php-parallel-lint/php-console-highlighter": "^1.0.0", 162 | "php-parallel-lint/php-parallel-lint": "^1.4.0", 163 | "phpcsstandards/phpcsdevcs": "^1.1.3", 164 | "phpcsstandards/phpcsdevtools": "^1.2.0", 165 | "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4 || ^10.1.0", 166 | "yoast/phpunit-polyfills": "^1.0.5 || ^2.0.0" 167 | }, 168 | "suggest": { 169 | "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." 170 | }, 171 | "default-branch": true, 172 | "type": "phpcodesniffer-standard", 173 | "extra": { 174 | "branch-alias": { 175 | "dev-master": "9.x-dev", 176 | "dev-develop": "10.x-dev" 177 | } 178 | }, 179 | "notification-url": "https://packagist.org/downloads/", 180 | "license": [ 181 | "LGPL-3.0-or-later" 182 | ], 183 | "authors": [ 184 | { 185 | "name": "Wim Godden", 186 | "homepage": "https://github.com/wimg", 187 | "role": "lead" 188 | }, 189 | { 190 | "name": "Juliette Reinders Folmer", 191 | "homepage": "https://github.com/jrfnl", 192 | "role": "lead" 193 | }, 194 | { 195 | "name": "Contributors", 196 | "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" 197 | } 198 | ], 199 | "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", 200 | "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", 201 | "keywords": [ 202 | "compatibility", 203 | "phpcs", 204 | "standards", 205 | "static analysis" 206 | ], 207 | "support": { 208 | "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", 209 | "security": "https://github.com/PHPCompatibility/PHPCompatibility/security/policy", 210 | "source": "https://github.com/PHPCompatibility/PHPCompatibility" 211 | }, 212 | "funding": [ 213 | { 214 | "url": "https://github.com/PHPCompatibility", 215 | "type": "github" 216 | }, 217 | { 218 | "url": "https://github.com/jrfnl", 219 | "type": "github" 220 | }, 221 | { 222 | "url": "https://opencollective.com/php_codesniffer", 223 | "type": "open_collective" 224 | } 225 | ], 226 | "time": "2024-10-07T07:09:51+00:00" 227 | }, 228 | { 229 | "name": "phpcsstandards/phpcsutils", 230 | "version": "1.0.12", 231 | "source": { 232 | "type": "git", 233 | "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", 234 | "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c" 235 | }, 236 | "dist": { 237 | "type": "zip", 238 | "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/87b233b00daf83fb70f40c9a28692be017ea7c6c", 239 | "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c", 240 | "shasum": "" 241 | }, 242 | "require": { 243 | "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", 244 | "php": ">=5.4", 245 | "squizlabs/php_codesniffer": "^3.10.0 || 4.0.x-dev@dev" 246 | }, 247 | "require-dev": { 248 | "ext-filter": "*", 249 | "php-parallel-lint/php-console-highlighter": "^1.0", 250 | "php-parallel-lint/php-parallel-lint": "^1.3.2", 251 | "phpcsstandards/phpcsdevcs": "^1.1.6", 252 | "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0" 253 | }, 254 | "type": "phpcodesniffer-standard", 255 | "extra": { 256 | "branch-alias": { 257 | "dev-stable": "1.x-dev", 258 | "dev-develop": "1.x-dev" 259 | } 260 | }, 261 | "autoload": { 262 | "classmap": [ 263 | "PHPCSUtils/" 264 | ] 265 | }, 266 | "notification-url": "https://packagist.org/downloads/", 267 | "license": [ 268 | "LGPL-3.0-or-later" 269 | ], 270 | "authors": [ 271 | { 272 | "name": "Juliette Reinders Folmer", 273 | "homepage": "https://github.com/jrfnl", 274 | "role": "lead" 275 | }, 276 | { 277 | "name": "Contributors", 278 | "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" 279 | } 280 | ], 281 | "description": "A suite of utility functions for use with PHP_CodeSniffer", 282 | "homepage": "https://phpcsutils.com/", 283 | "keywords": [ 284 | "PHP_CodeSniffer", 285 | "phpcbf", 286 | "phpcodesniffer-standard", 287 | "phpcs", 288 | "phpcs3", 289 | "standards", 290 | "static analysis", 291 | "tokens", 292 | "utility" 293 | ], 294 | "support": { 295 | "docs": "https://phpcsutils.com/", 296 | "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", 297 | "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", 298 | "source": "https://github.com/PHPCSStandards/PHPCSUtils" 299 | }, 300 | "funding": [ 301 | { 302 | "url": "https://github.com/PHPCSStandards", 303 | "type": "github" 304 | }, 305 | { 306 | "url": "https://github.com/jrfnl", 307 | "type": "github" 308 | }, 309 | { 310 | "url": "https://opencollective.com/php_codesniffer", 311 | "type": "open_collective" 312 | } 313 | ], 314 | "time": "2024-05-20T13:34:27+00:00" 315 | }, 316 | { 317 | "name": "phpstan/phpdoc-parser", 318 | "version": "1.32.0", 319 | "source": { 320 | "type": "git", 321 | "url": "https://github.com/phpstan/phpdoc-parser.git", 322 | "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4" 323 | }, 324 | "dist": { 325 | "type": "zip", 326 | "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6ca22b154efdd9e3c68c56f5d94670920a1c19a4", 327 | "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4", 328 | "shasum": "" 329 | }, 330 | "require": { 331 | "php": "^7.2 || ^8.0" 332 | }, 333 | "require-dev": { 334 | "doctrine/annotations": "^2.0", 335 | "nikic/php-parser": "^4.15", 336 | "php-parallel-lint/php-parallel-lint": "^1.2", 337 | "phpstan/extension-installer": "^1.0", 338 | "phpstan/phpstan": "^1.5", 339 | "phpstan/phpstan-phpunit": "^1.1", 340 | "phpstan/phpstan-strict-rules": "^1.0", 341 | "phpunit/phpunit": "^9.5", 342 | "symfony/process": "^5.2" 343 | }, 344 | "type": "library", 345 | "autoload": { 346 | "psr-4": { 347 | "PHPStan\\PhpDocParser\\": [ 348 | "src/" 349 | ] 350 | } 351 | }, 352 | "notification-url": "https://packagist.org/downloads/", 353 | "license": [ 354 | "MIT" 355 | ], 356 | "description": "PHPDoc parser with support for nullable, intersection and generic types", 357 | "support": { 358 | "issues": "https://github.com/phpstan/phpdoc-parser/issues", 359 | "source": "https://github.com/phpstan/phpdoc-parser/tree/1.32.0" 360 | }, 361 | "time": "2024-09-26T07:23:32+00:00" 362 | }, 363 | { 364 | "name": "sirbrillig/phpcs-variable-analysis", 365 | "version": "v2.11.19", 366 | "source": { 367 | "type": "git", 368 | "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", 369 | "reference": "bc8d7e30e2005bce5c59018b7cdb08e9fb45c0d1" 370 | }, 371 | "dist": { 372 | "type": "zip", 373 | "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/bc8d7e30e2005bce5c59018b7cdb08e9fb45c0d1", 374 | "reference": "bc8d7e30e2005bce5c59018b7cdb08e9fb45c0d1", 375 | "shasum": "" 376 | }, 377 | "require": { 378 | "php": ">=5.4.0", 379 | "squizlabs/php_codesniffer": "^3.5.6" 380 | }, 381 | "require-dev": { 382 | "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.0", 383 | "phpcsstandards/phpcsdevcs": "^1.1", 384 | "phpstan/phpstan": "^1.7", 385 | "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.5 || ^7.0 || ^8.0 || ^9.0", 386 | "sirbrillig/phpcs-import-detection": "^1.1", 387 | "vimeo/psalm": "^0.2 || ^0.3 || ^1.1 || ^4.24 || ^5.0@beta" 388 | }, 389 | "type": "phpcodesniffer-standard", 390 | "autoload": { 391 | "psr-4": { 392 | "VariableAnalysis\\": "VariableAnalysis/" 393 | } 394 | }, 395 | "notification-url": "https://packagist.org/downloads/", 396 | "license": [ 397 | "BSD-2-Clause" 398 | ], 399 | "authors": [ 400 | { 401 | "name": "Sam Graham", 402 | "email": "php-codesniffer-variableanalysis@illusori.co.uk" 403 | }, 404 | { 405 | "name": "Payton Swick", 406 | "email": "payton@foolord.com" 407 | } 408 | ], 409 | "description": "A PHPCS sniff to detect problems with variables.", 410 | "keywords": [ 411 | "phpcs", 412 | "static analysis" 413 | ], 414 | "support": { 415 | "issues": "https://github.com/sirbrillig/phpcs-variable-analysis/issues", 416 | "source": "https://github.com/sirbrillig/phpcs-variable-analysis", 417 | "wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki" 418 | }, 419 | "time": "2024-06-26T20:08:34+00:00" 420 | }, 421 | { 422 | "name": "slevomat/coding-standard", 423 | "version": "8.15.0", 424 | "source": { 425 | "type": "git", 426 | "url": "https://github.com/slevomat/coding-standard.git", 427 | "reference": "7d1d957421618a3803b593ec31ace470177d7817" 428 | }, 429 | "dist": { 430 | "type": "zip", 431 | "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7d1d957421618a3803b593ec31ace470177d7817", 432 | "reference": "7d1d957421618a3803b593ec31ace470177d7817", 433 | "shasum": "" 434 | }, 435 | "require": { 436 | "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", 437 | "php": "^7.2 || ^8.0", 438 | "phpstan/phpdoc-parser": "^1.23.1", 439 | "squizlabs/php_codesniffer": "^3.9.0" 440 | }, 441 | "require-dev": { 442 | "phing/phing": "2.17.4", 443 | "php-parallel-lint/php-parallel-lint": "1.3.2", 444 | "phpstan/phpstan": "1.10.60", 445 | "phpstan/phpstan-deprecation-rules": "1.1.4", 446 | "phpstan/phpstan-phpunit": "1.3.16", 447 | "phpstan/phpstan-strict-rules": "1.5.2", 448 | "phpunit/phpunit": "8.5.21|9.6.8|10.5.11" 449 | }, 450 | "type": "phpcodesniffer-standard", 451 | "extra": { 452 | "branch-alias": { 453 | "dev-master": "8.x-dev" 454 | } 455 | }, 456 | "autoload": { 457 | "psr-4": { 458 | "SlevomatCodingStandard\\": "SlevomatCodingStandard/" 459 | } 460 | }, 461 | "notification-url": "https://packagist.org/downloads/", 462 | "license": [ 463 | "MIT" 464 | ], 465 | "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", 466 | "keywords": [ 467 | "dev", 468 | "phpcs" 469 | ], 470 | "support": { 471 | "issues": "https://github.com/slevomat/coding-standard/issues", 472 | "source": "https://github.com/slevomat/coding-standard/tree/8.15.0" 473 | }, 474 | "funding": [ 475 | { 476 | "url": "https://github.com/kukulich", 477 | "type": "github" 478 | }, 479 | { 480 | "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard", 481 | "type": "tidelift" 482 | } 483 | ], 484 | "time": "2024-03-09T15:20:58+00:00" 485 | }, 486 | { 487 | "name": "squizlabs/php_codesniffer", 488 | "version": "3.10.3", 489 | "source": { 490 | "type": "git", 491 | "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", 492 | "reference": "62d32998e820bddc40f99f8251958aed187a5c9c" 493 | }, 494 | "dist": { 495 | "type": "zip", 496 | "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/62d32998e820bddc40f99f8251958aed187a5c9c", 497 | "reference": "62d32998e820bddc40f99f8251958aed187a5c9c", 498 | "shasum": "" 499 | }, 500 | "require": { 501 | "ext-simplexml": "*", 502 | "ext-tokenizer": "*", 503 | "ext-xmlwriter": "*", 504 | "php": ">=5.4.0" 505 | }, 506 | "require-dev": { 507 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" 508 | }, 509 | "bin": [ 510 | "bin/phpcbf", 511 | "bin/phpcs" 512 | ], 513 | "type": "library", 514 | "extra": { 515 | "branch-alias": { 516 | "dev-master": "3.x-dev" 517 | } 518 | }, 519 | "notification-url": "https://packagist.org/downloads/", 520 | "license": [ 521 | "BSD-3-Clause" 522 | ], 523 | "authors": [ 524 | { 525 | "name": "Greg Sherwood", 526 | "role": "Former lead" 527 | }, 528 | { 529 | "name": "Juliette Reinders Folmer", 530 | "role": "Current lead" 531 | }, 532 | { 533 | "name": "Contributors", 534 | "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" 535 | } 536 | ], 537 | "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", 538 | "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", 539 | "keywords": [ 540 | "phpcs", 541 | "standards", 542 | "static analysis" 543 | ], 544 | "support": { 545 | "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", 546 | "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", 547 | "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", 548 | "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" 549 | }, 550 | "funding": [ 551 | { 552 | "url": "https://github.com/PHPCSStandards", 553 | "type": "github" 554 | }, 555 | { 556 | "url": "https://github.com/jrfnl", 557 | "type": "github" 558 | }, 559 | { 560 | "url": "https://opencollective.com/php_codesniffer", 561 | "type": "open_collective" 562 | } 563 | ], 564 | "time": "2024-09-18T10:38:58+00:00" 565 | }, 566 | { 567 | "name": "symfony/polyfill-ctype", 568 | "version": "v1.31.0", 569 | "source": { 570 | "type": "git", 571 | "url": "https://github.com/symfony/polyfill-ctype.git", 572 | "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" 573 | }, 574 | "dist": { 575 | "type": "zip", 576 | "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", 577 | "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", 578 | "shasum": "" 579 | }, 580 | "require": { 581 | "php": ">=7.2" 582 | }, 583 | "provide": { 584 | "ext-ctype": "*" 585 | }, 586 | "suggest": { 587 | "ext-ctype": "For best performance" 588 | }, 589 | "type": "library", 590 | "extra": { 591 | "thanks": { 592 | "name": "symfony/polyfill", 593 | "url": "https://github.com/symfony/polyfill" 594 | } 595 | }, 596 | "autoload": { 597 | "files": [ 598 | "bootstrap.php" 599 | ], 600 | "psr-4": { 601 | "Symfony\\Polyfill\\Ctype\\": "" 602 | } 603 | }, 604 | "notification-url": "https://packagist.org/downloads/", 605 | "license": [ 606 | "MIT" 607 | ], 608 | "authors": [ 609 | { 610 | "name": "Gert de Pagter", 611 | "email": "BackEndTea@gmail.com" 612 | }, 613 | { 614 | "name": "Symfony Community", 615 | "homepage": "https://symfony.com/contributors" 616 | } 617 | ], 618 | "description": "Symfony polyfill for ctype functions", 619 | "homepage": "https://symfony.com", 620 | "keywords": [ 621 | "compatibility", 622 | "ctype", 623 | "polyfill", 624 | "portable" 625 | ], 626 | "support": { 627 | "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" 628 | }, 629 | "funding": [ 630 | { 631 | "url": "https://symfony.com/sponsor", 632 | "type": "custom" 633 | }, 634 | { 635 | "url": "https://github.com/fabpot", 636 | "type": "github" 637 | }, 638 | { 639 | "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 640 | "type": "tidelift" 641 | } 642 | ], 643 | "time": "2024-09-09T11:45:10+00:00" 644 | }, 645 | { 646 | "name": "symfony/yaml", 647 | "version": "v7.1.5", 648 | "source": { 649 | "type": "git", 650 | "url": "https://github.com/symfony/yaml.git", 651 | "reference": "4e561c316e135e053bd758bf3b3eb291d9919de4" 652 | }, 653 | "dist": { 654 | "type": "zip", 655 | "url": "https://api.github.com/repos/symfony/yaml/zipball/4e561c316e135e053bd758bf3b3eb291d9919de4", 656 | "reference": "4e561c316e135e053bd758bf3b3eb291d9919de4", 657 | "shasum": "" 658 | }, 659 | "require": { 660 | "php": ">=8.2", 661 | "symfony/polyfill-ctype": "^1.8" 662 | }, 663 | "conflict": { 664 | "symfony/console": "<6.4" 665 | }, 666 | "require-dev": { 667 | "symfony/console": "^6.4|^7.0" 668 | }, 669 | "bin": [ 670 | "Resources/bin/yaml-lint" 671 | ], 672 | "type": "library", 673 | "autoload": { 674 | "psr-4": { 675 | "Symfony\\Component\\Yaml\\": "" 676 | }, 677 | "exclude-from-classmap": [ 678 | "/Tests/" 679 | ] 680 | }, 681 | "notification-url": "https://packagist.org/downloads/", 682 | "license": [ 683 | "MIT" 684 | ], 685 | "authors": [ 686 | { 687 | "name": "Fabien Potencier", 688 | "email": "fabien@symfony.com" 689 | }, 690 | { 691 | "name": "Symfony Community", 692 | "homepage": "https://symfony.com/contributors" 693 | } 694 | ], 695 | "description": "Loads and dumps YAML files", 696 | "homepage": "https://symfony.com", 697 | "support": { 698 | "source": "https://github.com/symfony/yaml/tree/v7.1.5" 699 | }, 700 | "funding": [ 701 | { 702 | "url": "https://symfony.com/sponsor", 703 | "type": "custom" 704 | }, 705 | { 706 | "url": "https://github.com/fabpot", 707 | "type": "github" 708 | }, 709 | { 710 | "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 711 | "type": "tidelift" 712 | } 713 | ], 714 | "time": "2024-09-17T12:49:58+00:00" 715 | } 716 | ], 717 | "packages-dev": [], 718 | "aliases": [], 719 | "minimum-stability": "dev", 720 | "stability-flags": { 721 | "phpcompatibility/php-compatibility": 20 722 | }, 723 | "prefer-stable": true, 724 | "prefer-lowest": false, 725 | "platform": {}, 726 | "platform-dev": {}, 727 | "plugin-api-version": "2.6.0" 728 | } 729 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | .phpcs-cache 3 | -------------------------------------------------------------------------------- /example/PhpStormInspections.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 18 | -------------------------------------------------------------------------------- /example/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "drupal/example", 3 | "type": "drupal-module", 4 | "description": "Provides an example module for testing and illustration purposes.", 5 | "license": "GPL-2.0-or-later", 6 | "require-dev": { 7 | "acquia/coding-standards": "*", 8 | "brainmaestro/composer-git-hooks": "^2.5", 9 | "dealerdirect/phpcodesniffer-composer-installer": "^0.5" 10 | }, 11 | "extra": { 12 | "hooks": { 13 | "post-install-cmd": "cghooks add --ignore-lock", 14 | "post-update-cmd": "cghooks update", 15 | "pre-commit": "vendor/bin/phpcs", 16 | "pre-push": "vendor/bin/phpcs" 17 | }, 18 | "phpcodesniffer-search-depth": 4 19 | }, 20 | "scripts": { 21 | "phpcs": "phpcs" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/phpcs.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | An example PHP CodeSniffer configuration. 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | . 20 | 21 | 22 | 23 | 24 | vendor/* 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Standards/AcquiaDrupalMinimal/ruleset.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | Acquia's Drupal coding standards. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | tests/* 30 | 31 | 32 | tests/* 33 | 34 | 35 | tests/* 36 | 37 | 38 | tests/* 39 | 40 | 41 | tests/* 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/Standards/AcquiaDrupalStrict/ruleset.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | Acquia's strict Drupal coding standards. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Standards/AcquiaPHPMinimal/ruleset.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | Acquia's PHP coding standards. 10 | 11 | 12 | 13 | 14 | 15 | 16 | *.(md|txt|yml) 17 | 18 | 19 | 20 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/Standards/AcquiaPHPStrict/ruleset.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | Acquia's strict PHP coding standards. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 60 | 61 | 62 | 63 | --------------------------------------------------------------------------------