[TYPO3-core] RFC #7357: Use exceptions to detect missing user function

Oliver Klee typo3-german-02 at oliverklee.de
Sat Feb 2 16:38:07 CET 2008


Hi,

-1 as this patch still has a few smaller issues and is in bad need of a
refactoring. Please change these things and provide an updated patch.

+	public static function
callUserFunction($funcName,&$params,&$ref,$checkPrefix='user_',$errorMode=0)
{

Please use a space instead of a tab before the {.
Please put spaces after the commas.


+			if ($errorMode == 2) {
+				throw new Exception($errorMsg);
+			} elseif(!$errorMode)	{
+				debug($errorMsg, 1);
+			}

Please use a space before the (.

Please use ($errorMode == 0) instead of (!$errorMode) because this will
make the code a lot easier to read (I nearly gave you a -1 because the
new code didn't seem to match the new function documentation).

+			$errorMsg = "Function/class '$funcRef' was not prepended with
'$checkPrefix'";
+			if ($errorMode == 2) {
+				throw new Exception($errorMsg);
+			} elseif(!$errorMode)	{
+				debug($errorMsg, 1);

Please don't use abbreviations. $errorMsg -> $errorMessage

Please use single quotes instead of double quotes (and use string
appending with . to have the variables included).

+					$errorMsg = "<strong>ERROR:</strong> No method name
'".$parts[1]."' in class ".$parts[0];
+					if ($errorMode == 2) {
+						throw new Exception($errorMsg);
+					} elseif(!$errorMode)   {
+						debug($errorMsg, 1);
+					}

Ditto.

+				$errorMsg = "<strong>ERROR:</strong> No class named: ".$parts[0];
+				if ($errorMode == 2) {
+					throw new Exception($errorMsg);
+				} elseif(!$errorMode)   {
+					debug($errorMsg, 1);
+				}

Ditto.

Actually, we now have this code three times - this is a bad smell.
Please refactor it to a separate function.

-				if (!$silent)	debug("<strong>ERROR:</strong> No function named:
".$funcRef,1);
+				$errorMsg = "<strong>ERROR:</strong> No function named: ".$funcRef;
+				if ($errorMode == 2) {
+					throw new Exception($errorMsg);
+				} elseif(!$errorMode)   {
+					debug($errorMsg, 1);
+				}

Ditto (the 4th time).


Regards,


Oliver


More information about the TYPO3-team-core mailing list