My TestMyClass.php
has two class definitions in the same file (unit testing class), and PHP Code Sniffer complains about each class must be in a file by itself<
With the following comments you can ignore whatever part of a file you would like.
Ignore all the sniffs for the file:
Ignore only the current and next line:
// phpcs:ignore
public function store($myArray)
Ignore the current line:
public function store($myArray) // phpcs:ignore
Ignore a certain amount of lines in a file:
// phpcs:disable
public function store($myArray): void
{
if (count($myArray) > 3) {
// Humongous amount of legacy code you don't want to look at
}
return;
}
// phpcs:enable
With // phpcs:ignore
and // phpcs:disable
you can also specify which messages, sniffs, categories or standards you would like to disable, for example:
// phpcs:ignore Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed
$foo = [1,2,3];
If you want to read more about this subject, you can visit the wiki. Some of the examples were taken from there.