Completed
Branch master (b65d76)
by David
04:29
created
lib/Dwoo/Plugins/Functions/PluginTruncate.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -33,25 +33,25 @@
 block discarded – undo
33 33
  */
34 34
 function PluginTruncate(Core $dwoo, $value, $length = 80, $etc = '...', $break = false, $middle = false)
35 35
 {
36
-    if ($length == 0) {
37
-        return '';
38
-    }
36
+	if ($length == 0) {
37
+		return '';
38
+	}
39 39
 
40
-    $value  = (string)$value;
41
-    $etc    = (string)$etc;
42
-    $length = (int)$length;
40
+	$value  = (string)$value;
41
+	$etc    = (string)$etc;
42
+	$length = (int)$length;
43 43
 
44
-    if (strlen($value) < $length) {
45
-        return $value;
46
-    }
44
+	if (strlen($value) < $length) {
45
+		return $value;
46
+	}
47 47
 
48
-    $length = max($length - strlen($etc), 0);
49
-    if ($break === false && $middle === false) {
50
-        $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1));
51
-    }
52
-    if ($middle === false) {
53
-        return substr($value, 0, $length) . $etc;
54
-    }
48
+	$length = max($length - strlen($etc), 0);
49
+	if ($break === false && $middle === false) {
50
+		$value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1));
51
+	}
52
+	if ($middle === false) {
53
+		return substr($value, 0, $length) . $etc;
54
+	}
55 55
 
56
-    return substr($value, 0, ceil($length / 2)) . $etc . substr($value, - floor($length / 2));
56
+	return substr($value, 0, ceil($length / 2)) . $etc . substr($value, - floor($length / 2));
57 57
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -37,21 +37,21 @@
 block discarded – undo
37 37
         return '';
38 38
     }
39 39
 
40
-    $value  = (string)$value;
41
-    $etc    = (string)$etc;
42
-    $length = (int)$length;
40
+    $value  = (string) $value;
41
+    $etc    = (string) $etc;
42
+    $length = (int) $length;
43 43
 
44 44
     if (strlen($value) < $length) {
45 45
         return $value;
46 46
     }
47 47
 
48
-    $length = max($length - strlen($etc), 0);
48
+    $length = max($length-strlen($etc), 0);
49 49
     if ($break === false && $middle === false) {
50
-        $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1));
50
+        $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length+1));
51 51
     }
52 52
     if ($middle === false) {
53
-        return substr($value, 0, $length) . $etc;
53
+        return substr($value, 0, $length).$etc;
54 54
     }
55 55
 
56
-    return substr($value, 0, ceil($length / 2)) . $etc . substr($value, - floor($length / 2));
56
+    return substr($value, 0, ceil($length/2)).$etc.substr($value, - floor($length/2));
57 57
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginTifCompile.php 3 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -34,56 +34,56 @@
 block discarded – undo
34 34
  */
35 35
 function PluginTifCompile(Compiler $compiler, array $rest, array $tokens)
36 36
 {
37
-    // load if plugin
38
-    if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf')) {
39
-        try {
40
-            $compiler->getDwoo()->getLoader()->loadPlugin('if');
41
-        }
42
-        catch (Exception $e) {
43
-            throw new CompilationException($compiler, 'Tif: the if plugin is required to use Tif');
44
-        }
45
-    }
37
+	// load if plugin
38
+	if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf')) {
39
+		try {
40
+			$compiler->getDwoo()->getLoader()->loadPlugin('if');
41
+		}
42
+		catch (Exception $e) {
43
+			throw new CompilationException($compiler, 'Tif: the if plugin is required to use Tif');
44
+		}
45
+	}
46 46
 
47
-    if (count($rest) == 1) {
48
-        return $rest[0];
49
-    }
47
+	if (count($rest) == 1) {
48
+		return $rest[0];
49
+	}
50 50
 
51
-    // fetch false result and remove the ":" if it was present
52
-    $falseResult = array_pop($rest);
51
+	// fetch false result and remove the ":" if it was present
52
+	$falseResult = array_pop($rest);
53 53
 
54
-    if (trim(end($rest), '"\'') === ':') {
55
-        // remove the ':' if present
56
-        array_pop($rest);
57
-    } elseif (trim(end($rest), '"\'') === '?' || count($rest) === 1) {
58
-        if ($falseResult === '?' || $falseResult === ':') {
59
-            throw new CompilationException($compiler, 'Tif: incomplete tif statement, value missing after ' . $falseResult);
60
-        }
61
-        // there was in fact no false result provided, so we move it to be the true result instead
62
-        $trueResult  = $falseResult;
63
-        $falseResult = "''";
64
-    }
54
+	if (trim(end($rest), '"\'') === ':') {
55
+		// remove the ':' if present
56
+		array_pop($rest);
57
+	} elseif (trim(end($rest), '"\'') === '?' || count($rest) === 1) {
58
+		if ($falseResult === '?' || $falseResult === ':') {
59
+			throw new CompilationException($compiler, 'Tif: incomplete tif statement, value missing after ' . $falseResult);
60
+		}
61
+		// there was in fact no false result provided, so we move it to be the true result instead
62
+		$trueResult  = $falseResult;
63
+		$falseResult = "''";
64
+	}
65 65
 
66
-    // fetch true result if needed
67
-    if (!isset($trueResult)) {
68
-        $trueResult = array_pop($rest);
69
-        // no true result provided so we use the expression arg
70
-        if ($trueResult === '?') {
71
-            $trueResult = true;
72
-        }
73
-    }
66
+	// fetch true result if needed
67
+	if (!isset($trueResult)) {
68
+		$trueResult = array_pop($rest);
69
+		// no true result provided so we use the expression arg
70
+		if ($trueResult === '?') {
71
+			$trueResult = true;
72
+		}
73
+	}
74 74
 
75
-    // remove the '?' if present
76
-    if (trim(end($rest), '"\'') === '?') {
77
-        array_pop($rest);
78
-    }
75
+	// remove the '?' if present
76
+	if (trim(end($rest), '"\'') === '?') {
77
+		array_pop($rest);
78
+	}
79 79
 
80
-    // check params were correctly provided
81
-    if (empty($rest) || $trueResult === null || $falseResult === null) {
82
-        throw new CompilationException($compiler, 'Tif: you must provide three parameters serving as <expression> ? <true value> : <false value>');
83
-    }
80
+	// check params were correctly provided
81
+	if (empty($rest) || $trueResult === null || $falseResult === null) {
82
+		throw new CompilationException($compiler, 'Tif: you must provide three parameters serving as <expression> ? <true value> : <false value>');
83
+	}
84 84
 
85
-    // parse condition
86
-    $condition = PluginIf::replaceKeywords($rest, $tokens, $compiler);
85
+	// parse condition
86
+	$condition = PluginIf::replaceKeywords($rest, $tokens, $compiler);
87 87
 
88
-    return '((' . implode(' ', $condition) . ') ? ' . ($trueResult === true ? implode(' ', $condition) : $trueResult) . ' : ' . $falseResult . ')';
88
+	return '((' . implode(' ', $condition) . ') ? ' . ($trueResult === true ? implode(' ', $condition) : $trueResult) . ' : ' . $falseResult . ')';
89 89
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 function PluginTifCompile(Compiler $compiler, array $rest, array $tokens)
36 36
 {
37 37
     // load if plugin
38
-    if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf')) {
38
+    if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS.'PluginIf')) {
39 39
         try {
40 40
             $compiler->getDwoo()->getLoader()->loadPlugin('if');
41 41
         }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         array_pop($rest);
57 57
     } elseif (trim(end($rest), '"\'') === '?' || count($rest) === 1) {
58 58
         if ($falseResult === '?' || $falseResult === ':') {
59
-            throw new CompilationException($compiler, 'Tif: incomplete tif statement, value missing after ' . $falseResult);
59
+            throw new CompilationException($compiler, 'Tif: incomplete tif statement, value missing after '.$falseResult);
60 60
         }
61 61
         // there was in fact no false result provided, so we move it to be the true result instead
62 62
         $trueResult  = $falseResult;
@@ -85,5 +85,5 @@  discard block
 block discarded – undo
85 85
     // parse condition
86 86
     $condition = PluginIf::replaceKeywords($rest, $tokens, $compiler);
87 87
 
88
-    return '((' . implode(' ', $condition) . ') ? ' . ($trueResult === true ? implode(' ', $condition) : $trueResult) . ' : ' . $falseResult . ')';
88
+    return '(('.implode(' ', $condition).') ? '.($trueResult === true ? implode(' ', $condition) : $trueResult).' : '.$falseResult.')';
89 89
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,7 @@
 block discarded – undo
38 38
     if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf')) {
39 39
         try {
40 40
             $compiler->getDwoo()->getLoader()->loadPlugin('if');
41
-        }
42
-        catch (Exception $e) {
41
+        } catch (Exception $e) {
43 42
             throw new CompilationException($compiler, 'Tif: the if plugin is required to use Tif');
44 43
         }
45 44
     }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginReplaceCompile.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@
 block discarded – undo
30 30
  */
31 31
 function PluginReplaceCompile(Compiler $compiler, $value, $search, $replace, $case_sensitive = true)
32 32
 {
33
-    if ($case_sensitive == 'false' || (bool)$case_sensitive === false) {
34
-        return 'str_ireplace(' . $search . ', ' . $replace . ', ' . $value . ')';
35
-    } else {
36
-        return 'str_replace(' . $search . ', ' . $replace . ', ' . $value . ')';
37
-    }
33
+	if ($case_sensitive == 'false' || (bool)$case_sensitive === false) {
34
+		return 'str_ireplace(' . $search . ', ' . $replace . ', ' . $value . ')';
35
+	} else {
36
+		return 'str_replace(' . $search . ', ' . $replace . ', ' . $value . ')';
37
+	}
38 38
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@
 block discarded – undo
30 30
  */
31 31
 function PluginReplaceCompile(Compiler $compiler, $value, $search, $replace, $case_sensitive = true)
32 32
 {
33
-    if ($case_sensitive == 'false' || (bool)$case_sensitive === false) {
34
-        return 'str_ireplace(' . $search . ', ' . $replace . ', ' . $value . ')';
33
+    if ($case_sensitive == 'false' || (bool) $case_sensitive === false) {
34
+        return 'str_ireplace('.$search.', '.$replace.', '.$value.')';
35 35
     } else {
36
-        return 'str_replace(' . $search . ', ' . $replace . ', ' . $value . ')';
36
+        return 'str_replace('.$search.', '.$replace.', '.$value.')';
37 37
     }
38 38
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginCountParagraphsCompile.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,5 +28,5 @@
 block discarded – undo
28 28
  */
29 29
 function PluginCountParagraphsCompile(Compiler $compiler, $value)
30 30
 {
31
-    return '(preg_match_all(\'#[\r\n]+#\', ' . $value . ', $tmp)+1)';
31
+	return '(preg_match_all(\'#[\r\n]+#\', ' . $value . ', $tmp)+1)';
32 32
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,5 +28,5 @@
 block discarded – undo
28 28
  */
29 29
 function PluginCountParagraphsCompile(Compiler $compiler, $value)
30 30
 {
31
-    return '(preg_match_all(\'#[\r\n]+#\', ' . $value . ', $tmp)+1)';
31
+    return '(preg_match_all(\'#[\r\n]+#\', '.$value.', $tmp)+1)';
32 32
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginFetch.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -30,40 +30,40 @@
 block discarded – undo
30 30
  */
31 31
 function PluginFetch(Core $dwoo, $file, $assign = null)
32 32
 {
33
-    if ($file === '') {
34
-        return '';
35
-    }
33
+	if ($file === '') {
34
+		return '';
35
+	}
36 36
 
37
-    if ($policy = $dwoo->getSecurityPolicy()) {
38
-        while (true) {
39
-            if (preg_match('{^([a-z]+?)://}i', $file)) {
40
-                $dwoo->triggerError('The security policy prevents you to read files from external sources.', E_USER_WARNING);
41
-            }
37
+	if ($policy = $dwoo->getSecurityPolicy()) {
38
+		while (true) {
39
+			if (preg_match('{^([a-z]+?)://}i', $file)) {
40
+				$dwoo->triggerError('The security policy prevents you to read files from external sources.', E_USER_WARNING);
41
+			}
42 42
 
43
-            $file = realpath($file);
44
-            $dirs = $policy->getAllowedDirectories();
45
-            foreach ($dirs as $dir => $dummy) {
46
-                if (strpos($file, $dir) === 0) {
47
-                    break 2;
48
-                }
49
-            }
50
-            $dwoo->triggerError('The security policy prevents you to read <em>' . $file . '</em>', E_USER_WARNING);
51
-        }
52
-    }
53
-    $file = str_replace(array(
54
-        "\t",
55
-        "\n",
56
-        "\r"
57
-    ), array(
58
-        '\\t',
59
-        '\\n',
60
-        '\\r'
61
-    ), $file);
43
+			$file = realpath($file);
44
+			$dirs = $policy->getAllowedDirectories();
45
+			foreach ($dirs as $dir => $dummy) {
46
+				if (strpos($file, $dir) === 0) {
47
+					break 2;
48
+				}
49
+			}
50
+			$dwoo->triggerError('The security policy prevents you to read <em>' . $file . '</em>', E_USER_WARNING);
51
+		}
52
+	}
53
+	$file = str_replace(array(
54
+		"\t",
55
+		"\n",
56
+		"\r"
57
+	), array(
58
+		'\\t',
59
+		'\\n',
60
+		'\\r'
61
+	), $file);
62 62
 
63
-    $out = file_get_contents($file);
63
+	$out = file_get_contents($file);
64 64
 
65
-    if ($assign === null) {
66
-        return $out;
67
-    }
68
-    $dwoo->assignInScope($out, $assign);
65
+	if ($assign === null) {
66
+		return $out;
67
+	}
68
+	$dwoo->assignInScope($out, $assign);
69 69
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
                     break 2;
48 48
                 }
49 49
             }
50
-            $dwoo->triggerError('The security policy prevents you to read <em>' . $file . '</em>', E_USER_WARNING);
50
+            $dwoo->triggerError('The security policy prevents you to read <em>'.$file.'</em>', E_USER_WARNING);
51 51
         }
52 52
     }
53 53
     $file = str_replace(array(
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginSpacifyCompile.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,5 +29,5 @@
 block discarded – undo
29 29
  */
30 30
 function PluginSpacifyCompile(Compiler $compiler, $value, $space_char = ' ')
31 31
 {
32
-    return 'implode(' . $space_char . ', str_split(' . $value . ', 1))';
32
+	return 'implode(' . $space_char . ', str_split(' . $value . ', 1))';
33 33
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,5 +29,5 @@
 block discarded – undo
29 29
  */
30 30
 function PluginSpacifyCompile(Compiler $compiler, $value, $space_char = ' ')
31 31
 {
32
-    return 'implode(' . $space_char . ', str_split(' . $value . ', 1))';
32
+    return 'implode('.$space_char.', str_split('.$value.', 1))';
33 33
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginLowerCompile.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,5 +28,5 @@
 block discarded – undo
28 28
  */
29 29
 function PluginLowerCompile(Compiler $compiler, $value)
30 30
 {
31
-    return 'mb_strtolower((string) ' . $value . ', $this->charset)';
31
+	return 'mb_strtolower((string) ' . $value . ', $this->charset)';
32 32
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,5 +28,5 @@
 block discarded – undo
28 28
  */
29 29
 function PluginLowerCompile(Compiler $compiler, $value)
30 30
 {
31
-    return 'mb_strtolower((string) ' . $value . ', $this->charset)';
31
+    return 'mb_strtolower((string) '.$value.', $this->charset)';
32 32
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginEscape.php 3 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -32,56 +32,56 @@
 block discarded – undo
32 32
  */
33 33
 function PluginEscape(Core $dwoo, $value = '', $format = 'html', $charset = null)
34 34
 {
35
-    if ($charset === null) {
36
-        $charset = $dwoo->getCharset();
37
-    }
35
+	if ($charset === null) {
36
+		$charset = $dwoo->getCharset();
37
+	}
38 38
 
39
-    switch ($format) {
39
+	switch ($format) {
40 40
 
41
-        case 'html':
42
-            return htmlspecialchars((string)$value, ENT_QUOTES, $charset);
43
-        case 'htmlall':
44
-            return htmlentities((string)$value, ENT_QUOTES, $charset);
45
-        case 'url':
46
-            return rawurlencode((string)$value);
47
-        case 'urlpathinfo':
48
-            return str_replace('%2F', '/', rawurlencode((string)$value));
49
-        case 'quotes':
50
-            return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value);
51
-        case 'hex':
52
-            $out = '';
53
-            $cnt = strlen((string)$value);
54
-            for ($i = 0; $i < $cnt; ++ $i) {
55
-                $out .= '%' . bin2hex((string)$value[$i]);
56
-            }
41
+		case 'html':
42
+			return htmlspecialchars((string)$value, ENT_QUOTES, $charset);
43
+		case 'htmlall':
44
+			return htmlentities((string)$value, ENT_QUOTES, $charset);
45
+		case 'url':
46
+			return rawurlencode((string)$value);
47
+		case 'urlpathinfo':
48
+			return str_replace('%2F', '/', rawurlencode((string)$value));
49
+		case 'quotes':
50
+			return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value);
51
+		case 'hex':
52
+			$out = '';
53
+			$cnt = strlen((string)$value);
54
+			for ($i = 0; $i < $cnt; ++ $i) {
55
+				$out .= '%' . bin2hex((string)$value[$i]);
56
+			}
57 57
 
58
-            return $out;
59
-        case 'hexentity':
60
-            $out = '';
61
-            $cnt = strlen((string)$value);
62
-            for ($i = 0; $i < $cnt; ++ $i) {
63
-                $out .= '&#x' . bin2hex((string)$value[$i]) . ';';
64
-            }
58
+			return $out;
59
+		case 'hexentity':
60
+			$out = '';
61
+			$cnt = strlen((string)$value);
62
+			for ($i = 0; $i < $cnt; ++ $i) {
63
+				$out .= '&#x' . bin2hex((string)$value[$i]) . ';';
64
+			}
65 65
 
66
-            return $out;
67
-        case 'javascript':
68
-            return strtr((string)$value, array(
69
-                '\\' => '\\\\',
70
-                "'"  => "\\'",
71
-                '"'  => '\\"',
72
-                "\r" => '\\r',
73
-                "\n" => '\\n',
74
-                '</' => '<\/'
75
-            ));
76
-        case 'mail':
77
-            return str_replace(array(
78
-                '@',
79
-                '.'
80
-            ), array(
81
-                '&nbsp;(AT)&nbsp;',
82
-                '&nbsp;(DOT)&nbsp;'
83
-            ), (string)$value);
84
-        default:
85
-            $dwoo->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript or mail, "' . $format . '" given.', E_USER_WARNING);
86
-    }
66
+			return $out;
67
+		case 'javascript':
68
+			return strtr((string)$value, array(
69
+				'\\' => '\\\\',
70
+				"'"  => "\\'",
71
+				'"'  => '\\"',
72
+				"\r" => '\\r',
73
+				"\n" => '\\n',
74
+				'</' => '<\/'
75
+			));
76
+		case 'mail':
77
+			return str_replace(array(
78
+				'@',
79
+				'.'
80
+			), array(
81
+				'&nbsp;(AT)&nbsp;',
82
+				'&nbsp;(DOT)&nbsp;'
83
+			), (string)$value);
84
+		default:
85
+			$dwoo->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript or mail, "' . $format . '" given.', E_USER_WARNING);
86
+	}
87 87
 }
Please login to merge, or discard this patch.
Switch Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -38,50 +38,50 @@
 block discarded – undo
38 38
 
39 39
     switch ($format) {
40 40
 
41
-        case 'html':
42
-            return htmlspecialchars((string)$value, ENT_QUOTES, $charset);
43
-        case 'htmlall':
44
-            return htmlentities((string)$value, ENT_QUOTES, $charset);
45
-        case 'url':
46
-            return rawurlencode((string)$value);
47
-        case 'urlpathinfo':
48
-            return str_replace('%2F', '/', rawurlencode((string)$value));
49
-        case 'quotes':
50
-            return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value);
51
-        case 'hex':
52
-            $out = '';
53
-            $cnt = strlen((string)$value);
54
-            for ($i = 0; $i < $cnt; ++ $i) {
55
-                $out .= '%' . bin2hex((string)$value[$i]);
56
-            }
41
+    case 'html':
42
+        return htmlspecialchars((string)$value, ENT_QUOTES, $charset);
43
+    case 'htmlall':
44
+        return htmlentities((string)$value, ENT_QUOTES, $charset);
45
+    case 'url':
46
+        return rawurlencode((string)$value);
47
+    case 'urlpathinfo':
48
+        return str_replace('%2F', '/', rawurlencode((string)$value));
49
+    case 'quotes':
50
+        return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value);
51
+    case 'hex':
52
+        $out = '';
53
+        $cnt = strlen((string)$value);
54
+        for ($i = 0; $i < $cnt; ++ $i) {
55
+            $out .= '%' . bin2hex((string)$value[$i]);
56
+        }
57 57
 
58
-            return $out;
59
-        case 'hexentity':
60
-            $out = '';
61
-            $cnt = strlen((string)$value);
62
-            for ($i = 0; $i < $cnt; ++ $i) {
63
-                $out .= '&#x' . bin2hex((string)$value[$i]) . ';';
64
-            }
58
+        return $out;
59
+    case 'hexentity':
60
+        $out = '';
61
+        $cnt = strlen((string)$value);
62
+        for ($i = 0; $i < $cnt; ++ $i) {
63
+            $out .= '&#x' . bin2hex((string)$value[$i]) . ';';
64
+        }
65 65
 
66
-            return $out;
67
-        case 'javascript':
68
-            return strtr((string)$value, array(
69
-                '\\' => '\\\\',
70
-                "'"  => "\\'",
71
-                '"'  => '\\"',
72
-                "\r" => '\\r',
73
-                "\n" => '\\n',
74
-                '</' => '<\/'
75
-            ));
76
-        case 'mail':
77
-            return str_replace(array(
78
-                '@',
79
-                '.'
80
-            ), array(
81
-                '&nbsp;(AT)&nbsp;',
82
-                '&nbsp;(DOT)&nbsp;'
83
-            ), (string)$value);
84
-        default:
85
-            $dwoo->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript or mail, "' . $format . '" given.', E_USER_WARNING);
66
+        return $out;
67
+    case 'javascript':
68
+        return strtr((string)$value, array(
69
+            '\\' => '\\\\',
70
+            "'"  => "\\'",
71
+            '"'  => '\\"',
72
+            "\r" => '\\r',
73
+            "\n" => '\\n',
74
+            '</' => '<\/'
75
+        ));
76
+    case 'mail':
77
+        return str_replace(array(
78
+            '@',
79
+            '.'
80
+        ), array(
81
+            '&nbsp;(AT)&nbsp;',
82
+            '&nbsp;(DOT)&nbsp;'
83
+        ), (string)$value);
84
+    default:
85
+        $dwoo->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript or mail, "' . $format . '" given.', E_USER_WARNING);
86 86
     }
87 87
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -39,33 +39,33 @@  discard block
 block discarded – undo
39 39
     switch ($format) {
40 40
 
41 41
         case 'html':
42
-            return htmlspecialchars((string)$value, ENT_QUOTES, $charset);
42
+            return htmlspecialchars((string) $value, ENT_QUOTES, $charset);
43 43
         case 'htmlall':
44
-            return htmlentities((string)$value, ENT_QUOTES, $charset);
44
+            return htmlentities((string) $value, ENT_QUOTES, $charset);
45 45
         case 'url':
46
-            return rawurlencode((string)$value);
46
+            return rawurlencode((string) $value);
47 47
         case 'urlpathinfo':
48
-            return str_replace('%2F', '/', rawurlencode((string)$value));
48
+            return str_replace('%2F', '/', rawurlencode((string) $value));
49 49
         case 'quotes':
50
-            return preg_replace("#(?<!\\\\)'#", "\\'", (string)$value);
50
+            return preg_replace("#(?<!\\\\)'#", "\\'", (string) $value);
51 51
         case 'hex':
52 52
             $out = '';
53
-            $cnt = strlen((string)$value);
53
+            $cnt = strlen((string) $value);
54 54
             for ($i = 0; $i < $cnt; ++ $i) {
55
-                $out .= '%' . bin2hex((string)$value[$i]);
55
+                $out .= '%'.bin2hex((string) $value[$i]);
56 56
             }
57 57
 
58 58
             return $out;
59 59
         case 'hexentity':
60 60
             $out = '';
61
-            $cnt = strlen((string)$value);
61
+            $cnt = strlen((string) $value);
62 62
             for ($i = 0; $i < $cnt; ++ $i) {
63
-                $out .= '&#x' . bin2hex((string)$value[$i]) . ';';
63
+                $out .= '&#x'.bin2hex((string) $value[$i]).';';
64 64
             }
65 65
 
66 66
             return $out;
67 67
         case 'javascript':
68
-            return strtr((string)$value, array(
68
+            return strtr((string) $value, array(
69 69
                 '\\' => '\\\\',
70 70
                 "'"  => "\\'",
71 71
                 '"'  => '\\"',
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
             ), array(
81 81
                 '&nbsp;(AT)&nbsp;',
82 82
                 '&nbsp;(DOT)&nbsp;'
83
-            ), (string)$value);
83
+            ), (string) $value);
84 84
         default:
85
-            $dwoo->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript or mail, "' . $format . '" given.', E_USER_WARNING);
85
+            $dwoo->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript or mail, "'.$format.'" given.', E_USER_WARNING);
86 86
     }
87 87
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginMathCompile.php 2 patches
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -39,143 +39,143 @@
 block discarded – undo
39 39
  */
40 40
 function PluginMathCompile(Compiler $compiler, $equation, $format = '', $assign = '', array $rest = array())
41 41
 {
42
-    /*
42
+	/*
43 43
      * Holds the allowed function, characters, operators and constants
44 44
      */
45
-    $allowed = array(
46
-        '0',
47
-        '1',
48
-        '2',
49
-        '3',
50
-        '4',
51
-        '5',
52
-        '6',
53
-        '7',
54
-        '8',
55
-        '9',
56
-        '+',
57
-        '-',
58
-        '/',
59
-        '*',
60
-        '.',
61
-        ' ',
62
-        '<<',
63
-        '>>',
64
-        '%',
65
-        '&',
66
-        '^',
67
-        '|',
68
-        '~',
69
-        'abs(',
70
-        'ceil(',
71
-        'floor(',
72
-        'exp(',
73
-        'log10(',
74
-        'cos(',
75
-        'sin(',
76
-        'sqrt(',
77
-        'tan(',
78
-        'M_PI',
79
-        'INF',
80
-        'M_E',
81
-    );
45
+	$allowed = array(
46
+		'0',
47
+		'1',
48
+		'2',
49
+		'3',
50
+		'4',
51
+		'5',
52
+		'6',
53
+		'7',
54
+		'8',
55
+		'9',
56
+		'+',
57
+		'-',
58
+		'/',
59
+		'*',
60
+		'.',
61
+		' ',
62
+		'<<',
63
+		'>>',
64
+		'%',
65
+		'&',
66
+		'^',
67
+		'|',
68
+		'~',
69
+		'abs(',
70
+		'ceil(',
71
+		'floor(',
72
+		'exp(',
73
+		'log10(',
74
+		'cos(',
75
+		'sin(',
76
+		'sqrt(',
77
+		'tan(',
78
+		'M_PI',
79
+		'INF',
80
+		'M_E',
81
+	);
82 82
 
83
-    /*
83
+	/*
84 84
      * Holds the functions that can accept multiple arguments
85 85
      */
86
-    $funcs = array(
87
-        'round(',
88
-        'log(',
89
-        'pow(',
90
-        'max(',
91
-        'min(',
92
-        'rand(',
93
-    );
86
+	$funcs = array(
87
+		'round(',
88
+		'log(',
89
+		'pow(',
90
+		'max(',
91
+		'min(',
92
+		'rand(',
93
+	);
94 94
 
95
-    $equation = $equationSrc = str_ireplace(array(
96
-        'pi',
97
-        'M_PI()',
98
-        'inf',
99
-        ' e '
100
-    ), array(
101
-        'M_PI',
102
-        'M_PI',
103
-        'INF',
104
-        ' M_E '
105
-    ), $equation);
95
+	$equation = $equationSrc = str_ireplace(array(
96
+		'pi',
97
+		'M_PI()',
98
+		'inf',
99
+		' e '
100
+	), array(
101
+		'M_PI',
102
+		'M_PI',
103
+		'INF',
104
+		' M_E '
105
+	), $equation);
106 106
 
107
-    $delim      = $equation[0];
108
-    $open       = $delim . '.';
109
-    $close      = '.' . $delim;
110
-    $equation   = substr($equation, 1, - 1);
111
-    $out        = '';
112
-    $ptr        = 1;
113
-    $allowcomma = 0;
114
-    while (strlen($equation) > 0) {
115
-        $substr = substr($equation, 0, $ptr);
116
-        if (array_search($substr, $allowed) !== false) {
117
-            // allowed string
118
-            $out .= $substr;
119
-            $equation = substr($equation, $ptr);
120
-            $ptr      = 0;
121
-        } elseif (array_search($substr, $funcs) !== false) {
122
-            // allowed func
123
-            $out .= $substr;
124
-            $equation = substr($equation, $ptr);
125
-            $ptr      = 0;
126
-            ++ $allowcomma;
127
-            if ($allowcomma === 1) {
128
-                $allowed[] = ',';
129
-            }
130
-        } elseif (isset($rest[$substr])) {
131
-            // variable
132
-            $out .= $rest[$substr];
133
-            $equation = substr($equation, $ptr);
134
-            $ptr      = 0;
135
-        } elseif ($substr === $open) {
136
-            // pre-replaced variable
137
-            preg_match('#.*\((?:[^()]*?|(?R))\)' . str_replace('.', '\\.', $close) . '#', substr($equation, 2), $m);
138
-            if (empty($m)) {
139
-                preg_match('#.*?' . str_replace('.', '\\.', $close) . '#', substr($equation, 2), $m);
140
-            }
141
-            $out .= substr($m[0], 0, - 2);
142
-            $equation = substr($equation, strlen($m[0]) + 2);
143
-            $ptr      = 0;
144
-        } elseif ($substr === '(') {
145
-            // opening parenthesis
146
-            if ($allowcomma > 0) {
147
-                ++ $allowcomma;
148
-            }
107
+	$delim      = $equation[0];
108
+	$open       = $delim . '.';
109
+	$close      = '.' . $delim;
110
+	$equation   = substr($equation, 1, - 1);
111
+	$out        = '';
112
+	$ptr        = 1;
113
+	$allowcomma = 0;
114
+	while (strlen($equation) > 0) {
115
+		$substr = substr($equation, 0, $ptr);
116
+		if (array_search($substr, $allowed) !== false) {
117
+			// allowed string
118
+			$out .= $substr;
119
+			$equation = substr($equation, $ptr);
120
+			$ptr      = 0;
121
+		} elseif (array_search($substr, $funcs) !== false) {
122
+			// allowed func
123
+			$out .= $substr;
124
+			$equation = substr($equation, $ptr);
125
+			$ptr      = 0;
126
+			++ $allowcomma;
127
+			if ($allowcomma === 1) {
128
+				$allowed[] = ',';
129
+			}
130
+		} elseif (isset($rest[$substr])) {
131
+			// variable
132
+			$out .= $rest[$substr];
133
+			$equation = substr($equation, $ptr);
134
+			$ptr      = 0;
135
+		} elseif ($substr === $open) {
136
+			// pre-replaced variable
137
+			preg_match('#.*\((?:[^()]*?|(?R))\)' . str_replace('.', '\\.', $close) . '#', substr($equation, 2), $m);
138
+			if (empty($m)) {
139
+				preg_match('#.*?' . str_replace('.', '\\.', $close) . '#', substr($equation, 2), $m);
140
+			}
141
+			$out .= substr($m[0], 0, - 2);
142
+			$equation = substr($equation, strlen($m[0]) + 2);
143
+			$ptr      = 0;
144
+		} elseif ($substr === '(') {
145
+			// opening parenthesis
146
+			if ($allowcomma > 0) {
147
+				++ $allowcomma;
148
+			}
149 149
 
150
-            $out .= $substr;
151
-            $equation = substr($equation, $ptr);
152
-            $ptr      = 0;
153
-        } elseif ($substr === ')') {
154
-            // closing parenthesis
155
-            if ($allowcomma > 0) {
156
-                -- $allowcomma;
157
-                if ($allowcomma === 0) {
158
-                    array_pop($allowed);
159
-                }
160
-            }
150
+			$out .= $substr;
151
+			$equation = substr($equation, $ptr);
152
+			$ptr      = 0;
153
+		} elseif ($substr === ')') {
154
+			// closing parenthesis
155
+			if ($allowcomma > 0) {
156
+				-- $allowcomma;
157
+				if ($allowcomma === 0) {
158
+					array_pop($allowed);
159
+				}
160
+			}
161 161
 
162
-            $out .= $substr;
163
-            $equation = substr($equation, $ptr);
164
-            $ptr      = 0;
165
-        } elseif ($ptr >= strlen($equation)) {
166
-            // parse error if we've consumed the entire equation without finding anything valid
167
-            throw new CompilationException($compiler, 'Math : Syntax error or variable undefined in equation ' . $equationSrc . ' at ' . $substr);
168
-        } else {
169
-            // nothing special, advance
170
-            ++ $ptr;
171
-        }
172
-    }
173
-    if ($format !== '\'\'') {
174
-        $out = 'sprintf(' . $format . ', ' . $out . ')';
175
-    }
176
-    if ($assign !== '\'\'') {
177
-        return '($this->assignInScope(' . $out . ', ' . $assign . '))';
178
-    }
162
+			$out .= $substr;
163
+			$equation = substr($equation, $ptr);
164
+			$ptr      = 0;
165
+		} elseif ($ptr >= strlen($equation)) {
166
+			// parse error if we've consumed the entire equation without finding anything valid
167
+			throw new CompilationException($compiler, 'Math : Syntax error or variable undefined in equation ' . $equationSrc . ' at ' . $substr);
168
+		} else {
169
+			// nothing special, advance
170
+			++ $ptr;
171
+		}
172
+	}
173
+	if ($format !== '\'\'') {
174
+		$out = 'sprintf(' . $format . ', ' . $out . ')';
175
+	}
176
+	if ($assign !== '\'\'') {
177
+		return '($this->assignInScope(' . $out . ', ' . $assign . '))';
178
+	}
179 179
 
180
-    return '(' . $out . ')';
180
+	return '(' . $out . ')';
181 181
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
     ), $equation);
106 106
 
107 107
     $delim      = $equation[0];
108
-    $open       = $delim . '.';
109
-    $close      = '.' . $delim;
108
+    $open       = $delim.'.';
109
+    $close      = '.'.$delim;
110 110
     $equation   = substr($equation, 1, - 1);
111 111
     $out        = '';
112 112
     $ptr        = 1;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             $out .= $substr;
124 124
             $equation = substr($equation, $ptr);
125 125
             $ptr      = 0;
126
-            ++ $allowcomma;
126
+            ++$allowcomma;
127 127
             if ($allowcomma === 1) {
128 128
                 $allowed[] = ',';
129 129
             }
@@ -134,17 +134,17 @@  discard block
 block discarded – undo
134 134
             $ptr      = 0;
135 135
         } elseif ($substr === $open) {
136 136
             // pre-replaced variable
137
-            preg_match('#.*\((?:[^()]*?|(?R))\)' . str_replace('.', '\\.', $close) . '#', substr($equation, 2), $m);
137
+            preg_match('#.*\((?:[^()]*?|(?R))\)'.str_replace('.', '\\.', $close).'#', substr($equation, 2), $m);
138 138
             if (empty($m)) {
139
-                preg_match('#.*?' . str_replace('.', '\\.', $close) . '#', substr($equation, 2), $m);
139
+                preg_match('#.*?'.str_replace('.', '\\.', $close).'#', substr($equation, 2), $m);
140 140
             }
141 141
             $out .= substr($m[0], 0, - 2);
142
-            $equation = substr($equation, strlen($m[0]) + 2);
142
+            $equation = substr($equation, strlen($m[0])+2);
143 143
             $ptr      = 0;
144 144
         } elseif ($substr === '(') {
145 145
             // opening parenthesis
146 146
             if ($allowcomma > 0) {
147
-                ++ $allowcomma;
147
+                ++$allowcomma;
148 148
             }
149 149
 
150 150
             $out .= $substr;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         } elseif ($substr === ')') {
154 154
             // closing parenthesis
155 155
             if ($allowcomma > 0) {
156
-                -- $allowcomma;
156
+                --$allowcomma;
157 157
                 if ($allowcomma === 0) {
158 158
                     array_pop($allowed);
159 159
                 }
@@ -164,18 +164,18 @@  discard block
 block discarded – undo
164 164
             $ptr      = 0;
165 165
         } elseif ($ptr >= strlen($equation)) {
166 166
             // parse error if we've consumed the entire equation without finding anything valid
167
-            throw new CompilationException($compiler, 'Math : Syntax error or variable undefined in equation ' . $equationSrc . ' at ' . $substr);
167
+            throw new CompilationException($compiler, 'Math : Syntax error or variable undefined in equation '.$equationSrc.' at '.$substr);
168 168
         } else {
169 169
             // nothing special, advance
170
-            ++ $ptr;
170
+            ++$ptr;
171 171
         }
172 172
     }
173 173
     if ($format !== '\'\'') {
174
-        $out = 'sprintf(' . $format . ', ' . $out . ')';
174
+        $out = 'sprintf('.$format.', '.$out.')';
175 175
     }
176 176
     if ($assign !== '\'\'') {
177
-        return '($this->assignInScope(' . $out . ', ' . $assign . '))';
177
+        return '($this->assignInScope('.$out.', '.$assign.'))';
178 178
     }
179 179
 
180
-    return '(' . $out . ')';
180
+    return '('.$out.')';
181 181
 }
Please login to merge, or discard this patch.