[TYPO3-dev] CGL question
Dmitry Dulepov
dmitry.dulepov at gmail.com
Wed Feb 26 12:50:52 CET 2014
Hi!
I have a CGL question. Our current CGL says:
----------------
In general there should be a single return statement in the function.
However a function can return during parameter validation before it starts
its main logic. Example:
----------------
So it is about ***parameter*** validation. There are no other conditions
here that allow early return. So what about this:
-- example #1 --
public function foo() {
if (!$this->bar) {
return;
}
// ... 100 lines of code here
}
----------------
In my opinion this looks ok from a common sense point of view but it is
against CGL (because $this->bar is not a parameter but an attribute and the
check above is not about validation). The function has to look like:
-- example #2 --
public function foo() {
if ($this->bar) {
// ... 100 lines of code here
}
}
----------------
What is you opinion: does example #1 violate CGL or not?
Note: I do not ask whether you like example #1 or example #2 but only about
formal conformance of example #1 to CGL in such case.
The outcome of this "poll" is whether code like in example #1 can be
allowed in the TYPO3 core or not. In my opinion it is not allowed by CGL
(again, it is not important whether one likes it or not).
--
Dmitry Dulepov
Today is a good day to have a good day.
More information about the TYPO3-dev
mailing list