Bug #19694 [Com]: Squiz.PHP.LowercasePHPFunctions incorrectly matches on class methods.

From: Date: Wed, 07 Nov 2012 03:38:56 +0000
Subject: Bug #19694 [Com]: Squiz.PHP.LowercasePHPFunctions incorrectly matches on class methods.
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-9300@lists.php.net to get a copy of this message
Edit report at https://pear.php.net/bugs/bug.php?id=19694&edit=1 ID: 19694 Comment by: pear@kennel17.co.uk Reported By: pear at kennel17 dot co dot uk Summary: Squiz.PHP.LowercasePHPFunctions incorrectly matches on class methods. Status: Feedback Type: Bug Package: PHP_CodeSniffer Operating System: All Package Version: 1.4.1 PHP Version: Irrelevant Assigned To: squiz Roadmap Versions: New Comment: Hmmm... I can't seem to reproduce the problem as described, but I've found an example of a different false positive. I encountered the error in 1.4.0, so perhaps it has been fixed in 1.4.1, or perhaps I made a mistake and there was no error - or the error was this new problem and I got confused! The issue false positive I have found is when functions are declared as returning by reference: == Test case == function &Sort() { } == Result == Calls to inbuilt PHP functions must be lowercase; expected "sort" but found "Sort" I'm not sure whether to close this and log a new bug, or to update the summary, so I'll leave that to you. Previous Comments: ------------------------------------------------------------------------ [2012-11-07 01:48:35] squiz -Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz There is already code in there to make sure the function name doesnt have a -> or :: in front of it and that code has been there for 2 years, so I don't think you'd have an old file. Are you able to give me some sample code that produces the error and show me what output you get from running PHPCS on your file with the built-in Squiz standard. ------------------------------------------------------------------------ [2012-11-07 01:19:10] happydog Description: ------------ Squiz.PHP.LowercasePHPFunctions reports errors if any of the built-in PHP functions are used with the incorrect case. However, it gives false positives when you have class methods that happen to match an existing PHP function and your coding style is such that it is not in lower-case. An example that we use all over the place is providing a static Count() function for our data objects, which returns the number of objects of that type currently in the system. Any call to these functions is flagged as incorrect, even though it is not. Expected result: ---------------- That the sniff correctly identifies when a function call is actually a method call, i.e. to distinguish count() from ::count() or ->count() and to only check function calls for correct casing. Actual result: -------------- Class methods are also being checked, which can result in a lot of false positives if you use a coding style that is not lower-case. ------------------------------------------------------------------------ -- Edit this bug report at https://pear.php.net/bugs/bug.php?id=19694&edit=1

« previous php.pear.bugs (#9300) next »