Completed
Pull Request — master (#87)
by David
14:35 queued 07:46
created
lib/Dwoo/Plugins/Functions/PluginIndent.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,16 +32,16 @@
 block discarded – undo
32 32
  */
33 33
 class PluginIndent extends Plugin implements ICompilable
34 34
 {
35
-    /**
36
-     * @param Compiler $compiler
37
-     * @param string   $value
38
-     * @param int      $by
39
-     * @param string   $char
40
-     *
41
-     * @return string
42
-     */
43
-    public static function compile(Compiler $compiler, $value, $by = 4, $char = ' ')
44
-    {
45
-        return "preg_replace('#^#m', '" . str_repeat(substr($char, 1, - 1), trim($by, '"\'')) . "', $value)";
46
-    }
35
+	/**
36
+	 * @param Compiler $compiler
37
+	 * @param string   $value
38
+	 * @param int      $by
39
+	 * @param string   $char
40
+	 *
41
+	 * @return string
42
+	 */
43
+	public static function compile(Compiler $compiler, $value, $by = 4, $char = ' ')
44
+	{
45
+		return "preg_replace('#^#m', '" . str_repeat(substr($char, 1, - 1), trim($by, '"\'')) . "', $value)";
46
+	}
47 47
 }
48 48
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginTruncate.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -33,37 +33,37 @@
 block discarded – undo
33 33
  */
34 34
 class PluginTruncate extends Plugin
35 35
 {
36
-    /**
37
-     * @param string $value
38
-     * @param int    $length
39
-     * @param string $etc
40
-     * @param bool   $break
41
-     * @param bool   $middle
42
-     *
43
-     * @return mixed|string
44
-     */
45
-    public function process($value, $length = 80, $etc = '...', $break = false, $middle = false)
46
-    {
47
-        if ($length == 0) {
48
-            return '';
49
-        }
36
+	/**
37
+	 * @param string $value
38
+	 * @param int    $length
39
+	 * @param string $etc
40
+	 * @param bool   $break
41
+	 * @param bool   $middle
42
+	 *
43
+	 * @return mixed|string
44
+	 */
45
+	public function process($value, $length = 80, $etc = '...', $break = false, $middle = false)
46
+	{
47
+		if ($length == 0) {
48
+			return '';
49
+		}
50 50
 
51
-        $value  = (string)$value;
52
-        $etc    = (string)$etc;
53
-        $length = (int)$length;
51
+		$value  = (string)$value;
52
+		$etc    = (string)$etc;
53
+		$length = (int)$length;
54 54
 
55
-        if (strlen($value) < $length) {
56
-            return $value;
57
-        }
55
+		if (strlen($value) < $length) {
56
+			return $value;
57
+		}
58 58
 
59
-        $length = max($length - strlen($etc), 0);
60
-        if ($break === false && $middle === false) {
61
-            $value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1));
62
-        }
63
-        if ($middle === false) {
64
-            return substr($value, 0, $length) . $etc;
65
-        }
59
+		$length = max($length - strlen($etc), 0);
60
+		if ($break === false && $middle === false) {
61
+			$value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length + 1));
62
+		}
63
+		if ($middle === false) {
64
+			return substr($value, 0, $length) . $etc;
65
+		}
66 66
 
67
-        return substr($value, 0, ceil($length / 2)) . $etc . substr($value, - floor($length / 2));
68
-    }
67
+		return substr($value, 0, ceil($length / 2)) . $etc . substr($value, - floor($length / 2));
68
+	}
69 69
 }
70 70
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginDefault.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,15 +31,15 @@
 block discarded – undo
31 31
  */
32 32
 class PluginDefault extends Plugin implements ICompilable
33 33
 {
34
-    /**
35
-     * @param Compiler $compiler
36
-     * @param mixed    $value
37
-     * @param string   $default
38
-     *
39
-     * @return string
40
-     */
41
-    public static function compile(Compiler $compiler, $value, $default = '')
42
-    {
43
-        return '(($tmp = ' . $value . ')===null||$tmp===\'\' ? ' . $default . ' : $tmp)';
44
-    }
34
+	/**
35
+	 * @param Compiler $compiler
36
+	 * @param mixed    $value
37
+	 * @param string   $default
38
+	 *
39
+	 * @return string
40
+	 */
41
+	public static function compile(Compiler $compiler, $value, $default = '')
42
+	{
43
+		return '(($tmp = ' . $value . ')===null||$tmp===\'\' ? ' . $default . ' : $tmp)';
44
+	}
45 45
 }
46 46
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginCat.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -30,15 +30,15 @@
 block discarded – undo
30 30
  */
31 31
 class PluginCat extends Plugin implements ICompilable
32 32
 {
33
-    /**
34
-     * @param Compiler $compiler
35
-     * @param string   $value
36
-     * @param array    $rest
37
-     *
38
-     * @return string
39
-     */
40
-    public static function compile(Compiler $compiler, $value, array $rest)
41
-    {
42
-        return '(' . $value . ').(' . implode(').(', $rest) . ')';
43
-    }
33
+	/**
34
+	 * @param Compiler $compiler
35
+	 * @param string   $value
36
+	 * @param array    $rest
37
+	 *
38
+	 * @return string
39
+	 */
40
+	public static function compile(Compiler $compiler, $value, array $rest)
41
+	{
42
+		return '(' . $value . ').(' . implode(').(', $rest) . ')';
43
+	}
44 44
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginCountCharacters.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -31,19 +31,19 @@
 block discarded – undo
31 31
  */
32 32
 class PluginCountCharacters extends Plugin implements ICompilable
33 33
 {
34
-    /**
35
-     * @param Compiler $compiler
36
-     * @param string   $value
37
-     * @param bool     $count_spaces
38
-     *
39
-     * @return string
40
-     */
41
-    public static function compile(Compiler $compiler, $value, $count_spaces = false)
42
-    {
43
-        if ($count_spaces === 'false') {
44
-            return 'preg_match_all(\'#[^\s\pZ]#u\', ' . $value . ', $tmp)';
45
-        }
34
+	/**
35
+	 * @param Compiler $compiler
36
+	 * @param string   $value
37
+	 * @param bool     $count_spaces
38
+	 *
39
+	 * @return string
40
+	 */
41
+	public static function compile(Compiler $compiler, $value, $count_spaces = false)
42
+	{
43
+		if ($count_spaces === 'false') {
44
+			return 'preg_match_all(\'#[^\s\pZ]#u\', ' . $value . ', $tmp)';
45
+		}
46 46
 
47
-        return 'mb_strlen(' . $value . ', $this->charset)';
48
-    }
47
+		return 'mb_strlen(' . $value . ', $this->charset)';
48
+	}
49 49
 }
50 50
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginNl2br.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@
 block discarded – undo
30 30
  */
31 31
 class PluginNl2br extends Plugin implements ICompilable
32 32
 {
33
-    /**
34
-     * @param Compiler $compiler
35
-     * @param string   $value
36
-     *
37
-     * @return string
38
-     */
39
-    public static function compile(Compiler $compiler, $value)
40
-    {
41
-        return 'nl2br((string) ' . $value . ')';
42
-    }
33
+	/**
34
+	 * @param Compiler $compiler
35
+	 * @param string   $value
36
+	 *
37
+	 * @return string
38
+	 */
39
+	public static function compile(Compiler $compiler, $value)
40
+	{
41
+		return 'nl2br((string) ' . $value . ')';
42
+	}
43 43
 }
44 44
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginMath.php 1 patch
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -41,159 +41,159 @@
 block discarded – undo
41 41
  */
42 42
 class PluginMath extends Plugin implements ICompilable
43 43
 {
44
-    /**
45
-     * @param Compiler $compiler
46
-     * @param string   $equation
47
-     * @param string   $format
48
-     * @param string   $assign
49
-     * @param array    $rest
50
-     *
51
-     * @return string
52
-     * @throws CompilationException
53
-     */
54
-    public static function compile(Compiler $compiler, $equation, $format = '', $assign = '', array $rest = array())
55
-    {
56
-        /*
44
+	/**
45
+	 * @param Compiler $compiler
46
+	 * @param string   $equation
47
+	 * @param string   $format
48
+	 * @param string   $assign
49
+	 * @param array    $rest
50
+	 *
51
+	 * @return string
52
+	 * @throws CompilationException
53
+	 */
54
+	public static function compile(Compiler $compiler, $equation, $format = '', $assign = '', array $rest = array())
55
+	{
56
+		/*
57 57
          * Holds the allowed function, characters, operators and constants
58 58
          */
59
-        $allowed = array(
60
-            '0',
61
-            '1',
62
-            '2',
63
-            '3',
64
-            '4',
65
-            '5',
66
-            '6',
67
-            '7',
68
-            '8',
69
-            '9',
70
-            '+',
71
-            '-',
72
-            '/',
73
-            '*',
74
-            '.',
75
-            ' ',
76
-            '<<',
77
-            '>>',
78
-            '%',
79
-            '&',
80
-            '^',
81
-            '|',
82
-            '~',
83
-            'abs(',
84
-            'ceil(',
85
-            'floor(',
86
-            'exp(',
87
-            'log10(',
88
-            'cos(',
89
-            'sin(',
90
-            'sqrt(',
91
-            'tan(',
92
-            'M_PI',
93
-            'INF',
94
-            'M_E',
95
-        );
59
+		$allowed = array(
60
+			'0',
61
+			'1',
62
+			'2',
63
+			'3',
64
+			'4',
65
+			'5',
66
+			'6',
67
+			'7',
68
+			'8',
69
+			'9',
70
+			'+',
71
+			'-',
72
+			'/',
73
+			'*',
74
+			'.',
75
+			' ',
76
+			'<<',
77
+			'>>',
78
+			'%',
79
+			'&',
80
+			'^',
81
+			'|',
82
+			'~',
83
+			'abs(',
84
+			'ceil(',
85
+			'floor(',
86
+			'exp(',
87
+			'log10(',
88
+			'cos(',
89
+			'sin(',
90
+			'sqrt(',
91
+			'tan(',
92
+			'M_PI',
93
+			'INF',
94
+			'M_E',
95
+		);
96 96
 
97
-        /*
97
+		/*
98 98
          * Holds the functions that can accept multiple arguments
99 99
          */
100
-        $funcs = array(
101
-            'round(',
102
-            'log(',
103
-            'pow(',
104
-            'max(',
105
-            'min(',
106
-            'rand(',
107
-        );
100
+		$funcs = array(
101
+			'round(',
102
+			'log(',
103
+			'pow(',
104
+			'max(',
105
+			'min(',
106
+			'rand(',
107
+		);
108 108
 
109
-        $equation = $equationSrc = str_ireplace(array(
110
-            'pi',
111
-            'M_PI()',
112
-            'inf',
113
-            ' e '
114
-        ),
115
-            array(
116
-                'M_PI',
117
-                'M_PI',
118
-                'INF',
119
-                ' M_E '
120
-            ),
121
-            $equation);
109
+		$equation = $equationSrc = str_ireplace(array(
110
+			'pi',
111
+			'M_PI()',
112
+			'inf',
113
+			' e '
114
+		),
115
+			array(
116
+				'M_PI',
117
+				'M_PI',
118
+				'INF',
119
+				' M_E '
120
+			),
121
+			$equation);
122 122
 
123
-        $delim      = $equation[0];
124
-        $open       = $delim . '.';
125
-        $close      = '.' . $delim;
126
-        $equation   = substr($equation, 1, - 1);
127
-        $out        = '';
128
-        $ptr        = 1;
129
-        $allowcomma = 0;
130
-        while (strlen($equation) > 0) {
131
-            $substr = substr($equation, 0, $ptr);
132
-            if (array_search($substr, $allowed) !== false) {
133
-                // allowed string
134
-                $out .= $substr;
135
-                $equation = substr($equation, $ptr);
136
-                $ptr      = 0;
137
-            } elseif (array_search($substr, $funcs) !== false) {
138
-                // allowed func
139
-                $out .= $substr;
140
-                $equation = substr($equation, $ptr);
141
-                $ptr      = 0;
142
-                ++ $allowcomma;
143
-                if ($allowcomma === 1) {
144
-                    $allowed[] = ',';
145
-                }
146
-            } elseif (isset($rest[$substr])) {
147
-                // variable
148
-                $out .= $rest[$substr];
149
-                $equation = substr($equation, $ptr);
150
-                $ptr      = 0;
151
-            } elseif ($substr === $open) {
152
-                // pre-replaced variable
153
-                preg_match('#.*\((?:[^()]*?|(?R))\)' . str_replace('.', '\\.', $close) . '#', substr($equation, 2), $m);
154
-                if (empty($m)) {
155
-                    preg_match('#.*?' . str_replace('.', '\\.', $close) . '#', substr($equation, 2), $m);
156
-                }
157
-                $out .= substr($m[0], 0, - 2);
158
-                $equation = substr($equation, strlen($m[0]) + 2);
159
-                $ptr      = 0;
160
-            } elseif ($substr === '(') {
161
-                // opening parenthesis
162
-                if ($allowcomma > 0) {
163
-                    ++ $allowcomma;
164
-                }
123
+		$delim      = $equation[0];
124
+		$open       = $delim . '.';
125
+		$close      = '.' . $delim;
126
+		$equation   = substr($equation, 1, - 1);
127
+		$out        = '';
128
+		$ptr        = 1;
129
+		$allowcomma = 0;
130
+		while (strlen($equation) > 0) {
131
+			$substr = substr($equation, 0, $ptr);
132
+			if (array_search($substr, $allowed) !== false) {
133
+				// allowed string
134
+				$out .= $substr;
135
+				$equation = substr($equation, $ptr);
136
+				$ptr      = 0;
137
+			} elseif (array_search($substr, $funcs) !== false) {
138
+				// allowed func
139
+				$out .= $substr;
140
+				$equation = substr($equation, $ptr);
141
+				$ptr      = 0;
142
+				++ $allowcomma;
143
+				if ($allowcomma === 1) {
144
+					$allowed[] = ',';
145
+				}
146
+			} elseif (isset($rest[$substr])) {
147
+				// variable
148
+				$out .= $rest[$substr];
149
+				$equation = substr($equation, $ptr);
150
+				$ptr      = 0;
151
+			} elseif ($substr === $open) {
152
+				// pre-replaced variable
153
+				preg_match('#.*\((?:[^()]*?|(?R))\)' . str_replace('.', '\\.', $close) . '#', substr($equation, 2), $m);
154
+				if (empty($m)) {
155
+					preg_match('#.*?' . str_replace('.', '\\.', $close) . '#', substr($equation, 2), $m);
156
+				}
157
+				$out .= substr($m[0], 0, - 2);
158
+				$equation = substr($equation, strlen($m[0]) + 2);
159
+				$ptr      = 0;
160
+			} elseif ($substr === '(') {
161
+				// opening parenthesis
162
+				if ($allowcomma > 0) {
163
+					++ $allowcomma;
164
+				}
165 165
 
166
-                $out .= $substr;
167
-                $equation = substr($equation, $ptr);
168
-                $ptr      = 0;
169
-            } elseif ($substr === ')') {
170
-                // closing parenthesis
171
-                if ($allowcomma > 0) {
172
-                    -- $allowcomma;
173
-                    if ($allowcomma === 0) {
174
-                        array_pop($allowed);
175
-                    }
176
-                }
166
+				$out .= $substr;
167
+				$equation = substr($equation, $ptr);
168
+				$ptr      = 0;
169
+			} elseif ($substr === ')') {
170
+				// closing parenthesis
171
+				if ($allowcomma > 0) {
172
+					-- $allowcomma;
173
+					if ($allowcomma === 0) {
174
+						array_pop($allowed);
175
+					}
176
+				}
177 177
 
178
-                $out .= $substr;
179
-                $equation = substr($equation, $ptr);
180
-                $ptr      = 0;
181
-            } elseif ($ptr >= strlen($equation)) {
182
-                // parse error if we've consumed the entire equation without finding anything valid
183
-                throw new CompilationException($compiler,
184
-                    'Math : Syntax error or variable undefined in equation ' . $equationSrc . ' at ' . $substr);
185
-            } else {
186
-                // nothing special, advance
187
-                ++ $ptr;
188
-            }
189
-        }
190
-        if ($format !== '\'\'') {
191
-            $out = 'sprintf(' . $format . ', ' . $out . ')';
192
-        }
193
-        if ($assign !== '\'\'') {
194
-            return '($this->assignInScope(' . $out . ', ' . $assign . '))';
195
-        }
178
+				$out .= $substr;
179
+				$equation = substr($equation, $ptr);
180
+				$ptr      = 0;
181
+			} elseif ($ptr >= strlen($equation)) {
182
+				// parse error if we've consumed the entire equation without finding anything valid
183
+				throw new CompilationException($compiler,
184
+					'Math : Syntax error or variable undefined in equation ' . $equationSrc . ' at ' . $substr);
185
+			} else {
186
+				// nothing special, advance
187
+				++ $ptr;
188
+			}
189
+		}
190
+		if ($format !== '\'\'') {
191
+			$out = 'sprintf(' . $format . ', ' . $out . ')';
192
+		}
193
+		if ($assign !== '\'\'') {
194
+			return '($this->assignInScope(' . $out . ', ' . $assign . '))';
195
+		}
196 196
 
197
-        return '(' . $out . ')';
198
-    }
197
+		return '(' . $out . ')';
198
+	}
199 199
 }
200 200
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Helpers/PluginArray.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -35,22 +35,22 @@
 block discarded – undo
35 35
  */
36 36
 class PluginArray extends Plugin implements ICompilable
37 37
 {
38
-    /**
39
-     * @param Compiler $compiler
40
-     * @param array    $rest
41
-     *
42
-     * @return string
43
-     */
44
-    public static function compile(Compiler $compiler, array $rest = array())
45
-    {
46
-        $out = array();
47
-        foreach ($rest as $key => $value) {
48
-            if (!is_numeric($key) && !strstr($key, '$this->scope')) {
49
-                $key = "'" . $key . "'";
50
-            }
51
-            $out[] = $key . '=>' . $value;
52
-        }
38
+	/**
39
+	 * @param Compiler $compiler
40
+	 * @param array    $rest
41
+	 *
42
+	 * @return string
43
+	 */
44
+	public static function compile(Compiler $compiler, array $rest = array())
45
+	{
46
+		$out = array();
47
+		foreach ($rest as $key => $value) {
48
+			if (!is_numeric($key) && !strstr($key, '$this->scope')) {
49
+				$key = "'" . $key . "'";
50
+			}
51
+			$out[] = $key . '=>' . $value;
52
+		}
53 53
 
54
-        return 'array(' . implode(', ', $out) . ')';
55
-    }
54
+		return 'array(' . implode(', ', $out) . ')';
55
+	}
56 56
 }
57 57
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Dwoo/Data.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -24,241 +24,241 @@
 block discarded – undo
24 24
  */
25 25
 class Data implements IDataProvider
26 26
 {
27
-    /**
28
-     * Data array.
29
-     *
30
-     * @var array
31
-     */
32
-    protected $data = array();
27
+	/**
28
+	 * Data array.
29
+	 *
30
+	 * @var array
31
+	 */
32
+	protected $data = array();
33 33
 
34
-    /**
35
-     * Returns the data array.
36
-     *
37
-     * @return array
38
-     */
39
-    public function getData()
40
-    {
41
-        return $this->data;
42
-    }
34
+	/**
35
+	 * Returns the data array.
36
+	 *
37
+	 * @return array
38
+	 */
39
+	public function getData()
40
+	{
41
+		return $this->data;
42
+	}
43 43
 
44
-    /**
45
-     * Clears a the entire data or only the given key.
46
-     *
47
-     * @param array|string $name clears only one value if you give a name, multiple values if
48
-     *                           you give an array of names, or the entire data if left null
49
-     */
50
-    public function clear($name = null)
51
-    {
52
-        if ($name === null) {
53
-            $this->data = array();
54
-        } elseif (is_array($name)) {
55
-            foreach ($name as $index) {
56
-                unset($this->data[$index]);
57
-            }
58
-        } else {
59
-            unset($this->data[$name]);
60
-        }
61
-    }
44
+	/**
45
+	 * Clears a the entire data or only the given key.
46
+	 *
47
+	 * @param array|string $name clears only one value if you give a name, multiple values if
48
+	 *                           you give an array of names, or the entire data if left null
49
+	 */
50
+	public function clear($name = null)
51
+	{
52
+		if ($name === null) {
53
+			$this->data = array();
54
+		} elseif (is_array($name)) {
55
+			foreach ($name as $index) {
56
+				unset($this->data[$index]);
57
+			}
58
+		} else {
59
+			unset($this->data[$name]);
60
+		}
61
+	}
62 62
 
63
-    /**
64
-     * Overwrites the entire data with the given array.
65
-     *
66
-     * @param array $data the new data array to use
67
-     */
68
-    public function setData(array $data)
69
-    {
70
-        $this->data = $data;
71
-    }
63
+	/**
64
+	 * Overwrites the entire data with the given array.
65
+	 *
66
+	 * @param array $data the new data array to use
67
+	 */
68
+	public function setData(array $data)
69
+	{
70
+		$this->data = $data;
71
+	}
72 72
 
73
-    /**
74
-     * merges the given array(s) with the current data with array_merge.
75
-     *
76
-     * @param array $data  the array to merge
77
-     */
78
-    public function mergeData(array $data)
79
-    {
80
-        $args = func_get_args();
81
-        foreach ($args as $key => $v) {
82
-            if (is_array($v)) {
83
-                $this->data = array_merge($this->data, $v);
84
-            }
85
-        }
86
-    }
73
+	/**
74
+	 * merges the given array(s) with the current data with array_merge.
75
+	 *
76
+	 * @param array $data  the array to merge
77
+	 */
78
+	public function mergeData(array $data)
79
+	{
80
+		$args = func_get_args();
81
+		foreach ($args as $key => $v) {
82
+			if (is_array($v)) {
83
+				$this->data = array_merge($this->data, $v);
84
+			}
85
+		}
86
+	}
87 87
 
88
-    /**
89
-     * Assigns a value or an array of values to the data object.
90
-     *
91
-     * @param array|string $name an associative array of multiple (index=>value) or a string
92
-     *                           that is the index to use, i.e. a value assigned to "foo" will be
93
-     *                           accessible in the template through {$foo}
94
-     * @param mixed        $val  the value to assign, or null if $name was an array
95
-     */
96
-    public function assign($name, $val = null)
97
-    {
98
-        if (is_array($name)) {
99
-            reset($name);
100
-            foreach ($name as $k => $v){
101
-                $this->data[$k] = $v;
102
-            }
103
-        } else {
104
-            $this->data[$name] = $val;
105
-        }
106
-    }
88
+	/**
89
+	 * Assigns a value or an array of values to the data object.
90
+	 *
91
+	 * @param array|string $name an associative array of multiple (index=>value) or a string
92
+	 *                           that is the index to use, i.e. a value assigned to "foo" will be
93
+	 *                           accessible in the template through {$foo}
94
+	 * @param mixed        $val  the value to assign, or null if $name was an array
95
+	 */
96
+	public function assign($name, $val = null)
97
+	{
98
+		if (is_array($name)) {
99
+			reset($name);
100
+			foreach ($name as $k => $v){
101
+				$this->data[$k] = $v;
102
+			}
103
+		} else {
104
+			$this->data[$name] = $val;
105
+		}
106
+	}
107 107
 
108
-    /**
109
-     * Allows to assign variables using the object syntax.
110
-     *
111
-     * @param string $name  the variable name
112
-     * @param string $value the value to assign to it
113
-     */
114
-    public function __set($name, $value)
115
-    {
116
-        $this->assign($name, $value);
117
-    }
108
+	/**
109
+	 * Allows to assign variables using the object syntax.
110
+	 *
111
+	 * @param string $name  the variable name
112
+	 * @param string $value the value to assign to it
113
+	 */
114
+	public function __set($name, $value)
115
+	{
116
+		$this->assign($name, $value);
117
+	}
118 118
 
119
-    /**
120
-     * Assigns a value by reference to the data object.
121
-     *
122
-     * @param string $name the index to use, i.e. a value assigned to "foo" will be
123
-     *                     accessible in the template through {$foo}
124
-     * @param mixed  $val  the value to assign by reference
125
-     */
126
-    public function assignByRef($name, &$val)
127
-    {
128
-        $this->data[$name] = &$val;
129
-    }
119
+	/**
120
+	 * Assigns a value by reference to the data object.
121
+	 *
122
+	 * @param string $name the index to use, i.e. a value assigned to "foo" will be
123
+	 *                     accessible in the template through {$foo}
124
+	 * @param mixed  $val  the value to assign by reference
125
+	 */
126
+	public function assignByRef($name, &$val)
127
+	{
128
+		$this->data[$name] = &$val;
129
+	}
130 130
 
131
-    /**
132
-     * Appends values or an array of values to the data object.
133
-     *
134
-     * @param array|string $name  an associative array of multiple (index=>value) or a string
135
-     *                            that is the index to use, i.e. a value assigned to "foo" will be
136
-     *                            accessible in the template through {$foo}
137
-     * @param mixed        $val   the value to assign, or null if $name was an array
138
-     * @param bool         $merge true to merge data or false to append, defaults to false
139
-     */
140
-    public function append($name, $val = null, $merge = false)
141
-    {
142
-        if (is_array($name)) {
143
-            foreach ($name as $key => $val) {
144
-                if (isset($this->data[$key]) && !is_array($this->data[$key])) {
145
-                    settype($this->data[$key], 'array');
146
-                }
131
+	/**
132
+	 * Appends values or an array of values to the data object.
133
+	 *
134
+	 * @param array|string $name  an associative array of multiple (index=>value) or a string
135
+	 *                            that is the index to use, i.e. a value assigned to "foo" will be
136
+	 *                            accessible in the template through {$foo}
137
+	 * @param mixed        $val   the value to assign, or null if $name was an array
138
+	 * @param bool         $merge true to merge data or false to append, defaults to false
139
+	 */
140
+	public function append($name, $val = null, $merge = false)
141
+	{
142
+		if (is_array($name)) {
143
+			foreach ($name as $key => $val) {
144
+				if (isset($this->data[$key]) && !is_array($this->data[$key])) {
145
+					settype($this->data[$key], 'array');
146
+				}
147 147
 
148
-                if ($merge === true && is_array($val)) {
149
-                    $this->data[$key] = $val + $this->data[$key];
150
-                } else {
151
-                    $this->data[$key][] = $val;
152
-                }
153
-            }
154
-        } elseif ($val !== null) {
155
-            if (isset($this->data[$name]) && !is_array($this->data[$name])) {
156
-                settype($this->data[$name], 'array');
157
-            } elseif (!isset($this->data[$name])) {
158
-                $this->data[$name] = array();
159
-            }
148
+				if ($merge === true && is_array($val)) {
149
+					$this->data[$key] = $val + $this->data[$key];
150
+				} else {
151
+					$this->data[$key][] = $val;
152
+				}
153
+			}
154
+		} elseif ($val !== null) {
155
+			if (isset($this->data[$name]) && !is_array($this->data[$name])) {
156
+				settype($this->data[$name], 'array');
157
+			} elseif (!isset($this->data[$name])) {
158
+				$this->data[$name] = array();
159
+			}
160 160
 
161
-            if ($merge === true && is_array($val)) {
162
-                $this->data[$name] = $val + $this->data[$name];
163
-            } else {
164
-                $this->data[$name][] = $val;
165
-            }
166
-        }
167
-    }
161
+			if ($merge === true && is_array($val)) {
162
+				$this->data[$name] = $val + $this->data[$name];
163
+			} else {
164
+				$this->data[$name][] = $val;
165
+			}
166
+		}
167
+	}
168 168
 
169
-    /**
170
-     * Appends a value by reference to the data object.
171
-     *
172
-     * @param string $name  the index to use, i.e. a value assigned to "foo" will be
173
-     *                      accessible in the template through {$foo}
174
-     * @param mixed  $val   the value to append by reference
175
-     * @param bool   $merge true to merge data or false to append, defaults to false
176
-     */
177
-    public function appendByRef($name, &$val, $merge = false)
178
-    {
179
-        if (isset($this->data[$name]) && !is_array($this->data[$name])) {
180
-            settype($this->data[$name], 'array');
181
-        }
169
+	/**
170
+	 * Appends a value by reference to the data object.
171
+	 *
172
+	 * @param string $name  the index to use, i.e. a value assigned to "foo" will be
173
+	 *                      accessible in the template through {$foo}
174
+	 * @param mixed  $val   the value to append by reference
175
+	 * @param bool   $merge true to merge data or false to append, defaults to false
176
+	 */
177
+	public function appendByRef($name, &$val, $merge = false)
178
+	{
179
+		if (isset($this->data[$name]) && !is_array($this->data[$name])) {
180
+			settype($this->data[$name], 'array');
181
+		}
182 182
 
183
-        if ($merge === true && is_array($val)) {
184
-            foreach ($val as $key => &$value) {
185
-                $this->data[$name][$key] = &$value;
186
-            }
187
-        } else {
188
-            $this->data[$name][] = &$val;
189
-        }
190
-    }
183
+		if ($merge === true && is_array($val)) {
184
+			foreach ($val as $key => &$value) {
185
+				$this->data[$name][$key] = &$value;
186
+			}
187
+		} else {
188
+			$this->data[$name][] = &$val;
189
+		}
190
+	}
191 191
 
192
-    /**
193
-     * Returns true if the variable has been assigned already, false otherwise.
194
-     *
195
-     * @param string $name the variable name
196
-     *
197
-     * @return bool
198
-     */
199
-    public function isAssigned($name)
200
-    {
201
-        return isset($this->data[$name]);
202
-    }
192
+	/**
193
+	 * Returns true if the variable has been assigned already, false otherwise.
194
+	 *
195
+	 * @param string $name the variable name
196
+	 *
197
+	 * @return bool
198
+	 */
199
+	public function isAssigned($name)
200
+	{
201
+		return isset($this->data[$name]);
202
+	}
203 203
 
204
-    /**
205
-     * Supports calls to isset($dwoo->var).
206
-     *
207
-     * @param string $name the variable name
208
-     *
209
-     * @return bool
210
-     */
211
-    public function __isset($name)
212
-    {
213
-        return isset($this->data[$name]);
214
-    }
204
+	/**
205
+	 * Supports calls to isset($dwoo->var).
206
+	 *
207
+	 * @param string $name the variable name
208
+	 *
209
+	 * @return bool
210
+	 */
211
+	public function __isset($name)
212
+	{
213
+		return isset($this->data[$name]);
214
+	}
215 215
 
216
-    /**
217
-     * Unassigns/removes a variable.
218
-     *
219
-     * @param string $name the variable name
220
-     */
221
-    public function unassign($name)
222
-    {
223
-        unset($this->data[$name]);
224
-    }
216
+	/**
217
+	 * Unassigns/removes a variable.
218
+	 *
219
+	 * @param string $name the variable name
220
+	 */
221
+	public function unassign($name)
222
+	{
223
+		unset($this->data[$name]);
224
+	}
225 225
 
226
-    /**
227
-     * Supports unsetting variables using the object syntax.
228
-     *
229
-     * @param string $name the variable name
230
-     */
231
-    public function __unset($name)
232
-    {
233
-        unset($this->data[$name]);
234
-    }
226
+	/**
227
+	 * Supports unsetting variables using the object syntax.
228
+	 *
229
+	 * @param string $name the variable name
230
+	 */
231
+	public function __unset($name)
232
+	{
233
+		unset($this->data[$name]);
234
+	}
235 235
 
236
-    /**
237
-     * Returns a variable if it was assigned.
238
-     *
239
-     * @param string $name the variable name
240
-     *
241
-     * @return mixed
242
-     */
243
-    public function get($name)
244
-    {
245
-        return $this->__get($name);
246
-    }
236
+	/**
237
+	 * Returns a variable if it was assigned.
238
+	 *
239
+	 * @param string $name the variable name
240
+	 *
241
+	 * @return mixed
242
+	 */
243
+	public function get($name)
244
+	{
245
+		return $this->__get($name);
246
+	}
247 247
 
248
-    /**
249
-     * Allows to read variables using the object syntax.
250
-     *
251
-     * @param string $name the variable name
252
-     *
253
-     * @return mixed
254
-     * @throws Exception
255
-     */
256
-    public function __get($name)
257
-    {
258
-        if (isset($this->data[$name])) {
259
-            return $this->data[$name];
260
-        } else {
261
-            throw new Exception('Tried to read a value that was not assigned yet : "' . $name . '"');
262
-        }
263
-    }
248
+	/**
249
+	 * Allows to read variables using the object syntax.
250
+	 *
251
+	 * @param string $name the variable name
252
+	 *
253
+	 * @return mixed
254
+	 * @throws Exception
255
+	 */
256
+	public function __get($name)
257
+	{
258
+		if (isset($this->data[$name])) {
259
+			return $this->data[$name];
260
+		} else {
261
+			throw new Exception('Tried to read a value that was not assigned yet : "' . $name . '"');
262
+		}
263
+	}
264 264
 }
Please login to merge, or discard this patch.