PHP_CodeSniffer is a great tool for automating checks and unifying PHP coding standards in the team. Version 2.9.1 is supported in SideCI, and many customers have already been using it.
Recently, PHP_CodeSniffer 3.0 was released. Conventionally, updates of analysis tools were done automatically in the background, but in this update, we have made it so that you can use either 2.9.x and 3.0 versions by switching settings for backward compatibility.
How to use PHP_CodeSniffer
You can try out PHP_CodeSniffer just by creating a
sideci.yml file in the root directory and specifying
version: 3 as shown below.
If no version is specified, analysis will be run with 2.9.x versions as like until now.
About backward compatibility
In many instances, you can use 3.0 without any special settings, but in cases using coding standards other than the ones provided by default such as PEAR and PSR2, changes may need to be made to your settings for 3.0. For details, please check the official upgrade guide.
Also, 2.9.x supported third party coding standards, such as CakePHP, CodeIgniter, FuelPHP, Symfony, and WordPress, but in 3.0, only CakePHP is supported as of July 3, 2017. The coding standards supported in each version are as follows:
$ phpcs -i
The installed coding standards are FuelPHP, Symfony2, CodeIgniter, CakePHP, PEAR, Zend, Squiz, PSR2, PHPCS, PSR1, MySource, WordPress-Docs, WordPress-Extra, WordPress-VIP, WordPress and WordPress-Core
$ phpcs3 -i
The installed coding standards are MySource, PEAR, PSR1, PSR2, Squiz, Zend and CakePHP
About Future Support
The new features of PHP_CodeSniffer will be incorporated for only versions 3.0 and after. 2.9.x versions will only have security patches and serious bug fixes applied. Therefore, we would appreciate it if you could use version 3.0 if possible. If there are any inquiries about this update, please don’t hesitate to contact us from the chat button in SideCI.
※ This feature is only for the Abyssinian mode. The Classic mode will continue support for only 2.9.x versions as like until now.
More articles about PHP (PHPMD, PHP_CodeSniffer)
- Let’s clean up our PHP code using PHP_CodeSniffer
- keeping a watchdog in the PHP repository(using PHPMD, PHP_CodeSniffer)
- Use PHPMD to clean up your PHP coding
For more information about Sider, please go to our website.