[TYPO3-core] RFC: #11836: Remove final from classes

Oliver Hader oliver at typo3.org
Tue Sep 1 12:46:00 CEST 2009


Hi Stefan,

Stefan Geith schrieb:
> Oliver Hader schrieb:
>> Yes, but a various number of extension uses static calls to t3lib_div -
>> so we cannot just transform this to a singleton object.
> 
> Why can't t3lib_div be instantiated as a singleton _parallel_ to using
> it static ?
> We could make the static usage of t3lib_div deprecated and start usage
> of $GLOBALS['T3LIB_DIV'] (or maybe $GLOBALS['T3DIV']).
> 
> Nothing gets broken yet and we can start to convert the static calls to
> calls to the singleton - right ?

My concerns were about calling non-static methods statically (from
existing extension). The PHP.net manual says the following about that:
http://de.php.net/manual/en/language.oop5.static.php

However, I could not reproduce the E_STRIC behaviour in my PHP 5.2 with
all error reportings enabled. But I don't know how PHP 5.3 behaves here.

Example:
class testClass {
  static public function testA() { echo 'testA'; }
  public function testB() { echo 'testB'; }
}
$test = new testClass(); // singleton looks different, I know
$test->testA();          // static function called non-static
testClass::testB();      // non-static function called static

> Static calls in core could be converted in (e.g.) Version 4.4 of Typo3.
> 
> Plugin-Devs could/should change their calls, but if they don't change to
> the singleton, the only disadvantage is, that the cannot use
> Xclassed-extensions of t3lib_div...
> 
> What do you think ? Did I forget an aspect ?

We should define how this is used:
* t3lib_div::getInstance()->getIndpEnv('HTTP_HOST')
* $GLOBALS['t3lib_div']->getIndpEnv('HTTP_HOST') - not my favourite
* how are XCLASS used here - if that's possible, "final" still has to be
removed

However, I it's not a good idea to discuss converting static classes to
singletons for TYPO3 4.3 right now. We are already one day behind the
soft feature freeze and still have the chance to get other and long time
pending stuff into TYPO3 4.3. Converting to singleton could be a task
for TYPO3 4.4.

What we can discuss/vote about here is whether "final" is removed from
static classes or not. "final" does not mean that a class is static it
means that a class cannot be extended by another one.

olly
-- 
Oliver Hader
TYPO3 Release Manager 4.3


More information about the TYPO3-team-core mailing list