[TYPO3-core] Decisions and Changes to Coding Guidelines (CGL)

Michiel Roos michiel at maxserv.nl
Thu Jan 30 21:47:14 CET 2014


The measurements are here:
http://forge.typo3.org/issues/54517#note-8

Patch sets for you to verify the results are here:
http://forge.typo3.org/issues/54517#note-9

One of the weirdest things I have come across concerning readability is in:
\TYPO3\CMS\Backend\Controller\Wizard\AddController

if (GeneralUtility::isFirstPartOfStr($this->P['params']['pid'], '###') && substr($this->P['params']['pid'], -3) == '###') {
	$this->pid = intval($TSconfig['_' . substr($this->P['params']['pid'], 3, -3)]);
} else {
	$this->pid = (integer) $this->P['params']['pid'];
}

Where this was this code before
if (substr($this->P['params']['pid'], 0, 3) == '###' && substr($this->P['params']['pid'], -3) == '###') {
	$this->pid = intval($TSconfig['_' . substr($this->P['params']['pid'], 3, -3)]);
} else {
	$this->pid = (integer) $this->P['params']['pid'];
}

And it could be this code
if (strpos($this->P['params']['pid'], '###') === 0 && substr($this->P['params']['pid'], -3) == '###') {
	$this->pid = intval($TSconfig['_' . substr($this->P['params']['pid'], 3, -3)]);
} else {
	$this->pid = (integer) $this->P['params']['pid'];
}

I don't se a lot of difference in readability. As a programmer I can read each one of the forms just fine.

What keeps me awake at night however is 'knowing for a fact' that the last form is the most lightweight but currently is not being used. And that this situation might get even worse.


More information about the TYPO3-team-core mailing list