How can I make PHP CodeSniffer Fixer ignore the namespace declaration?

1.6k Views Asked by At

I am using the sublime text 2 plugin for PHP Coding Standards Fixer. It is working fine, except for the fact that it considers the namespace invalid (it is in fact invalid and I'm okay with it). this errors halts the script from correcting the rest of the file. I get the following error:

! The namespace Application\Controllers\Admin in <filepath> does not match the file path according to PSR-0 rules.

How can I tell the the script to ignore the namespace constraint. Both command line arguments and Sublime text 2 user settings can be changed.

2

There are 2 best solutions below

0
On

I am using below command to exclude pso0 rule:

php-cs-fixer fix --level="psr2" PATH --fixers=-psr0
0
On

While ugly, a short solution might be to add in something like the following:

Use suppression comment tags:

// @codingStandardsIgnoreStart

/* your namespacing here */

// @codingStandardsIgnoreEnd