I am using PHAN in my projects and wonder if there is some kind of codesniffer to validate the code is PHAN compliant.
Asked
Active
Viewed 248 times
1
-
what is "PHAN compliant"? I doubt you can verify it with a static code analyser. – Karoly Horvath Sep 17 '12 at 10:32
-
complaint would be that variables are in the form `$asArrayWithStringsVar` , and not `$arrayWithStrings`. That is something that should be checkable, I would guess. Check the link I added earlier. – Paul Peelen Sep 17 '12 at 10:46
-
what if `$asArray...` is an integer? – Karoly Horvath Sep 17 '12 at 10:59
-
I am not looking for XDebug or unit testing tools, I am looking for something that verifies that the correct type of variable names are used. – Paul Peelen Sep 17 '12 at 11:54
1 Answers
1
My guess is that you could use Codesniffer (http://pear.php.net/manual/en/package.php.php-codesniffer.php), but you would have to create your own custom sniffs. It doesn't look too hard, and all the documentation is there.
What you can do is check that each variable name is made up of the legal prefixes.
What you might be able to do is check that private class variable begin with _.
What you won't be able to do is check that the correct type prefix is used. This is because PHP variables are dynamically typed and can change over the life of the variable. It would be impossible for a static code analyser to figure that our.

Luke Mills
- 1,616
- 1
- 11
- 18