Download the PHP package arxeiss/coding-standards without Composer
On this page you can find all versions of the php package arxeiss/coding-standards. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arxeiss/coding-standards
More information about arxeiss/coding-standards
Files in arxeiss/coding-standards
Package coding-standards
Short Description Custom PHP CodeSniffer ruleset
License Apache-2.0
Informations about the package coding-standards
PHP CodeSniffer - Custom standard ruleset
Custom ruleset for PHP CodeSniffer with Slevomat sniffs. Ruleset is based on PSR2 + PSR12 with additional rules, more detailed list is below. Ruleset is possible to use with space indentation and also tabs indentation.
Installation and running
Install with composer:
and run CodeSniffer
Custom ruleset file
Better way is to create custom file phpcs.xml
, with content like phpcs.example.xml. After that it is possible to run
More info about PHP CodeSniffer can be found in the PHP CS wiki
Groups of sniffs
Package consist of multiple files based on the used sniffs.
There are 3 files basic files including all selected sniffs. Use phpcs-spaces.xml or phpcs-tabs.xml, not both. Optionally it is possible to add also phpcs-strict.xml.
- phpcs-spaces.xml - Contains all sniffs with space indentation
- phpcs-tabs.xml - Contains all sniffs with tabs indentation
- phpcs-strict.xml - Contains extra, more strict rules based on Slevomat rules
It can be handy to not include all sniffs at once, specially when migrating big project. Files above just including these partial files:
- Parts/phpcs-psr.xml - PSR2 + PSR12 standards
- Parts/phpcs-use-spaces.xml or Parts/phpcs-use-tabs.xml - Include only one file on the indentation preferences
- Parts/phpcs-generic.xml - Additional Generic rules
- Parts/phpcs-pear.xml - Additional PEAR rules
- Parts/phpcs-squiz.xml - Additional Squiz rules
- Parts/phpcs-slevomat.xml - Selected Slevomat rules
If building own ruleset based on partial files, always use Parts/phpcs-psr.xml, then Parts/phpcs-use-spaces.xml or Parts/phpcs-use-tabs.xml.
Later more additional rules can be added. See phpcs.example.xml.
Included sniffs
See SniffList, I wrote one sentence explanation for each used sniff into XML files.
Also Slevomat rules have some comments about in their repository Readme https://github.com/slevomat/coding-standard
More suggested
Check that Namespace matches file structure
This is used from my own blog in Laravel, where main folder app
is BlogApp
namespace.
Since v0.11.0 mixed
typehint is not required
Explanation can be found here https://github.com/arxeiss/php-coding-standards/pull/6
If you want to force linter to use mixed
typehint, you can enable by adding this into phpcs.xml file.