[TYPO3-core] RFC #15644: Replace magic numbers for shortcut_mode with class constants
Ernesto Baschny [cron IT]
ernst at cron-it.de
Mon Sep 6 19:51:50 CEST 2010
Steffen Gebert schrieb am 05.09.2010 21:08:
> This is a SVN patch request.
>
> Type: Bugfix/Clean-up
>
> Bugtracker reference:
> http://bugs.typo3.org/view.php?id=15644
>
> Branches:
> trunk
>
> Problem:
> Option shortcut_mode uses magic numbers to distinguish the option's value.
>
> Solution:
> Replace them with meaningful class constants:
>> const SHORTCUT_MODE_NONE = 0;
>> const SHORTCUT_MODE_FIRST_SUBPAGE = 1;
>> const SHORTCUT_MODE_RANDOM_SUBPAGE = 2;
>> const SHORTCUT_MODE_PARENT = 3;
+1 on reading. Following comments:
I agree with Steffen (Kamper). t3lib_page sounds a more appropriate
namespace for that constants.
Please don't change the "==" with "===" in this patch, as this would
mean a change of functionality and not only an introduction of
constants. That should be a separate RFC, if someone wants to try that.
e.g.
if ($row['shortcut_mode'] == 0)
should be the same as
if ( (int)$row['shortcut_mode'] === 0 )
but.. it isn't really more readable and not even more consistent. So
only add the constants first. To make it consistent with the labels, the
last one has to be called:
const SHORTCUT_MODE_PARENT_PAGE = 3;
Cheers,
Ernesto
More information about the TYPO3-team-core
mailing list