[TYPO3-core] Principle: Always adding parameters in the _end_ of functions parameter list!
Kasper Skårhøj
kasper2006 at typo3.com
Mon Mar 6 18:44:18 CET 2006
Hi Stanislas and core list.
Stanislas recently fixed "lorem_ipsum" to support RTE. Thanks for
doing that.
However, he needed to add a parameter and did so by adding it as the
first in the list which is wrong (so I will use this example to make
a general point to all of you):
function somefunction($oldVar1,$oldVar2)
=>
function somefunction($newVar, $oldVar1,$oldVar2)
This is something that will immediately break every usage of that
function outside of your control. As long as we cannot make functions
truely "private" and we do not know how many places the function is
used in other extensions this practice is forbidden!
The correct way to do it will be this:
function somefunction($oldVar1,$oldVar2)
=>
function somefunction( $oldVar1,$oldVar2, $newVar)
In Stans case I think he did as he did because the context suggested
that it was better to add it in the beginning of the list. If that is
justified, then one must make a proxy function:
function proxyfunction($newVar, $oldVar1,$oldVar2) {
return $this->somefunction( $oldVar1,$oldVar2, $newVar)
}
I have fixed the problem in lorem_ipsum now.
- kasper
"A contribution a day keeps the fork away"
-------------------------------
kasper2006 at typo3.com | +45 20 999 115 | skype: kasperskaarhoej |
gizmo: kasper_typo3
More information about the TYPO3-team-core
mailing list