Difference between revisions of "Coding Standards"
m |
m |
(No difference)
|
Latest revision as of 15:58, 6 November 2023
In the PHP community, as well as every other development community, there has been a long-standing tradition of establishing 'Coding Standards' that specify how developers should format their code. So, the PHP Framework Interop(ability) Group came up with PSR-1 and PSR-2 that deal with the issue specifically.
Tools[edit | edit source]
Fabien Potencier (Sensio Labs) has released the PHP Coding Standards Fixer tool which fixes most issues in your code. It helps you follow the PHP coding standards as defined in the PSR-1 and PSR-2 documents.
- PHP Coding Standards Fixer website (code)
- Note that if you use NetBeans, there is a plugin that will integrate with this tool.
Greg Sherwood (Squiz Labs) is the maintainer of PHP CodeSniffer, which was originally a PEAR project. PHP_CodeSniffer tokenizes and "sniffs" PHP, JavaScript and CSS files to detect violations of a defined coding standard. It is an essential development tool that ensures your code remains clean and consistent. It can also help prevent some common semantic errors made by developers.
- Usage
- There is a sniff file for MediaWiki (see here) that you can use to conform to MediaWiki Coding Conventions
ESLint[edit | edit source]
ESLint statically analyzes your code to quickly find problems. It is built into most text editors and you can run ESLint as part of your continuous integration pipeline.
ESLint is used as a code quality tool for the MediaWiki project, and specifically their Vue codebase. More at https://www.mediawiki.org/wiki/Manual:Coding_conventions/Vue