I have recently been working on a coding standard and would like to use codesniffer to check my files according to this standard. Since i am new to Codesniffer i figured i'd go test the standards first before creating my own standard.
I have however run into a problem with codesniffer and i am unsure wether this is a bug or something i am doing wrong.
I've had pear install code sniffer using the commandline command pear install CodeSniffer
after that i tried using different standards on my test file:
<?php
public class Application_IndexController() {
DEFINE WEBSITE_URL = 'https://localhost/';
public $avast = '';
private $_ye = '';
protected $_swabs = '';
public setAvast($avast){
$this->avast = $avast;
}
private getYe(){
return $this->_ye;
}
protected changeProtected($_swabs){
if($_swabs && $this->swabs) {
$this->_swabs = $swabs;
} elseif($swabs) {
$this->_swabs = $swabs;
} else {
return null;
}
}
public iDontKnowWhatImDoing($harhar) {
Switch($harhar) {
case 1:
$yargh = "Avast ye "
. "swabs!";
echo $yargh;
break;
default:
$array = array(
"Sailor 1", "Sailor 2", "Sailor 3",
"Sailor 4", "Sailor 5", "Sailor 5"
);
break;
}
}
}
?>
Suffice to say i was in a rather silly mood while writting this file, but regardless it fullfills it's purpose.
I've run all of the standards on this file and only a few of them actually work, the other seem to return the same error all the time.
The 'generic', 'psr1' and 'psr2' standards work perfectly fine yet the 'phpcs', 'pear', 'mysource', 'zend' and 'squiz' standards all result in a single error:
$stackPtr is not a class member var
It seems rather odd that 5 out of 8 just don't work including phpcs's own standard.