2

I've managed to get PHP CodeSniffer installed and working. I have also managed to write my own custom sniffs.

There is one issue that I cannot figure out - how do I override the $allowedTypes variable which is defined in the main PHP_CodeSniffer class:

public static $allowedTypes = array(
   'array',
   'boolean',
   'float',
   'integer',
   'mixed',
   'object',
   'string',
   'resource',
   'callable',
);

I would like to add 'bool' and 'int' options to this array, but without monkey patching the core repository.

JonoB
  • 5,801
  • 17
  • 55
  • 77

1 Answers1

0

For anyone hitting this issue: the topic was discussed at github.

The variable cannot be overridden using command line arguments or the XML configuration file.

The easiest solution is to implement a custom Sniff making use of your own suggestType implementation.

dhh
  • 4,289
  • 8
  • 42
  • 59