Checking coding standards of In-Portal by hand takes a lot of time. Gladly there is a tool out there, called PHP_CodeSniffer, that does that automatically and prints out nice report with violations. To make it even more powerful it can be connected to IDE and report errors of files being edited on the fly making developer life easier.
Right now I have created basic set of rules, that needs to be checked and found, that default rules are not so clever in understanding code as they should be. On this page I will note:
- which PHP_CodeSniffer inspections are failing
- what are exact test case
- what we can do about it
Inspection name | Error message | Example code | Problem description | Solved |
---|---|---|---|---|
A opeator statement must be followed by a single space | $this->Application =& kApplication::Instance(); | Inspections should check, that operands are separated from operators by a single space. Good $a + $b Bad $a+$b However symbols "=" and "&" are operators on it's own ("equals" and "bitwise and") and probably during syntax check inspection isn't aware, that together ("=&") they represent assigning a value by reference. | NO | |