[TYPO3-core] RFC: #11836: Remove final from classes
Steffen Kamper
info at sk-typo3.de
Tue Sep 1 09:16:31 CEST 2009
Hi,
Ernesto Baschny [cron IT] schrieb:
> Mathias Schreiber [wmdb >] schrieb:
>> Martin Kutschker schrieb:
>>> The final keyword is used solely for classes that have only static
>>> functions and should therefore not be instantiated at all. Technically
>>> you could extend them, but it makes little sense to do so.
>> I disagree.
>> It happened quite a few times that we needed to patch (ergo xclass)
>> befunc or t3lib_div.
>>
>> So I bascially welcome this patch.
>
> You cannot XCLASS t3lib_div, exactly because people call it statically,
> ergo they will never call your XCLASSed ux_t3lib_div. They call:
>
> t3lib_div::getUrl()
>
> and not
>
> $class = t3lib_div::makeInstanceClassName('t3lib_div');
> $class::getUrl();
>
> So it is technically "static" and not extendable, ergo the final is ok
> here. It doesn't even have a XCLASS statement.
>
at the moment there is no XCLASS definition, but it can be added. And
it's possible to XCLASS, but very tricky, see this little example from
one of our genius :)
$TYPO3_CONF_VARS['XCLASS']['t3lib/class.t3lib_div.php'] = 'ux_t3lib_div';
if (isset($TYPO3_CONF_VARS['XCLASS']['t3lib/class.t3lib_div.php'])) {
eval('class t3lib_div extends ' .
$TYPO3_CONF_VARS['XCLASS']['t3lib/class.t3lib_div.php'] . ' {}');
} else {
eval('class t3lib_div extends t3lib_div_CORE {}');
}
abstract class t3lib_div_CORE {
static public function something($argument) {
echo $argument . PHP_EOL;
}
}
class ux_t3lib_div extends t3lib_div_CORE {
static public function something($argument) {
parent::something('>' . $argument . '<');
}
}
t3lib_div::something('test');
So let's think like Toyota: nothing is impossible
vg Steffen
More information about the TYPO3-team-core
mailing list