-- Pádraic Brady <[EMAIL PROTECTED]> wrote
(on Tuesday, 29 July 2008, 03:32 AM -0700):
> 
> I don't know about everyone else, but I once a param is going to cross the 80
> space limit I'll put it on a new line indented from the start of the
> function declaration and continue as normal:
> 
>     public function longMethodDeclaration(Zend_Controller_Front $front,
>         Zend_Cache $cache = null, Zend_Db_Table $databaseTable,
>         Zend_Feed $feed)
>     {

I'm going to make another note here. PEAR2 CS is proposing using the
following syntax when wrapping:

    public function longMethodDeclaration(Zend_Controller_Front $front,
        Zend_Cache $cache = null, Zend_Db_Table $databaseTable,
        Zend_Feed $feed
    ) {

Notice that the closing paren and opening brace are on the same line.
This allows you to open further lines without needing to worry about the
closing paren. The same would be true for if/elseif conditionals:

    if ($someCondition
        && $anotherCondition
        && $stillAnotherCondition
    ) {

One purpose of this is to reduce the size of changesets -- by pushing the
closing paren to the next line, if you insert another conditional at the
end later, you don't end up changing two lines -- only inserting one.

I'll be proposing similar changes for the ZF CS.

>         // much PHP
>     }
> 
> Where it makes sense, I'll follow a similar pattern for method calls. The
> only hard rule I have is to keep both parameters and type hints paired at
> all times.
> 
> Paddy
> 
> public function longMethodDeclaration(Zend_Class $zendClass
> 
> Trevor Johns wrote:
> > 
> > Hi everyone,
> > I just have a quick question regarding the ZF coding style:
> > 
> > There's an 80 column line-length for code, so long method declarations/ 
> > calls will need to be wrapped. This much is clear.
> > 
> > However, what is convention as to how to indent method parameters  
> > after wrapping? Should parameters be aligned, or should they just be  
> > treated as a single long line?
> > 
> > For example, which of these would be correct:
> > 
> > $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass,  
> > $service, null,
> >          Zend_Gdata_ClientLogin::DEFAULT_SOURCE, null, null,
> >          Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, 'GOOGLE');
> > 
> > (That's 2x4 spaces on the wrapped lines, whether this is correct  
> > indentation is also unclear from the style guide.)
> > 
> > or
> > 
> > $client = Zend_Gdata_ClientLogin::getHttpClient($user,
> >                                                  $pass,
> >                                                  $service,
> >                                                  null,
> >                                                   
> > Zend_Gdata_ClientLogin::DEFAULT_SOURCE,
> >                                                  null,
> >                                                  null,
> >                                                   
> > Zend_Gdata_ClientLogin::CLIENTLOGIN_URI,
> >                                                  'GOOGLE');
> > 
> > I've scanned over the ZF style guide at the below URL, but couldn't  
> > find any information that clarified this, so any input from the  
> > community would be appreciated.
> > 
> >      http://framework.zend.com/manual/en/coding-standard.html
> > 
> > Thanks.
> > 
> > -- 
> > Trevor Johns
> > http://tjohns.net
> > 
> > 
> > 
> 
> 
> -----
> Pádraic Brady
> 
> http://blog.astrumfutura.com
> http://www.patternsforphp.com
> OpenID Europe Foundation - Irish Representative
> -- 
> View this message in context: 
> http://www.nabble.com/ZF-Style-Guide-Clarification%3A-Method-Parameter-Indentation-tp18706711p18709298.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
> 

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend Framework           | http://framework.zend.com/

Reply via email to