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

Oliver Hader oliver at typo3.org
Tue Sep 1 12:07:28 CEST 2009


Hi Bastian,

Bastian Waidelich schrieb:
> Martin Kutschker wrote:
> 
> Hi Masi & co,
> 
>> I stumbled into the same problem, but I don't like Steffens approach to
>> "extend" a static class.
> 
> I agree, "eval is evil" ;)
> But: In the last days I stumbled upon the problem, that we have lots of
> dependencies in the core classes that are impossible to mock in unit
> tests. Even if you only want to test a single method - if this creates a
> new instance using t3lib_div::makeInstance, there are actually three
> classes involved.
> In short: having the possibility to mock t3lib_dib in phpunit
> environment would be a great help to ease and stabilize unit tests (not
> only for core classes).

Exactly. That were also my concerns with having the "final" declaration.
If a static class stores caches to an internal protected variable it's
not possible to perform isolated test for it.
Currently the "t3lib_extmgm_testcase" has such problems with the first
unit test there. A variable was filled before by a regular core call and
cannot be reset anymore for the test case.

>> Better would be to fade out these static classes and create singletons
>> instead.
> 
> Absolutely!

Yes, but a various number of extension uses static calls to t3lib_div -
so we cannot just transform this to a singleton object.

olly
-- 
Oliver Hader
TYPO3 Release Manager 4.3


More information about the TYPO3-team-core mailing list