For Programmers: Free Programming Magazines  


Home > Archive > PHP PEAR Questions and Answers > November 2007 > Re: [PEAR-QA] private methods require an underscore









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR-QA] private methods require an underscore
Greg Sherwood

2007-11-25, 4:22 am

till wrote:
> Hello QAers!
>
> phpcs frequenty complains with the following message:
> Private method name "Foo::getS3AuthCode" must be prefixed with an underscore
>
> (getS3AuthCode is a private method in Foo.)
>
> I believe the underscore is redundant in PHP5 - kind of like @access
> tags in phpdoc in php5 so I wouldn't use it, others suggested the
> same. I don't want to just go ahead, because I want all the shiny CS
> graphs to be at 0. ;-)
>
> Any advice? Or should I open a feature request? It could probably take
> "PHP Version X" from the file comment and act based on that? (My first
> guess to resolve this issue within phpcs.)
>
> Thanks and regards,
> Till
>

Hi Till,

PHP_CodeSniffer enforces the current PEAR Naming Convention standards
that read, in part:
"Private class members (meaning class members that are intented to be
used only from within the same class in which they are declared; PHP
does not yet support truly-enforceable private namespaces) are preceeded
by a single underscore. For example: _sort() _initTree() $this->_status"

(I can't seen to get to pear.php.net at the moment so I don't have the
direct link for that standard)

And as always, before the PEAR standard in PHP_CodeSniffer could be
changed, the written PEAR standard would need to be changed.

Greg
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com