0

I am checking this PHP quality control tool: PHP_CodeSniffer

In its documentation page Example Section, it shows Usage of the tool:

 $ phpcs /path/to/code/myfile.php

 FILE: /path/to/code/myfile.php
 --------------------------------------------------------------------------------
 FOUND 5 ERROR(S) AFFECTING 2 LINE(S)
 --------------------------------------------------------------------------------
   2 | ERROR | Missing file doc comment
  20 | ERROR | PHP keywords must be lowercase; expected "false" but found "FALSE"
  47 | ERROR | Line not indented correctly; expected 4 spaces but found 1
  51 | ERROR | Missing function doc comment
  88 | ERROR | Line not indented correctly; expected 9 spaces but found 6
 --------------------------------------------------------------------------------

on line 2

20 | ERROR | PHP keywords must be lowercase; expected "false" but found "FALSE"', my question is why lower case "false" and "true".

according to PHP's documentation: "A boolean expresses a truth value. It can be either TRUE or FALSE"

1
  • I wonder about a tool that chooses to report only the most minor of annoyances as ERRORs... Commented Nov 7, 2011 at 2:21

2 Answers 2

2

Yes, PHP documentation says "TRUE or FALSE" but also says;

Syntax

To specify a boolean literal, use the keywords TRUE or FALSE. Both are case-insensitive.

So, even if PHP_CodeSniffer says

PHP keywords must be lowercase; expected "false" but found "FALSE"

it doesn't matter actually. You can change all boolean values to lowercase to skip this error message if you really care that much.

Sign up to request clarification or add additional context in comments.

2 Comments

I have searched pear coding standard, but can not find any reference to use lowercase "false/true", can you show me a web link which shows lowercase is better than uppercase, or the pear coding standard just try to make it consistent
I found this page. framework.zend.com/wiki/display/ZFDEV/… It's PHP coding standards defined by Zend Community. Check "Booleans and the NULL Value" headline.
1

CodeSniffer defaults to the PEAR coding standard. What is an error in CodeSniffer does not necessarily mean it is incorrect but often simply means it does not conform to the agreed upon PEAR coding standard. If you are writing your code for PEAR you should fix it. Otherwise, don't worry about it.

I believe you can configure CodeSniffer to check against a different coding standard (for example, if you prefer a standard that uses tabs instead of spaces for indenting, etc.) if you do not like the PEAR standard.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.