10.04.2018 Views

Doctrine_manual-1-2-en

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 32: Coding Standards 386<br />

* Docum<strong>en</strong>tation Block Here<br />

*/<br />

public function bar()<br />

{<br />

// <strong>en</strong>tire cont<strong>en</strong>t of function<br />

// must be ind<strong>en</strong>ted four spaces<br />

}<br />

public function bar2()<br />

{<br />

}<br />

}<br />

Functions must be separated by only ONE single new line like is done above betwe<strong>en</strong> the<br />

bar() and bar2() methods.<br />

Listing<br />

32-12<br />

Listing<br />

32-13<br />

Passing by-refer<strong>en</strong>ce is permitted in the function declaration only:<br />

/**<br />

* Docum<strong>en</strong>tation Block Here<br />

*/<br />

class Foo<br />

{<br />

/**<br />

* Docum<strong>en</strong>tation Block Here<br />

*/<br />

public function bar(&$baz)<br />

{<br />

}<br />

}<br />

Call-time pass by-refer<strong>en</strong>ce is prohibited. The return value must not be <strong>en</strong>closed in<br />

par<strong>en</strong>theses. This can hinder readability and can also break code if a method is later changed<br />

to return by refer<strong>en</strong>ce.<br />

/**<br />

* Docum<strong>en</strong>tation Block Here<br />

*/<br />

class Foo<br />

{<br />

/**<br />

* WRONG<br />

*/<br />

public function bar() {<br />

return($this->bar);<br />

}<br />

}<br />

/**<br />

* RIGHT<br />

*/<br />

public function bar()<br />

{<br />

return $this->bar;<br />

}<br />

----------------- Brought to you by

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!