Completed
Push — master ( 9ad54b...895d73 )
by Federico
03:21
created
jate/modules/ExternalModules/pug-php/pug/src/Jade/Compiler/MixinVisitor.php 3 patches
Doc Comments   +15 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,6 +15,9 @@  discard block
 block discarded – undo
15 15
         }
16 16
     }
17 17
 
18
+    /**
19
+     * @param boolean $containsOnlyArrays
20
+     */
18 21
     protected function parseMixinArguments(&$arguments, &$containsOnlyArrays, &$defaultAttributes)
19 22
     {
20 23
         $newArrayKey = null;
@@ -72,6 +75,9 @@  discard block
 block discarded – undo
72 75
         return $this->parseMixinStringAttribute($data);
73 76
     }
74 77
 
78
+    /**
79
+     * @param string $defaultAttributes
80
+     */
75 81
     protected function parseMixinAttributes($attributes, $defaultAttributes, $mixinAttributes)
76 82
     {
77 83
         if (!count($attributes)) {
@@ -112,6 +118,9 @@  discard block
 block discarded – undo
112 118
         );
113 119
     }
114 120
 
121
+    /**
122
+     * @param string $code
123
+     */
115 124
     protected function renderClosureClosing($code, $arguments = array())
116 125
     {
117 126
         if (!$this->restrictedScope) {
@@ -139,7 +148,9 @@  discard block
 block discarded – undo
139 148
     }
140 149
 
141 150
     /**
142
-     * @param Nodes\Mixin $mixin
151
+     * @param Mixin $mixin
152
+     * @param string $name
153
+     * @param string $blockName
143 154
      */
144 155
     protected function visitMixinCall(Mixin $mixin, $name, $blockName, $attributes)
145 156
     {
@@ -234,7 +245,8 @@  discard block
 block discarded – undo
234 245
     }
235 246
 
236 247
     /**
237
-     * @param Nodes\Mixin $mixin
248
+     * @param Mixin $mixin
249
+     * @param string $name
238 250
      */
239 251
     protected function visitMixinDeclaration(Mixin $mixin, $name)
240 252
     {
@@ -264,7 +276,7 @@  discard block
 block discarded – undo
264 276
     }
265 277
 
266 278
     /**
267
-     * @param Nodes\Mixin $mixin
279
+     * @param Mixin $mixin
268 280
      */
269 281
     protected function visitMixin(Mixin $mixin)
270 282
     {
Please login to merge, or discard this patch.
Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -6,281 +6,281 @@
 block discarded – undo
6 6
 
7 7
 abstract class MixinVisitor extends CodeVisitor
8 8
 {
9
-    protected function getMixinArgumentAssign($argument)
10
-    {
11
-        $argument = trim($argument);
12
-
13
-        if (preg_match('`^[a-zA-Z][a-zA-Z0-9:_-]*\s*=`', $argument)) {
14
-            return explode('=', $argument, 2);
15
-        }
16
-    }
17
-
18
-    protected function parseMixinArguments(&$arguments, &$containsOnlyArrays, &$defaultAttributes)
19
-    {
20
-        $newArrayKey = null;
21
-        $arguments = is_null($arguments) ? array() : explode(',', $arguments);
22
-        foreach ($arguments as $key => &$argument) {
23
-            if ($tab = $this->getMixinArgumentAssign($argument)) {
24
-                if (is_null($newArrayKey)) {
25
-                    $newArrayKey = $key;
26
-                    $argument = array();
27
-                } else {
28
-                    unset($arguments[$key]);
29
-                }
30
-
31
-                $defaultAttributes[] = var_export($tab[0], true) . ' => ' . $tab[1];
32
-                $arguments[$newArrayKey][$tab[0]] = static::decodeValue($tab[1]);
33
-                continue;
34
-            }
35
-
36
-            $containsOnlyArrays = false;
37
-            $newArrayKey = null;
38
-        }
39
-
40
-        return array_map(function ($argument) {
41
-            if (is_array($argument)) {
42
-                $argument = var_export($argument, true);
43
-            }
44
-
45
-            return $argument;
46
-        }, $arguments);
47
-    }
48
-
49
-    protected function parseMixinStringAttribute($data)
50
-    {
51
-        $value = is_array($data['value'])
52
-            ? preg_split('`\s+`', trim(implode(' ', $data['value'])))
53
-            : trim($data['value']);
54
-
55
-        return $data['escaped'] === true
56
-            ? is_array($value)
57
-                ? array_map('htmlspecialchars', $value)
58
-                : htmlspecialchars($value)
59
-            : $value;
60
-    }
61
-
62
-    protected function parseMixinAttribute($data)
63
-    {
64
-        if ($data['value'] === 'null' || $data['value'] === 'undefined' || is_null($data['value'])) {
65
-            return;
66
-        }
67
-
68
-        if (is_bool($data['value'])) {
69
-            return $data['value'];
70
-        }
71
-
72
-        return $this->parseMixinStringAttribute($data);
73
-    }
74
-
75
-    protected function parseMixinAttributes($attributes, $defaultAttributes, $mixinAttributes)
76
-    {
77
-        if (!count($attributes)) {
78
-            return "(isset(\$attributes)) ? \$attributes : array($defaultAttributes)";
79
-        }
80
-
81
-        $parsedAttributes = array();
82
-        foreach ($attributes as $data) {
83
-            $parsedAttributes[$data['name']] = $this->parseMixinAttribute($data);
84
-        }
85
-
86
-        $attributes = var_export($parsedAttributes, true);
87
-        $mixinAttributes = var_export(static::decodeAttributes($mixinAttributes), true);
88
-
89
-        return "array_merge(\\Jade\\Compiler::withMixinAttributes($attributes, $mixinAttributes), (isset(\$attributes)) ? \$attributes : array($defaultAttributes))";
90
-    }
91
-
92
-    protected function renderClosureOpenning()
93
-    {
94
-        $arguments = func_get_args();
95
-        $begin = array_shift($arguments);
96
-        $begin = is_array($begin)
97
-            ? $begin[0] . 'function ' . $begin[1]
98
-            : $begin . 'function ';
99
-        $params = implode(', ', array_map(function ($name) {
100
-            return (substr($name, 0, 1) === '$' ? '' : '$') . $name;
101
-        }, $arguments));
102
-
103
-        if ($this->restrictedScope) {
104
-            return $this->buffer($this->createCode($begin . '(' . $params . ') {'));
105
-        }
106
-
107
-        $params = '&$__varHandler, ' . $params;
108
-
109
-        $this->buffer(
110
-            $this->createCode($begin . '(' . $params . ') {') .
111
-            $this->createCode($this->indent() . 'extract($__varHandler, EXTR_SKIP);')
112
-        );
113
-    }
114
-
115
-    protected function renderClosureClosing($code, $arguments = array())
116
-    {
117
-        if (!$this->restrictedScope) {
118
-            $arguments = array_filter(array_map(function ($argument) {
119
-                $argument = explode('=', $argument);
120
-                $argument = trim($argument[0]);
121
-
122
-                return substr($argument, 0, 1) === '$'
123
-                    ? substr($argument, 1)
124
-                    : false;
125
-            }, array_slice($arguments, 1)));
126
-            $exception = count($arguments)
127
-                ? ' && !in_array($key, ' . var_export($arguments, true) . ')'
128
-                : '';
129
-            $this->buffer($this->createCode(
130
-                'foreach ($__varHandler as $key => &$val) {' .
131
-                'if ($key !== \'__varHandler\'' . $exception . ') {' .
132
-                '$val = ${$key};' .
133
-                '}' .
134
-                '}'
135
-            ));
136
-        }
137
-
138
-        $this->buffer($this->createCode($code));
139
-    }
140
-
141
-    /**
142
-     * @param Nodes\Mixin $mixin
143
-     */
144
-    protected function visitMixinCall(Mixin $mixin, $name, $blockName, $attributes)
145
-    {
146
-        $arguments = $mixin->arguments;
147
-        $block = $mixin->block;
148
-        $defaultAttributes = array();
149
-        $containsOnlyArrays = true;
150
-        $arguments = $this->parseMixinArguments($mixin->arguments, $containsOnlyArrays, $defaultAttributes);
151
-
152
-        $defaultAttributes = implode(', ', $defaultAttributes);
153
-        $attributes = $this->parseMixinAttributes($attributes, $defaultAttributes, $mixin->attributes);
154
-
155
-        if ($block) {
156
-            $this->renderClosureOpenning("\\Jade\\Compiler::recordMixinBlock($blockName, ", 'attributes');
157
-            $this->visit($block);
158
-            $this->renderClosureClosing('});');
159
-        }
160
-
161
-        $strings = array();
162
-        $arguments = preg_replace_callback(
163
-            '#([\'"])(.*(?!<\\\\)(?:\\\\{2})*)\\1#U',
164
-            function ($match) use (&$strings) {
165
-                $nextIndex = count($strings);
166
-                $strings[] = $match[0];
167
-
168
-                return 'stringToReplaceBy' . $nextIndex . 'ThCapture';
169
-            },
170
-            $arguments
171
-        );
172
-        $arguments = array_map(
173
-            function ($arg) use ($strings) {
174
-                return preg_replace_callback(
175
-                    '#stringToReplaceBy([0-9]+)ThCapture#',
176
-                    function ($match) use ($strings) {
177
-                        return $strings[intval($match[1])];
178
-                    },
179
-                    $arg
180
-                );
181
-            },
182
-            $arguments
183
-        );
184
-
185
-        array_unshift($arguments, $attributes);
186
-        $arguments = array_filter($arguments, 'strlen');
187
-        $statements = $this->apply('createStatements', $arguments);
188
-
189
-        $variables = array_pop($statements);
190
-        if ($mixin->call && $containsOnlyArrays) {
191
-            array_splice($variables, 1, 0, array('null'));
192
-        }
193
-        $variables = implode(', ', $variables);
194
-        array_push($statements, $variables);
195
-
196
-        $arguments = $statements;
197
-
198
-        $paramsPrefix = '';
199
-        if (!$this->restrictedScope) {
200
-            $this->buffer($this->createCode('$__varHandler = get_defined_vars();'));
201
-            $paramsPrefix = '$__varHandler, ';
202
-        }
203
-        $codeFormat = str_repeat('%s;', count($arguments) - 1) . "{$name}({$paramsPrefix}%s)";
204
-
205
-        array_unshift($arguments, $codeFormat);
206
-
207
-        $this->buffer($this->apply('createCode', $arguments));
208
-        if (!$this->restrictedScope) {
209
-            $this->buffer(
210
-                $this->createCode(
211
-                    'extract(array_diff_key($__varHandler, array(\'__varHandler\' => 1, \'attributes\' => 1)));'
212
-                )
213
-            );
214
-        }
215
-
216
-        if ($block) {
217
-            $code = $this->createCode("\\Jade\\Compiler::terminateMixinBlock($blockName);");
218
-            $this->buffer($code);
219
-        }
220
-    }
221
-
222
-    protected function visitMixinCodeAndBlock($name, $block, $arguments)
223
-    {
224
-        $this->renderClosureOpenning(
225
-            $this->allowMixinOverride
226
-                ? "{$name} = "
227
-                : array("if(!function_exists('{$name}')) { ", $name),
228
-            implode(',', $arguments)
229
-        );
230
-        $this->indents++;
231
-        $this->visit($block);
232
-        $this->indents--;
233
-        $this->renderClosureClosing($this->allowMixinOverride ? '};' : '} }', $arguments);
234
-    }
235
-
236
-    /**
237
-     * @param Nodes\Mixin $mixin
238
-     */
239
-    protected function visitMixinDeclaration(Mixin $mixin, $name)
240
-    {
241
-        $arguments = $mixin->arguments;
242
-        $block = $mixin->block;
243
-        $previousVisitedMixin = isset($this->visitedMixin) ? $this->visitedMixin : null;
244
-        $this->visitedMixin = $mixin;
245
-        if ($arguments === null || empty($arguments)) {
246
-            $arguments = array();
247
-        } elseif (!is_array($arguments)) {
248
-            $arguments = array($arguments);
249
-        }
250
-
251
-        array_unshift($arguments, 'attributes');
252
-        $arguments = implode(',', $arguments);
253
-        $arguments = explode(',', $arguments);
254
-        array_walk($arguments, array(get_class(), 'initArgToNull'));
255
-        $this->visitMixinCodeAndBlock($name, $block, $arguments);
256
-
257
-        if (is_null($previousVisitedMixin)) {
258
-            unset($this->visitedMixin);
259
-
260
-            return;
261
-        }
262
-
263
-        $this->visitedMixin = $previousVisitedMixin;
264
-    }
265
-
266
-    /**
267
-     * @param Nodes\Mixin $mixin
268
-     */
269
-    protected function visitMixin(Mixin $mixin)
270
-    {
271
-        $name = strtr($mixin->name, '-', '_') . '_mixin';
272
-        $blockName = var_export($mixin->name, true);
273
-        if ($this->allowMixinOverride) {
274
-            $name = '$GLOBALS[\'' . $name . '\']';
275
-        }
276
-        $attributes = static::decodeAttributes($mixin->attributes);
277
-
278
-        if ($mixin->call) {
279
-            $this->visitMixinCall($mixin, $name, $blockName, $attributes);
280
-
281
-            return;
282
-        }
283
-
284
-        $this->visitMixinDeclaration($mixin, $name);
285
-    }
9
+	protected function getMixinArgumentAssign($argument)
10
+	{
11
+		$argument = trim($argument);
12
+
13
+		if (preg_match('`^[a-zA-Z][a-zA-Z0-9:_-]*\s*=`', $argument)) {
14
+			return explode('=', $argument, 2);
15
+		}
16
+	}
17
+
18
+	protected function parseMixinArguments(&$arguments, &$containsOnlyArrays, &$defaultAttributes)
19
+	{
20
+		$newArrayKey = null;
21
+		$arguments = is_null($arguments) ? array() : explode(',', $arguments);
22
+		foreach ($arguments as $key => &$argument) {
23
+			if ($tab = $this->getMixinArgumentAssign($argument)) {
24
+				if (is_null($newArrayKey)) {
25
+					$newArrayKey = $key;
26
+					$argument = array();
27
+				} else {
28
+					unset($arguments[$key]);
29
+				}
30
+
31
+				$defaultAttributes[] = var_export($tab[0], true) . ' => ' . $tab[1];
32
+				$arguments[$newArrayKey][$tab[0]] = static::decodeValue($tab[1]);
33
+				continue;
34
+			}
35
+
36
+			$containsOnlyArrays = false;
37
+			$newArrayKey = null;
38
+		}
39
+
40
+		return array_map(function ($argument) {
41
+			if (is_array($argument)) {
42
+				$argument = var_export($argument, true);
43
+			}
44
+
45
+			return $argument;
46
+		}, $arguments);
47
+	}
48
+
49
+	protected function parseMixinStringAttribute($data)
50
+	{
51
+		$value = is_array($data['value'])
52
+			? preg_split('`\s+`', trim(implode(' ', $data['value'])))
53
+			: trim($data['value']);
54
+
55
+		return $data['escaped'] === true
56
+			? is_array($value)
57
+				? array_map('htmlspecialchars', $value)
58
+				: htmlspecialchars($value)
59
+			: $value;
60
+	}
61
+
62
+	protected function parseMixinAttribute($data)
63
+	{
64
+		if ($data['value'] === 'null' || $data['value'] === 'undefined' || is_null($data['value'])) {
65
+			return;
66
+		}
67
+
68
+		if (is_bool($data['value'])) {
69
+			return $data['value'];
70
+		}
71
+
72
+		return $this->parseMixinStringAttribute($data);
73
+	}
74
+
75
+	protected function parseMixinAttributes($attributes, $defaultAttributes, $mixinAttributes)
76
+	{
77
+		if (!count($attributes)) {
78
+			return "(isset(\$attributes)) ? \$attributes : array($defaultAttributes)";
79
+		}
80
+
81
+		$parsedAttributes = array();
82
+		foreach ($attributes as $data) {
83
+			$parsedAttributes[$data['name']] = $this->parseMixinAttribute($data);
84
+		}
85
+
86
+		$attributes = var_export($parsedAttributes, true);
87
+		$mixinAttributes = var_export(static::decodeAttributes($mixinAttributes), true);
88
+
89
+		return "array_merge(\\Jade\\Compiler::withMixinAttributes($attributes, $mixinAttributes), (isset(\$attributes)) ? \$attributes : array($defaultAttributes))";
90
+	}
91
+
92
+	protected function renderClosureOpenning()
93
+	{
94
+		$arguments = func_get_args();
95
+		$begin = array_shift($arguments);
96
+		$begin = is_array($begin)
97
+			? $begin[0] . 'function ' . $begin[1]
98
+			: $begin . 'function ';
99
+		$params = implode(', ', array_map(function ($name) {
100
+			return (substr($name, 0, 1) === '$' ? '' : '$') . $name;
101
+		}, $arguments));
102
+
103
+		if ($this->restrictedScope) {
104
+			return $this->buffer($this->createCode($begin . '(' . $params . ') {'));
105
+		}
106
+
107
+		$params = '&$__varHandler, ' . $params;
108
+
109
+		$this->buffer(
110
+			$this->createCode($begin . '(' . $params . ') {') .
111
+			$this->createCode($this->indent() . 'extract($__varHandler, EXTR_SKIP);')
112
+		);
113
+	}
114
+
115
+	protected function renderClosureClosing($code, $arguments = array())
116
+	{
117
+		if (!$this->restrictedScope) {
118
+			$arguments = array_filter(array_map(function ($argument) {
119
+				$argument = explode('=', $argument);
120
+				$argument = trim($argument[0]);
121
+
122
+				return substr($argument, 0, 1) === '$'
123
+					? substr($argument, 1)
124
+					: false;
125
+			}, array_slice($arguments, 1)));
126
+			$exception = count($arguments)
127
+				? ' && !in_array($key, ' . var_export($arguments, true) . ')'
128
+				: '';
129
+			$this->buffer($this->createCode(
130
+				'foreach ($__varHandler as $key => &$val) {' .
131
+				'if ($key !== \'__varHandler\'' . $exception . ') {' .
132
+				'$val = ${$key};' .
133
+				'}' .
134
+				'}'
135
+			));
136
+		}
137
+
138
+		$this->buffer($this->createCode($code));
139
+	}
140
+
141
+	/**
142
+	 * @param Nodes\Mixin $mixin
143
+	 */
144
+	protected function visitMixinCall(Mixin $mixin, $name, $blockName, $attributes)
145
+	{
146
+		$arguments = $mixin->arguments;
147
+		$block = $mixin->block;
148
+		$defaultAttributes = array();
149
+		$containsOnlyArrays = true;
150
+		$arguments = $this->parseMixinArguments($mixin->arguments, $containsOnlyArrays, $defaultAttributes);
151
+
152
+		$defaultAttributes = implode(', ', $defaultAttributes);
153
+		$attributes = $this->parseMixinAttributes($attributes, $defaultAttributes, $mixin->attributes);
154
+
155
+		if ($block) {
156
+			$this->renderClosureOpenning("\\Jade\\Compiler::recordMixinBlock($blockName, ", 'attributes');
157
+			$this->visit($block);
158
+			$this->renderClosureClosing('});');
159
+		}
160
+
161
+		$strings = array();
162
+		$arguments = preg_replace_callback(
163
+			'#([\'"])(.*(?!<\\\\)(?:\\\\{2})*)\\1#U',
164
+			function ($match) use (&$strings) {
165
+				$nextIndex = count($strings);
166
+				$strings[] = $match[0];
167
+
168
+				return 'stringToReplaceBy' . $nextIndex . 'ThCapture';
169
+			},
170
+			$arguments
171
+		);
172
+		$arguments = array_map(
173
+			function ($arg) use ($strings) {
174
+				return preg_replace_callback(
175
+					'#stringToReplaceBy([0-9]+)ThCapture#',
176
+					function ($match) use ($strings) {
177
+						return $strings[intval($match[1])];
178
+					},
179
+					$arg
180
+				);
181
+			},
182
+			$arguments
183
+		);
184
+
185
+		array_unshift($arguments, $attributes);
186
+		$arguments = array_filter($arguments, 'strlen');
187
+		$statements = $this->apply('createStatements', $arguments);
188
+
189
+		$variables = array_pop($statements);
190
+		if ($mixin->call && $containsOnlyArrays) {
191
+			array_splice($variables, 1, 0, array('null'));
192
+		}
193
+		$variables = implode(', ', $variables);
194
+		array_push($statements, $variables);
195
+
196
+		$arguments = $statements;
197
+
198
+		$paramsPrefix = '';
199
+		if (!$this->restrictedScope) {
200
+			$this->buffer($this->createCode('$__varHandler = get_defined_vars();'));
201
+			$paramsPrefix = '$__varHandler, ';
202
+		}
203
+		$codeFormat = str_repeat('%s;', count($arguments) - 1) . "{$name}({$paramsPrefix}%s)";
204
+
205
+		array_unshift($arguments, $codeFormat);
206
+
207
+		$this->buffer($this->apply('createCode', $arguments));
208
+		if (!$this->restrictedScope) {
209
+			$this->buffer(
210
+				$this->createCode(
211
+					'extract(array_diff_key($__varHandler, array(\'__varHandler\' => 1, \'attributes\' => 1)));'
212
+				)
213
+			);
214
+		}
215
+
216
+		if ($block) {
217
+			$code = $this->createCode("\\Jade\\Compiler::terminateMixinBlock($blockName);");
218
+			$this->buffer($code);
219
+		}
220
+	}
221
+
222
+	protected function visitMixinCodeAndBlock($name, $block, $arguments)
223
+	{
224
+		$this->renderClosureOpenning(
225
+			$this->allowMixinOverride
226
+				? "{$name} = "
227
+				: array("if(!function_exists('{$name}')) { ", $name),
228
+			implode(',', $arguments)
229
+		);
230
+		$this->indents++;
231
+		$this->visit($block);
232
+		$this->indents--;
233
+		$this->renderClosureClosing($this->allowMixinOverride ? '};' : '} }', $arguments);
234
+	}
235
+
236
+	/**
237
+	 * @param Nodes\Mixin $mixin
238
+	 */
239
+	protected function visitMixinDeclaration(Mixin $mixin, $name)
240
+	{
241
+		$arguments = $mixin->arguments;
242
+		$block = $mixin->block;
243
+		$previousVisitedMixin = isset($this->visitedMixin) ? $this->visitedMixin : null;
244
+		$this->visitedMixin = $mixin;
245
+		if ($arguments === null || empty($arguments)) {
246
+			$arguments = array();
247
+		} elseif (!is_array($arguments)) {
248
+			$arguments = array($arguments);
249
+		}
250
+
251
+		array_unshift($arguments, 'attributes');
252
+		$arguments = implode(',', $arguments);
253
+		$arguments = explode(',', $arguments);
254
+		array_walk($arguments, array(get_class(), 'initArgToNull'));
255
+		$this->visitMixinCodeAndBlock($name, $block, $arguments);
256
+
257
+		if (is_null($previousVisitedMixin)) {
258
+			unset($this->visitedMixin);
259
+
260
+			return;
261
+		}
262
+
263
+		$this->visitedMixin = $previousVisitedMixin;
264
+	}
265
+
266
+	/**
267
+	 * @param Nodes\Mixin $mixin
268
+	 */
269
+	protected function visitMixin(Mixin $mixin)
270
+	{
271
+		$name = strtr($mixin->name, '-', '_') . '_mixin';
272
+		$blockName = var_export($mixin->name, true);
273
+		if ($this->allowMixinOverride) {
274
+			$name = '$GLOBALS[\'' . $name . '\']';
275
+		}
276
+		$attributes = static::decodeAttributes($mixin->attributes);
277
+
278
+		if ($mixin->call) {
279
+			$this->visitMixinCall($mixin, $name, $blockName, $attributes);
280
+
281
+			return;
282
+		}
283
+
284
+		$this->visitMixinDeclaration($mixin, $name);
285
+	}
286 286
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
                     unset($arguments[$key]);
29 29
                 }
30 30
 
31
-                $defaultAttributes[] = var_export($tab[0], true) . ' => ' . $tab[1];
31
+                $defaultAttributes[] = var_export($tab[0], true).' => '.$tab[1];
32 32
                 $arguments[$newArrayKey][$tab[0]] = static::decodeValue($tab[1]);
33 33
                 continue;
34 34
             }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
             $newArrayKey = null;
38 38
         }
39 39
 
40
-        return array_map(function ($argument) {
40
+        return array_map(function($argument) {
41 41
             if (is_array($argument)) {
42 42
                 $argument = var_export($argument, true);
43 43
             }
@@ -94,28 +94,28 @@  discard block
 block discarded – undo
94 94
         $arguments = func_get_args();
95 95
         $begin = array_shift($arguments);
96 96
         $begin = is_array($begin)
97
-            ? $begin[0] . 'function ' . $begin[1]
98
-            : $begin . 'function ';
99
-        $params = implode(', ', array_map(function ($name) {
100
-            return (substr($name, 0, 1) === '$' ? '' : '$') . $name;
97
+            ? $begin[0].'function '.$begin[1]
98
+            : $begin.'function ';
99
+        $params = implode(', ', array_map(function($name) {
100
+            return (substr($name, 0, 1) === '$' ? '' : '$').$name;
101 101
         }, $arguments));
102 102
 
103 103
         if ($this->restrictedScope) {
104
-            return $this->buffer($this->createCode($begin . '(' . $params . ') {'));
104
+            return $this->buffer($this->createCode($begin.'('.$params.') {'));
105 105
         }
106 106
 
107
-        $params = '&$__varHandler, ' . $params;
107
+        $params = '&$__varHandler, '.$params;
108 108
 
109 109
         $this->buffer(
110
-            $this->createCode($begin . '(' . $params . ') {') .
111
-            $this->createCode($this->indent() . 'extract($__varHandler, EXTR_SKIP);')
110
+            $this->createCode($begin.'('.$params.') {').
111
+            $this->createCode($this->indent().'extract($__varHandler, EXTR_SKIP);')
112 112
         );
113 113
     }
114 114
 
115 115
     protected function renderClosureClosing($code, $arguments = array())
116 116
     {
117 117
         if (!$this->restrictedScope) {
118
-            $arguments = array_filter(array_map(function ($argument) {
118
+            $arguments = array_filter(array_map(function($argument) {
119 119
                 $argument = explode('=', $argument);
120 120
                 $argument = trim($argument[0]);
121 121
 
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
                     : false;
125 125
             }, array_slice($arguments, 1)));
126 126
             $exception = count($arguments)
127
-                ? ' && !in_array($key, ' . var_export($arguments, true) . ')'
127
+                ? ' && !in_array($key, '.var_export($arguments, true).')'
128 128
                 : '';
129 129
             $this->buffer($this->createCode(
130
-                'foreach ($__varHandler as $key => &$val) {' .
131
-                'if ($key !== \'__varHandler\'' . $exception . ') {' .
132
-                '$val = ${$key};' .
133
-                '}' .
130
+                'foreach ($__varHandler as $key => &$val) {'.
131
+                'if ($key !== \'__varHandler\''.$exception.') {'.
132
+                '$val = ${$key};'.
133
+                '}'.
134 134
                 '}'
135 135
             ));
136 136
         }
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
         $strings = array();
162 162
         $arguments = preg_replace_callback(
163 163
             '#([\'"])(.*(?!<\\\\)(?:\\\\{2})*)\\1#U',
164
-            function ($match) use (&$strings) {
164
+            function($match) use (&$strings) {
165 165
                 $nextIndex = count($strings);
166 166
                 $strings[] = $match[0];
167 167
 
168
-                return 'stringToReplaceBy' . $nextIndex . 'ThCapture';
168
+                return 'stringToReplaceBy'.$nextIndex.'ThCapture';
169 169
             },
170 170
             $arguments
171 171
         );
172 172
         $arguments = array_map(
173
-            function ($arg) use ($strings) {
173
+            function($arg) use ($strings) {
174 174
                 return preg_replace_callback(
175 175
                     '#stringToReplaceBy([0-9]+)ThCapture#',
176
-                    function ($match) use ($strings) {
176
+                    function($match) use ($strings) {
177 177
                         return $strings[intval($match[1])];
178 178
                     },
179 179
                     $arg
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
             $this->buffer($this->createCode('$__varHandler = get_defined_vars();'));
201 201
             $paramsPrefix = '$__varHandler, ';
202 202
         }
203
-        $codeFormat = str_repeat('%s;', count($arguments) - 1) . "{$name}({$paramsPrefix}%s)";
203
+        $codeFormat = str_repeat('%s;', count($arguments) - 1)."{$name}({$paramsPrefix}%s)";
204 204
 
205 205
         array_unshift($arguments, $codeFormat);
206 206
 
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
      */
269 269
     protected function visitMixin(Mixin $mixin)
270 270
     {
271
-        $name = strtr($mixin->name, '-', '_') . '_mixin';
271
+        $name = strtr($mixin->name, '-', '_').'_mixin';
272 272
         $blockName = var_export($mixin->name, true);
273 273
         if ($this->allowMixinOverride) {
274
-            $name = '$GLOBALS[\'' . $name . '\']';
274
+            $name = '$GLOBALS[\''.$name.'\']';
275 275
         }
276 276
         $attributes = static::decodeAttributes($mixin->attributes);
277 277
 
Please login to merge, or discard this patch.
modules/ExternalModules/pug-php/pug/src/Jade/Compiler/SubCodeHandler.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -11,6 +11,9 @@
 block discarded – undo
11 11
     protected $input;
12 12
     protected $name;
13 13
 
14
+    /**
15
+     * @param string $input
16
+     */
14 17
     public function __construct(CodeHandler $codeHandler, $input, $name)
15 18
     {
16 19
         $this->codeHandler = $codeHandler;
Please login to merge, or discard this patch.
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -7,168 +7,168 @@
 block discarded – undo
7 7
  */
8 8
 class SubCodeHandler
9 9
 {
10
-    protected $codeHandler;
11
-    protected $input;
12
-    protected $name;
13
-
14
-    public function __construct(CodeHandler $codeHandler, $input, $name)
15
-    {
16
-        $this->codeHandler = $codeHandler;
17
-        $this->input = $input;
18
-        $this->name = $name;
19
-    }
20
-
21
-    public function getMiddleString()
22
-    {
23
-        $input = $this->input;
24
-
25
-        return function ($start, $end) use ($input) {
26
-            $offset = $start[1] + strlen($start[0]);
27
-
28
-            return substr($input, $offset, isset($end) ? $end[1] - $offset : strlen($input));
29
-        };
30
-    }
31
-
32
-    public function handleRecursion(&$result)
33
-    {
34
-        $getMiddleString = $this->getMiddleString();
35
-        $codeHandler = $this->codeHandler;
36
-
37
-        return function ($arg, $name = '') use (&$result, $codeHandler, $getMiddleString) {
38
-            list($start, $end) = $arg;
39
-            $str = trim($getMiddleString($start, $end));
40
-
41
-            if (!strlen($str)) {
42
-                return '';
43
-            }
44
-
45
-            $innerCode = $codeHandler->innerCode($str, $name);
46
-
47
-            if (count($innerCode) > 1) {
48
-                $result = array_merge($result, array_slice($innerCode, 0, -1));
49
-
50
-                return array_pop($innerCode);
51
-            }
52
-
53
-            return $innerCode[0];
54
-        };
55
-    }
56
-
57
-    protected function handleNestedExpression(&$result)
58
-    {
59
-        $handleRecursion = $this->handleRecursion($result);
60
-        $name = $this->name;
61
-
62
-        return function (&$arguments, $start, $end) use ($name, $handleRecursion) {
63
-            if ($end !== false && $start[1] !== $end[1]) {
64
-                array_push(
65
-                    $arguments,
66
-                    $handleRecursion(
67
-                        array($start, $end),
68
-                        $name * 10 + count($arguments)
69
-                    )
70
-                );
71
-            }
72
-        };
73
-    }
74
-
75
-    protected function scanSeparators(&$separators, &$result)
76
-    {
77
-        $handleNested = $this->handleNestedExpression($result);
78
-
79
-        return function (&$arguments, $open, $close) use (&$separators, $handleNested) {
80
-            $count = 1;
81
-
82
-            do {
83
-                $start = current($separators);
84
-
85
-                do {
86
-                    $curr = next($separators);
87
-
88
-                    if ($curr[0] === $open) {
89
-                        $count++;
90
-                    }
91
-                    if ($curr[0] === $close) {
92
-                        $count--;
93
-                    }
94
-                } while ($curr[0] !== null && $count > 0 && $curr[0] !== ',');
95
-
96
-                $handleNested($arguments, $start, current($separators));
97
-            } while ($curr !== false && $count > 0);
98
-
99
-            return $count;
100
-        };
101
-    }
102
-
103
-    public function handleCodeInbetween(&$separators, &$result)
104
-    {
105
-        $scanSeparators = $this->scanSeparators($separators, $result);
106
-        $input = $this->input;
107
-
108
-        return function () use (&$separators, $input, $scanSeparators) {
109
-            $arguments = array();
110
-
111
-            $start = current($separators);
112
-            $endPair = array(
113
-                '[' => ']',
114
-                '{' => '}',
115
-                '(' => ')',
116
-                ',' => false,
117
-            );
118
-            $open = $start[0];
119
-            $close = $endPair[$start[0]];
120
-
121
-            $count = $scanSeparators($arguments, $open, $close);
122
-
123
-            if ($close && $count > 0) {
124
-                throw new \ErrorException($input . "\nMissing closing: " . $close, 14);
125
-            }
126
-
127
-            if (($sep = current($separators)) !== false) {
128
-                $end = next($separators);
129
-                if ($end[0] === null && $sep[1] < $end[1]) {
130
-                    $key = count($arguments) - 1;
131
-                    $arguments[$key] .= substr($input, $sep[1] + 1, $end[1] - $sep[1] - 1);
132
-                }
133
-            }
134
-
135
-            return $arguments;
136
-        };
137
-    }
138
-
139
-    public function getNext($separators)
140
-    {
141
-        return function ($index) use ($separators) {
142
-            if (isset($separators[$index + 1])) {
143
-                return $separators[$index + 1];
144
-            }
145
-        };
146
-    }
147
-
148
-    public function addToOutput(&$output, &$key, &$value)
149
-    {
150
-        return function () use (&$output, &$key, &$value) {
151
-            foreach (array('key', 'value') as $var) {
152
-                ${$var} = trim(${$var});
153
-                if (empty(${$var})) {
154
-                    continue;
155
-                }
156
-                if (preg_match('/^\d*[a-zA-Z_]/', ${$var})) {
157
-                    ${$var} = var_export(${$var}, true);
158
-                }
159
-            }
160
-            $output[] = empty($value)
161
-                ? $key
162
-                : $key . ' => ' . $value;
163
-            $key = '';
164
-            $value = null;
165
-        };
166
-    }
167
-
168
-    public function consume()
169
-    {
170
-        return function (&$argument, $start) {
171
-            $argument = substr($argument, strlen($start));
172
-        };
173
-    }
10
+	protected $codeHandler;
11
+	protected $input;
12
+	protected $name;
13
+
14
+	public function __construct(CodeHandler $codeHandler, $input, $name)
15
+	{
16
+		$this->codeHandler = $codeHandler;
17
+		$this->input = $input;
18
+		$this->name = $name;
19
+	}
20
+
21
+	public function getMiddleString()
22
+	{
23
+		$input = $this->input;
24
+
25
+		return function ($start, $end) use ($input) {
26
+			$offset = $start[1] + strlen($start[0]);
27
+
28
+			return substr($input, $offset, isset($end) ? $end[1] - $offset : strlen($input));
29
+		};
30
+	}
31
+
32
+	public function handleRecursion(&$result)
33
+	{
34
+		$getMiddleString = $this->getMiddleString();
35
+		$codeHandler = $this->codeHandler;
36
+
37
+		return function ($arg, $name = '') use (&$result, $codeHandler, $getMiddleString) {
38
+			list($start, $end) = $arg;
39
+			$str = trim($getMiddleString($start, $end));
40
+
41
+			if (!strlen($str)) {
42
+				return '';
43
+			}
44
+
45
+			$innerCode = $codeHandler->innerCode($str, $name);
46
+
47
+			if (count($innerCode) > 1) {
48
+				$result = array_merge($result, array_slice($innerCode, 0, -1));
49
+
50
+				return array_pop($innerCode);
51
+			}
52
+
53
+			return $innerCode[0];
54
+		};
55
+	}
56
+
57
+	protected function handleNestedExpression(&$result)
58
+	{
59
+		$handleRecursion = $this->handleRecursion($result);
60
+		$name = $this->name;
61
+
62
+		return function (&$arguments, $start, $end) use ($name, $handleRecursion) {
63
+			if ($end !== false && $start[1] !== $end[1]) {
64
+				array_push(
65
+					$arguments,
66
+					$handleRecursion(
67
+						array($start, $end),
68
+						$name * 10 + count($arguments)
69
+					)
70
+				);
71
+			}
72
+		};
73
+	}
74
+
75
+	protected function scanSeparators(&$separators, &$result)
76
+	{
77
+		$handleNested = $this->handleNestedExpression($result);
78
+
79
+		return function (&$arguments, $open, $close) use (&$separators, $handleNested) {
80
+			$count = 1;
81
+
82
+			do {
83
+				$start = current($separators);
84
+
85
+				do {
86
+					$curr = next($separators);
87
+
88
+					if ($curr[0] === $open) {
89
+						$count++;
90
+					}
91
+					if ($curr[0] === $close) {
92
+						$count--;
93
+					}
94
+				} while ($curr[0] !== null && $count > 0 && $curr[0] !== ',');
95
+
96
+				$handleNested($arguments, $start, current($separators));
97
+			} while ($curr !== false && $count > 0);
98
+
99
+			return $count;
100
+		};
101
+	}
102
+
103
+	public function handleCodeInbetween(&$separators, &$result)
104
+	{
105
+		$scanSeparators = $this->scanSeparators($separators, $result);
106
+		$input = $this->input;
107
+
108
+		return function () use (&$separators, $input, $scanSeparators) {
109
+			$arguments = array();
110
+
111
+			$start = current($separators);
112
+			$endPair = array(
113
+				'[' => ']',
114
+				'{' => '}',
115
+				'(' => ')',
116
+				',' => false,
117
+			);
118
+			$open = $start[0];
119
+			$close = $endPair[$start[0]];
120
+
121
+			$count = $scanSeparators($arguments, $open, $close);
122
+
123
+			if ($close && $count > 0) {
124
+				throw new \ErrorException($input . "\nMissing closing: " . $close, 14);
125
+			}
126
+
127
+			if (($sep = current($separators)) !== false) {
128
+				$end = next($separators);
129
+				if ($end[0] === null && $sep[1] < $end[1]) {
130
+					$key = count($arguments) - 1;
131
+					$arguments[$key] .= substr($input, $sep[1] + 1, $end[1] - $sep[1] - 1);
132
+				}
133
+			}
134
+
135
+			return $arguments;
136
+		};
137
+	}
138
+
139
+	public function getNext($separators)
140
+	{
141
+		return function ($index) use ($separators) {
142
+			if (isset($separators[$index + 1])) {
143
+				return $separators[$index + 1];
144
+			}
145
+		};
146
+	}
147
+
148
+	public function addToOutput(&$output, &$key, &$value)
149
+	{
150
+		return function () use (&$output, &$key, &$value) {
151
+			foreach (array('key', 'value') as $var) {
152
+				${$var} = trim(${$var});
153
+				if (empty(${$var})) {
154
+					continue;
155
+				}
156
+				if (preg_match('/^\d*[a-zA-Z_]/', ${$var})) {
157
+					${$var} = var_export(${$var}, true);
158
+				}
159
+			}
160
+			$output[] = empty($value)
161
+				? $key
162
+				: $key . ' => ' . $value;
163
+			$key = '';
164
+			$value = null;
165
+		};
166
+	}
167
+
168
+	public function consume()
169
+	{
170
+		return function (&$argument, $start) {
171
+			$argument = substr($argument, strlen($start));
172
+		};
173
+	}
174 174
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $input = $this->input;
24 24
 
25
-        return function ($start, $end) use ($input) {
25
+        return function($start, $end) use ($input) {
26 26
             $offset = $start[1] + strlen($start[0]);
27 27
 
28 28
             return substr($input, $offset, isset($end) ? $end[1] - $offset : strlen($input));
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $getMiddleString = $this->getMiddleString();
35 35
         $codeHandler = $this->codeHandler;
36 36
 
37
-        return function ($arg, $name = '') use (&$result, $codeHandler, $getMiddleString) {
37
+        return function($arg, $name = '') use (&$result, $codeHandler, $getMiddleString) {
38 38
             list($start, $end) = $arg;
39 39
             $str = trim($getMiddleString($start, $end));
40 40
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         $handleRecursion = $this->handleRecursion($result);
60 60
         $name = $this->name;
61 61
 
62
-        return function (&$arguments, $start, $end) use ($name, $handleRecursion) {
62
+        return function(&$arguments, $start, $end) use ($name, $handleRecursion) {
63 63
             if ($end !== false && $start[1] !== $end[1]) {
64 64
                 array_push(
65 65
                     $arguments,
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $handleNested = $this->handleNestedExpression($result);
78 78
 
79
-        return function (&$arguments, $open, $close) use (&$separators, $handleNested) {
79
+        return function(&$arguments, $open, $close) use (&$separators, $handleNested) {
80 80
             $count = 1;
81 81
 
82 82
             do {
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         $scanSeparators = $this->scanSeparators($separators, $result);
106 106
         $input = $this->input;
107 107
 
108
-        return function () use (&$separators, $input, $scanSeparators) {
108
+        return function() use (&$separators, $input, $scanSeparators) {
109 109
             $arguments = array();
110 110
 
111 111
             $start = current($separators);
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
             $count = $scanSeparators($arguments, $open, $close);
122 122
 
123 123
             if ($close && $count > 0) {
124
-                throw new \ErrorException($input . "\nMissing closing: " . $close, 14);
124
+                throw new \ErrorException($input."\nMissing closing: ".$close, 14);
125 125
             }
126 126
 
127 127
             if (($sep = current($separators)) !== false) {
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 
139 139
     public function getNext($separators)
140 140
     {
141
-        return function ($index) use ($separators) {
141
+        return function($index) use ($separators) {
142 142
             if (isset($separators[$index + 1])) {
143 143
                 return $separators[$index + 1];
144 144
             }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
     public function addToOutput(&$output, &$key, &$value)
149 149
     {
150
-        return function () use (&$output, &$key, &$value) {
150
+        return function() use (&$output, &$key, &$value) {
151 151
             foreach (array('key', 'value') as $var) {
152 152
                 ${$var} = trim(${$var});
153 153
                 if (empty(${$var})) {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             }
160 160
             $output[] = empty($value)
161 161
                 ? $key
162
-                : $key . ' => ' . $value;
162
+                : $key.' => '.$value;
163 163
             $key = '';
164 164
             $value = null;
165 165
         };
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
     public function consume()
169 169
     {
170
-        return function (&$argument, $start) {
170
+        return function(&$argument, $start) {
171 171
             $argument = substr($argument, strlen($start));
172 172
         };
173 173
     }
Please login to merge, or discard this patch.
jate/modules/ExternalModules/pug-php/pug/src/Jade/Compiler/TagVisitor.php 3 patches
Doc Comments   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,7 +7,8 @@  discard block
 block discarded – undo
7 7
 abstract class TagVisitor extends Visitor
8 8
 {
9 9
     /**
10
-     * @param Nodes\Tag $tag
10
+     * @param Tag $tag
11
+     * @param boolean $newLinePrettyPrint
11 12
      */
12 13
     protected function visitTagAttributes(Tag $tag, $newLinePrettyPrint, $close = '>')
13 14
     {
@@ -25,7 +26,7 @@  discard block
 block discarded – undo
25 26
     }
26 27
 
27 28
     /**
28
-     * @param Nodes\Tag $tag
29
+     * @param Tag $tag
29 30
      */
30 31
     protected function initTagName(Tag $tag)
31 32
     {
@@ -47,7 +48,7 @@  discard block
 block discarded – undo
47 48
     }
48 49
 
49 50
     /**
50
-     * @param Nodes\Tag $tag
51
+     * @param Tag $tag
51 52
      */
52 53
     protected function visitTagContents(Tag $tag)
53 54
     {
@@ -64,7 +65,7 @@  discard block
 block discarded – undo
64 65
     }
65 66
 
66 67
     /**
67
-     * @param Nodes\Tag $tag
68
+     * @param Tag $tag
68 69
      */
69 70
     protected function compileTag(Tag $tag)
70 71
     {
@@ -78,7 +79,7 @@  discard block
 block discarded – undo
78 79
     }
79 80
 
80 81
     /**
81
-     * @param Nodes\Tag $tag
82
+     * @param Tag $tag
82 83
      */
83 84
     protected function visitTag(Tag $tag)
84 85
     {
Please login to merge, or discard this patch.
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -6,95 +6,95 @@
 block discarded – undo
6 6
 
7 7
 abstract class TagVisitor extends Visitor
8 8
 {
9
-    /**
10
-     * @param Nodes\Tag $tag
11
-     */
12
-    protected function visitTagAttributes(Tag $tag, $newLinePrettyPrint, $close = '>')
13
-    {
14
-        $open = '<' . $tag->name;
15
-
16
-        if (count($tag->attributes)) {
17
-            $this->buffer($this->indent() . $open, false);
18
-            $this->visitAttributes($tag->attributes);
19
-            $this->buffer($this->getClassesDisplayCode() . $close . $this->newline(), false);
20
-
21
-            return;
22
-        }
23
-
24
-        $this->buffer($open . $close, $newLinePrettyPrint ? null : false);
25
-    }
26
-
27
-    /**
28
-     * @param Nodes\Tag $tag
29
-     */
30
-    protected function initTagName(Tag $tag)
31
-    {
32
-        if (isset($tag->buffer)) {
33
-            if (preg_match('`^[a-z][a-zA-Z0-9]+(?!\()`', $tag->name)) {
34
-                $tag->name = '$' . $tag->name;
35
-            }
36
-            $tag->name = trim($this->createCode('echo ' . $tag->name . ';'));
37
-        }
38
-    }
39
-
40
-    protected function trimLastLine()
41
-    {
42
-        $key = count($this->buffer) - 1;
43
-        $this->buffer[$key] = substr($this->buffer[$key], 0, -1);
44
-        if ($this->prettyprint && substr($this->buffer[$key], -1) === ' ') {
45
-            $this->buffer[$key] = substr($this->buffer[$key], 0, -1);
46
-        }
47
-    }
48
-
49
-    /**
50
-     * @param Nodes\Tag $tag
51
-     */
52
-    protected function visitTagContents(Tag $tag)
53
-    {
54
-        $inc = $tag->keepWhiteSpaces() ? -$this->indents : 1;
55
-        $this->indents += $inc;
56
-        if (isset($tag->code)) {
57
-            $this->visitCode($tag->code);
58
-        }
59
-        $this->visit($tag->block);
60
-        if ($tag->keepWhiteSpaces() && substr(end($this->buffer), -1) === "\n") {
61
-            $this->trimLastLine();
62
-        }
63
-        $this->indents -= $inc;
64
-    }
65
-
66
-    /**
67
-     * @param Nodes\Tag $tag
68
-     */
69
-    protected function compileTag(Tag $tag)
70
-    {
71
-        $selfClosing = (in_array(strtolower($tag->name), $this->selfClosing) || $tag->selfClosing) && !$this->xml;
72
-        $this->visitTagAttributes($tag, !$tag->keepWhiteSpaces() && $this->prettyprint, (!$selfClosing || $this->terse) ? '>' : ' />');
73
-
74
-        if (!$selfClosing) {
75
-            $this->visitTagContents($tag);
76
-            $this->buffer('</' . $tag->name . '>', $tag->keepWhiteSpaces() ? false : null);
77
-        }
78
-    }
79
-
80
-    /**
81
-     * @param Nodes\Tag $tag
82
-     */
83
-    protected function visitTag(Tag $tag)
84
-    {
85
-        $this->initTagName($tag);
86
-
87
-        $insidePrettyprint = !$tag->canInline() && $this->prettyprint && !$tag->isInline();
88
-        $prettyprint = $tag->keepWhiteSpaces() || $insidePrettyprint;
89
-
90
-        if ($this->prettyprint && !$insidePrettyprint) {
91
-            $this->buffer[] = $this->indent();
92
-        }
93
-
94
-        $this->tempPrettyPrint($prettyprint, 'compileTag', $tag);
95
-
96
-        if (!$prettyprint && $this->prettyprint && !$tag->isInline()) {
97
-            $this->buffer[] = $this->newline();
98
-        }
99
-    }
9
+	/**
10
+	 * @param Nodes\Tag $tag
11
+	 */
12
+	protected function visitTagAttributes(Tag $tag, $newLinePrettyPrint, $close = '>')
13
+	{
14
+		$open = '<' . $tag->name;
15
+
16
+		if (count($tag->attributes)) {
17
+			$this->buffer($this->indent() . $open, false);
18
+			$this->visitAttributes($tag->attributes);
19
+			$this->buffer($this->getClassesDisplayCode() . $close . $this->newline(), false);
20
+
21
+			return;
22
+		}
23
+
24
+		$this->buffer($open . $close, $newLinePrettyPrint ? null : false);
25
+	}
26
+
27
+	/**
28
+	 * @param Nodes\Tag $tag
29
+	 */
30
+	protected function initTagName(Tag $tag)
31
+	{
32
+		if (isset($tag->buffer)) {
33
+			if (preg_match('`^[a-z][a-zA-Z0-9]+(?!\()`', $tag->name)) {
34
+				$tag->name = '$' . $tag->name;
35
+			}
36
+			$tag->name = trim($this->createCode('echo ' . $tag->name . ';'));
37
+		}
38
+	}
39
+
40
+	protected function trimLastLine()
41
+	{
42
+		$key = count($this->buffer) - 1;
43
+		$this->buffer[$key] = substr($this->buffer[$key], 0, -1);
44
+		if ($this->prettyprint && substr($this->buffer[$key], -1) === ' ') {
45
+			$this->buffer[$key] = substr($this->buffer[$key], 0, -1);
46
+		}
47
+	}
48
+
49
+	/**
50
+	 * @param Nodes\Tag $tag
51
+	 */
52
+	protected function visitTagContents(Tag $tag)
53
+	{
54
+		$inc = $tag->keepWhiteSpaces() ? -$this->indents : 1;
55
+		$this->indents += $inc;
56
+		if (isset($tag->code)) {
57
+			$this->visitCode($tag->code);
58
+		}
59
+		$this->visit($tag->block);
60
+		if ($tag->keepWhiteSpaces() && substr(end($this->buffer), -1) === "\n") {
61
+			$this->trimLastLine();
62
+		}
63
+		$this->indents -= $inc;
64
+	}
65
+
66
+	/**
67
+	 * @param Nodes\Tag $tag
68
+	 */
69
+	protected function compileTag(Tag $tag)
70
+	{
71
+		$selfClosing = (in_array(strtolower($tag->name), $this->selfClosing) || $tag->selfClosing) && !$this->xml;
72
+		$this->visitTagAttributes($tag, !$tag->keepWhiteSpaces() && $this->prettyprint, (!$selfClosing || $this->terse) ? '>' : ' />');
73
+
74
+		if (!$selfClosing) {
75
+			$this->visitTagContents($tag);
76
+			$this->buffer('</' . $tag->name . '>', $tag->keepWhiteSpaces() ? false : null);
77
+		}
78
+	}
79
+
80
+	/**
81
+	 * @param Nodes\Tag $tag
82
+	 */
83
+	protected function visitTag(Tag $tag)
84
+	{
85
+		$this->initTagName($tag);
86
+
87
+		$insidePrettyprint = !$tag->canInline() && $this->prettyprint && !$tag->isInline();
88
+		$prettyprint = $tag->keepWhiteSpaces() || $insidePrettyprint;
89
+
90
+		if ($this->prettyprint && !$insidePrettyprint) {
91
+			$this->buffer[] = $this->indent();
92
+		}
93
+
94
+		$this->tempPrettyPrint($prettyprint, 'compileTag', $tag);
95
+
96
+		if (!$prettyprint && $this->prettyprint && !$tag->isInline()) {
97
+			$this->buffer[] = $this->newline();
98
+		}
99
+	}
100 100
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@  discard block
 block discarded – undo
11 11
      */
12 12
     protected function visitTagAttributes(Tag $tag, $newLinePrettyPrint, $close = '>')
13 13
     {
14
-        $open = '<' . $tag->name;
14
+        $open = '<'.$tag->name;
15 15
 
16 16
         if (count($tag->attributes)) {
17
-            $this->buffer($this->indent() . $open, false);
17
+            $this->buffer($this->indent().$open, false);
18 18
             $this->visitAttributes($tag->attributes);
19
-            $this->buffer($this->getClassesDisplayCode() . $close . $this->newline(), false);
19
+            $this->buffer($this->getClassesDisplayCode().$close.$this->newline(), false);
20 20
 
21 21
             return;
22 22
         }
23 23
 
24
-        $this->buffer($open . $close, $newLinePrettyPrint ? null : false);
24
+        $this->buffer($open.$close, $newLinePrettyPrint ? null : false);
25 25
     }
26 26
 
27 27
     /**
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
     {
32 32
         if (isset($tag->buffer)) {
33 33
             if (preg_match('`^[a-z][a-zA-Z0-9]+(?!\()`', $tag->name)) {
34
-                $tag->name = '$' . $tag->name;
34
+                $tag->name = '$'.$tag->name;
35 35
             }
36
-            $tag->name = trim($this->createCode('echo ' . $tag->name . ';'));
36
+            $tag->name = trim($this->createCode('echo '.$tag->name.';'));
37 37
         }
38 38
     }
39 39
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
         if (!$selfClosing) {
75 75
             $this->visitTagContents($tag);
76
-            $this->buffer('</' . $tag->name . '>', $tag->keepWhiteSpaces() ? false : null);
76
+            $this->buffer('</'.$tag->name.'>', $tag->keepWhiteSpaces() ? false : null);
77 77
         }
78 78
     }
79 79
 
Please login to merge, or discard this patch.
dist/jate/modules/ExternalModules/pug-php/pug/src/Jade/Compiler/Visitor.php 3 patches
Doc Comments   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 abstract class Visitor extends KeywordsCompiler
12 12
 {
13 13
     /**
14
-     * @param Nodes\Node $node
14
+     * @param Node $node
15 15
      *
16 16
      * @return array
17 17
      */
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     }
24 24
 
25 25
     /**
26
-     * @param Nodes\Node $node
26
+     * @param Node $node
27 27
      *
28 28
      * @return mixed
29 29
      */
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     }
57 57
 
58 58
     /**
59
-     * @param Nodes\Literal $node
59
+     * @param Literal $node
60 60
      */
61 61
     protected function visitLiteral(Literal $node)
62 62
     {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     }
66 66
 
67 67
     /**
68
-     * @param Nodes\Block $block
68
+     * @param Block $block
69 69
      */
70 70
     protected function visitBlock(Block $block)
71 71
     {
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     }
76 76
 
77 77
     /**
78
-     * @param Nodes\Doctype $doctype
78
+     * @param Doctype $doctype
79 79
      *
80 80
      * @throws \Exception
81 81
      */
@@ -97,7 +97,6 @@  discard block
 block discarded – undo
97 97
     }
98 98
 
99 99
     /**
100
-     * @param Nodes\Mixin $mixin
101 100
      */
102 101
     protected function visitMixinBlock()
103 102
     {
@@ -119,7 +118,7 @@  discard block
 block discarded – undo
119 118
     }
120 119
 
121 120
     /**
122
-     * @param Nodes\Comment $comment
121
+     * @param Comment $comment
123 122
      */
124 123
     protected function visitComment(Comment $comment)
125 124
     {
Please login to merge, or discard this patch.
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -10,129 +10,129 @@
 block discarded – undo
10 10
 
11 11
 abstract class Visitor extends KeywordsCompiler
12 12
 {
13
-    /**
14
-     * @param Nodes\Node $node
15
-     *
16
-     * @return array
17
-     */
18
-    public function visit(Node $node)
19
-    {
20
-        $this->visitNode($node);
21
-
22
-        return $this->buffer;
23
-    }
24
-
25
-    /**
26
-     * @param Nodes\Node $node
27
-     *
28
-     * @return mixed
29
-     */
30
-    protected function visitNode(Node $node)
31
-    {
32
-        $fqn = get_class($node);
33
-        $parts = explode('\\', $fqn);
34
-        $name = strtolower(end($parts));
35
-        $method = 'visit' . ucfirst($name);
36
-
37
-        try {
38
-            return $this->$method($node);
39
-        } catch (\ErrorException $e) {
40
-            if (!in_array($e->getCode(), array(8, 33))) {
41
-                throw $e;
42
-            }
43
-
44
-            throw new \ErrorException(
45
-                'Error on the ' . $name .
46
-                (isset($node->name) ? ' "' . $node->name . '"' : '') .
47
-                ($this->filename ? ' in ' . $this->filename : '') .
48
-                ' line ' . $node->line . ":\n" . $e->getMessage(),
49
-                34,
50
-                1,
51
-                __FILE__,
52
-                __LINE__,
53
-                $e
54
-            );
55
-        }
56
-    }
57
-
58
-    /**
59
-     * @param Nodes\Literal $node
60
-     */
61
-    protected function visitLiteral(Literal $node)
62
-    {
63
-        $str = preg_replace('/\\n/', '\\\\n', $node->string);
64
-        $this->buffer($str);
65
-    }
66
-
67
-    /**
68
-     * @param Nodes\Block $block
69
-     */
70
-    protected function visitBlock(Block $block)
71
-    {
72
-        foreach ($block->nodes as $n) {
73
-            $this->visit($n);
74
-        }
75
-    }
76
-
77
-    /**
78
-     * @param Nodes\Doctype $doctype
79
-     *
80
-     * @throws \Exception
81
-     */
82
-    protected function visitDoctype(Doctype $doctype = null)
83
-    {
84
-        $doc = (empty($doctype->value) || $doctype === null || !isset($doctype->value))
85
-            ? 'default'
86
-            : strtolower($doctype->value);
87
-
88
-        $str = isset($this->doctypes[$doc])
89
-            ? $this->doctypes[$doc]
90
-            : "<!DOCTYPE {$doc}>";
91
-
92
-        $this->buffer($str . $this->newline());
93
-
94
-        $this->terse = (strtolower($str) === '<!doctype html>');
95
-
96
-        $this->xml = ($doc === 'xml');
97
-    }
98
-
99
-    /**
100
-     * @param Nodes\Mixin $mixin
101
-     */
102
-    protected function visitMixinBlock()
103
-    {
104
-        $name = var_export($this->visitedMixin->name, true);
105
-
106
-        $code = $this->restrictedScope
107
-            ? "\\Jade\\Compiler::callMixinBlock($name, \$attributes);"
108
-            : "\$__varHandler = get_defined_vars(); \\Jade\\Compiler::callMixinBlockWithVars($name, \$__varHandler, \$attributes); extract(array_diff_key(\$__varHandler, array('__varHandler' => 1)));";
109
-
110
-        $this->buffer($this->createCode($code));
111
-    }
112
-
113
-    /**
114
-     * @param Nodes\Text $text
115
-     */
116
-    protected function visitText($text)
117
-    {
118
-        $this->buffer($this->interpolate($text->value));
119
-    }
120
-
121
-    /**
122
-     * @param Nodes\Comment $comment
123
-     */
124
-    protected function visitComment(Comment $comment)
125
-    {
126
-        if ($comment->buffer) {
127
-            $this->buffer('<!--' . $comment->value . '-->');
128
-        }
129
-    }
130
-
131
-    /**
132
-     * @param array $attributes
133
-     */
134
-    protected function visitAttributes($attributes)
135
-    {
136
-        $this->tempPrettyPrint(false, 'compileAttributes', $attributes);
137
-    }
13
+	/**
14
+	 * @param Nodes\Node $node
15
+	 *
16
+	 * @return array
17
+	 */
18
+	public function visit(Node $node)
19
+	{
20
+		$this->visitNode($node);
21
+
22
+		return $this->buffer;
23
+	}
24
+
25
+	/**
26
+	 * @param Nodes\Node $node
27
+	 *
28
+	 * @return mixed
29
+	 */
30
+	protected function visitNode(Node $node)
31
+	{
32
+		$fqn = get_class($node);
33
+		$parts = explode('\\', $fqn);
34
+		$name = strtolower(end($parts));
35
+		$method = 'visit' . ucfirst($name);
36
+
37
+		try {
38
+			return $this->$method($node);
39
+		} catch (\ErrorException $e) {
40
+			if (!in_array($e->getCode(), array(8, 33))) {
41
+				throw $e;
42
+			}
43
+
44
+			throw new \ErrorException(
45
+				'Error on the ' . $name .
46
+				(isset($node->name) ? ' "' . $node->name . '"' : '') .
47
+				($this->filename ? ' in ' . $this->filename : '') .
48
+				' line ' . $node->line . ":\n" . $e->getMessage(),
49
+				34,
50
+				1,
51
+				__FILE__,
52
+				__LINE__,
53
+				$e
54
+			);
55
+		}
56
+	}
57
+
58
+	/**
59
+	 * @param Nodes\Literal $node
60
+	 */
61
+	protected function visitLiteral(Literal $node)
62
+	{
63
+		$str = preg_replace('/\\n/', '\\\\n', $node->string);
64
+		$this->buffer($str);
65
+	}
66
+
67
+	/**
68
+	 * @param Nodes\Block $block
69
+	 */
70
+	protected function visitBlock(Block $block)
71
+	{
72
+		foreach ($block->nodes as $n) {
73
+			$this->visit($n);
74
+		}
75
+	}
76
+
77
+	/**
78
+	 * @param Nodes\Doctype $doctype
79
+	 *
80
+	 * @throws \Exception
81
+	 */
82
+	protected function visitDoctype(Doctype $doctype = null)
83
+	{
84
+		$doc = (empty($doctype->value) || $doctype === null || !isset($doctype->value))
85
+			? 'default'
86
+			: strtolower($doctype->value);
87
+
88
+		$str = isset($this->doctypes[$doc])
89
+			? $this->doctypes[$doc]
90
+			: "<!DOCTYPE {$doc}>";
91
+
92
+		$this->buffer($str . $this->newline());
93
+
94
+		$this->terse = (strtolower($str) === '<!doctype html>');
95
+
96
+		$this->xml = ($doc === 'xml');
97
+	}
98
+
99
+	/**
100
+	 * @param Nodes\Mixin $mixin
101
+	 */
102
+	protected function visitMixinBlock()
103
+	{
104
+		$name = var_export($this->visitedMixin->name, true);
105
+
106
+		$code = $this->restrictedScope
107
+			? "\\Jade\\Compiler::callMixinBlock($name, \$attributes);"
108
+			: "\$__varHandler = get_defined_vars(); \\Jade\\Compiler::callMixinBlockWithVars($name, \$__varHandler, \$attributes); extract(array_diff_key(\$__varHandler, array('__varHandler' => 1)));";
109
+
110
+		$this->buffer($this->createCode($code));
111
+	}
112
+
113
+	/**
114
+	 * @param Nodes\Text $text
115
+	 */
116
+	protected function visitText($text)
117
+	{
118
+		$this->buffer($this->interpolate($text->value));
119
+	}
120
+
121
+	/**
122
+	 * @param Nodes\Comment $comment
123
+	 */
124
+	protected function visitComment(Comment $comment)
125
+	{
126
+		if ($comment->buffer) {
127
+			$this->buffer('<!--' . $comment->value . '-->');
128
+		}
129
+	}
130
+
131
+	/**
132
+	 * @param array $attributes
133
+	 */
134
+	protected function visitAttributes($attributes)
135
+	{
136
+		$this->tempPrettyPrint(false, 'compileAttributes', $attributes);
137
+	}
138 138
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         $fqn = get_class($node);
33 33
         $parts = explode('\\', $fqn);
34 34
         $name = strtolower(end($parts));
35
-        $method = 'visit' . ucfirst($name);
35
+        $method = 'visit'.ucfirst($name);
36 36
 
37 37
         try {
38 38
             return $this->$method($node);
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
             }
43 43
 
44 44
             throw new \ErrorException(
45
-                'Error on the ' . $name .
46
-                (isset($node->name) ? ' "' . $node->name . '"' : '') .
47
-                ($this->filename ? ' in ' . $this->filename : '') .
48
-                ' line ' . $node->line . ":\n" . $e->getMessage(),
45
+                'Error on the '.$name.
46
+                (isset($node->name) ? ' "'.$node->name.'"' : '').
47
+                ($this->filename ? ' in '.$this->filename : '').
48
+                ' line '.$node->line.":\n".$e->getMessage(),
49 49
                 34,
50 50
                 1,
51 51
                 __FILE__,
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
             ? $this->doctypes[$doc]
90 90
             : "<!DOCTYPE {$doc}>";
91 91
 
92
-        $this->buffer($str . $this->newline());
92
+        $this->buffer($str.$this->newline());
93 93
 
94 94
         $this->terse = (strtolower($str) === '<!doctype html>');
95 95
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     protected function visitComment(Comment $comment)
125 125
     {
126 126
         if ($comment->buffer) {
127
-            $this->buffer('<!--' . $comment->value . '-->');
127
+            $this->buffer('<!--'.$comment->value.'-->');
128 128
         }
129 129
     }
130 130
 
Please login to merge, or discard this patch.
dist/jate/modules/ExternalModules/pug-php/pug/src/Jade/Engine/Cache.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
      *
33 33
      * @param string $directory the directory to search in pug templates
34 34
      *
35
-     * @return array count of cached files and error count
35
+     * @return integer[] count of cached files and error count
36 36
      */
37 37
     public function cacheDirectory($directory)
38 38
     {
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -9,35 +9,35 @@
 block discarded – undo
9 9
  */
10 10
 abstract class Cache extends Filters
11 11
 {
12
-    /**
13
-     * Get cached input/file a matching cache file exists.
14
-     * Else, render the input, cache it in a file and return it.
15
-     *
16
-     * @param string input
17
-     *
18
-     * @throws \InvalidArgumentException
19
-     * @throws \Exception
20
-     *
21
-     * @return string
22
-     */
23
-    public function cache($input)
24
-    {
25
-        $cache = new CacheHelper($this);
12
+	/**
13
+	 * Get cached input/file a matching cache file exists.
14
+	 * Else, render the input, cache it in a file and return it.
15
+	 *
16
+	 * @param string input
17
+	 *
18
+	 * @throws \InvalidArgumentException
19
+	 * @throws \Exception
20
+	 *
21
+	 * @return string
22
+	 */
23
+	public function cache($input)
24
+	{
25
+		$cache = new CacheHelper($this);
26 26
 
27
-        return $cache->cache($input);
28
-    }
27
+		return $cache->cache($input);
28
+	}
29 29
 
30
-    /**
31
-     * Scan a directory recursively, compile them and save them into the cache directory.
32
-     *
33
-     * @param string $directory the directory to search in pug templates
34
-     *
35
-     * @return array count of cached files and error count
36
-     */
37
-    public function cacheDirectory($directory)
38
-    {
39
-        $cache = new CacheHelper($this);
30
+	/**
31
+	 * Scan a directory recursively, compile them and save them into the cache directory.
32
+	 *
33
+	 * @param string $directory the directory to search in pug templates
34
+	 *
35
+	 * @return array count of cached files and error count
36
+	 */
37
+	public function cacheDirectory($directory)
38
+	{
39
+		$cache = new CacheHelper($this);
40 40
 
41
-        return $cache->cacheDirectory($directory);
42
-    }
41
+		return $cache->cacheDirectory($directory);
42
+	}
43 43
 }
Please login to merge, or discard this patch.
dist/jate/modules/ExternalModules/pug-php/pug/src/Jade/Engine/Keywords.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -7,6 +7,9 @@
 block discarded – undo
7 7
  */
8 8
 abstract class Keywords extends Cache
9 9
 {
10
+    /**
11
+     * @param string $keyword
12
+     */
10 13
     protected function hasKeyword($keyword)
11 14
     {
12 15
         return $this->hasValidCustomKeywordsOption() && isset($this->options['customKeywords'][$keyword]);
Please login to merge, or discard this patch.
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -7,77 +7,77 @@
 block discarded – undo
7 7
  */
8 8
 abstract class Keywords extends Cache
9 9
 {
10
-    protected function hasKeyword($keyword)
11
-    {
12
-        return $this->hasValidCustomKeywordsOption() && isset($this->options['customKeywords'][$keyword]);
13
-    }
10
+	protected function hasKeyword($keyword)
11
+	{
12
+		return $this->hasValidCustomKeywordsOption() && isset($this->options['customKeywords'][$keyword]);
13
+	}
14 14
 
15
-    protected function hasValidCustomKeywordsOption()
16
-    {
17
-        return isset($this->options['customKeywords']) && (
18
-            is_array($this->options['customKeywords']) ||
19
-            $this->options['customKeywords'] instanceof \ArrayAccess
20
-        );
21
-    }
15
+	protected function hasValidCustomKeywordsOption()
16
+	{
17
+		return isset($this->options['customKeywords']) && (
18
+			is_array($this->options['customKeywords']) ||
19
+			$this->options['customKeywords'] instanceof \ArrayAccess
20
+		);
21
+	}
22 22
 
23
-    /**
24
-     * Set custom keyword.
25
-     *
26
-     * @param string   $keyword the keyword to be found.
27
-     * @param callable $action  action to be executed when the keyword is found.
28
-     */
29
-    public function setKeyword($keyword, $action)
30
-    {
31
-        if (!is_callable($action)) {
32
-            throw new \InvalidArgumentException("Please add a callable action for your keyword $keyword", 30);
33
-        }
23
+	/**
24
+	 * Set custom keyword.
25
+	 *
26
+	 * @param string   $keyword the keyword to be found.
27
+	 * @param callable $action  action to be executed when the keyword is found.
28
+	 */
29
+	public function setKeyword($keyword, $action)
30
+	{
31
+		if (!is_callable($action)) {
32
+			throw new \InvalidArgumentException("Please add a callable action for your keyword $keyword", 30);
33
+		}
34 34
 
35
-        if (!$this->hasValidCustomKeywordsOption()) {
36
-            $this->options['customKeywords'] = array();
37
-        }
35
+		if (!$this->hasValidCustomKeywordsOption()) {
36
+			$this->options['customKeywords'] = array();
37
+		}
38 38
 
39
-        $this->options['customKeywords'][$keyword] = $action;
40
-    }
39
+		$this->options['customKeywords'][$keyword] = $action;
40
+	}
41 41
 
42
-    /**
43
-     * Add custom keyword.
44
-     *
45
-     * @param string   $keyword the keyword to be found.
46
-     * @param callable $action  action to be executed when the keyword is found.
47
-     */
48
-    public function addKeyword($keyword, $action)
49
-    {
50
-        if ($this->hasKeyword($keyword)) {
51
-            throw new \InvalidArgumentException("The keyword $keyword is already set.", 31);
52
-        }
42
+	/**
43
+	 * Add custom keyword.
44
+	 *
45
+	 * @param string   $keyword the keyword to be found.
46
+	 * @param callable $action  action to be executed when the keyword is found.
47
+	 */
48
+	public function addKeyword($keyword, $action)
49
+	{
50
+		if ($this->hasKeyword($keyword)) {
51
+			throw new \InvalidArgumentException("The keyword $keyword is already set.", 31);
52
+		}
53 53
 
54
-        $this->setKeyword($keyword, $action);
55
-    }
54
+		$this->setKeyword($keyword, $action);
55
+	}
56 56
 
57
-    /**
58
-     * Replace custom keyword.
59
-     *
60
-     * @param string   $keyword the keyword to be found.
61
-     * @param callable $action  action to be executed when the keyword is found.
62
-     */
63
-    public function replaceKeyword($keyword, $action)
64
-    {
65
-        if (!$this->hasKeyword($keyword)) {
66
-            throw new \InvalidArgumentException("The keyword $keyword is not set.", 32);
67
-        }
57
+	/**
58
+	 * Replace custom keyword.
59
+	 *
60
+	 * @param string   $keyword the keyword to be found.
61
+	 * @param callable $action  action to be executed when the keyword is found.
62
+	 */
63
+	public function replaceKeyword($keyword, $action)
64
+	{
65
+		if (!$this->hasKeyword($keyword)) {
66
+			throw new \InvalidArgumentException("The keyword $keyword is not set.", 32);
67
+		}
68 68
 
69
-        $this->setKeyword($keyword, $action);
70
-    }
69
+		$this->setKeyword($keyword, $action);
70
+	}
71 71
 
72
-    /**
73
-     * Remove custom keyword.
74
-     *
75
-     * @param string $keyword the keyword to be removed.
76
-     */
77
-    public function removeKeyword($keyword)
78
-    {
79
-        if ($this->hasKeyword($keyword)) {
80
-            unset($this->options['customKeywords'][$keyword]);
81
-        }
82
-    }
72
+	/**
73
+	 * Remove custom keyword.
74
+	 *
75
+	 * @param string $keyword the keyword to be removed.
76
+	 */
77
+	public function removeKeyword($keyword)
78
+	{
79
+		if ($this->hasKeyword($keyword)) {
80
+			unset($this->options['customKeywords'][$keyword]);
81
+		}
82
+	}
83 83
 }
Please login to merge, or discard this patch.
jate/modules/ExternalModules/pug-php/pug/src/Jade/Filter/AbstractFilter.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
      * @param Filter   $node
19 19
      * @param Compiler $compiler
20 20
      *
21
-     * @return mixed
21
+     * @return string
22 22
      */
23 23
     protected function getNodeString(Filter $node, Compiler $compiler = null)
24 24
     {
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -10,45 +10,45 @@
 block discarded – undo
10 10
  */
11 11
 abstract class AbstractFilter implements FilterInterface
12 12
 {
13
-    /**
14
-     * Returns the node string value, line by line.
15
-     * If the compiler is present, that means we need
16
-     * to interpolate line contents.
17
-     *
18
-     * @param Filter   $node
19
-     * @param Compiler $compiler
20
-     *
21
-     * @return mixed
22
-     */
23
-    protected function getNodeString(Filter $node, Compiler $compiler = null)
24
-    {
25
-        return array_reduce($node->block->nodes, function ($result, $line) use ($compiler) {
26
-            return $result . ($compiler
27
-                ? $compiler->interpolate($line->value)
28
-                : $line->value
29
-            ) . "\n";
30
-        });
31
-    }
13
+	/**
14
+	 * Returns the node string value, line by line.
15
+	 * If the compiler is present, that means we need
16
+	 * to interpolate line contents.
17
+	 *
18
+	 * @param Filter   $node
19
+	 * @param Compiler $compiler
20
+	 *
21
+	 * @return mixed
22
+	 */
23
+	protected function getNodeString(Filter $node, Compiler $compiler = null)
24
+	{
25
+		return array_reduce($node->block->nodes, function ($result, $line) use ($compiler) {
26
+			return $result . ($compiler
27
+				? $compiler->interpolate($line->value)
28
+				: $line->value
29
+			) . "\n";
30
+		});
31
+	}
32 32
 
33
-    public function __invoke(Filter $node, Compiler $compiler)
34
-    {
35
-        $nodes = $node->block->nodes;
36
-        $indent = strlen($nodes[0]->value) - strlen(ltrim($nodes[0]->value));
37
-        $code = '';
38
-        foreach ($nodes as $line) {
39
-            $code .= substr($compiler->interpolate($line->value), $indent) . "\n";
40
-        }
33
+	public function __invoke(Filter $node, Compiler $compiler)
34
+	{
35
+		$nodes = $node->block->nodes;
36
+		$indent = strlen($nodes[0]->value) - strlen(ltrim($nodes[0]->value));
37
+		$code = '';
38
+		foreach ($nodes as $line) {
39
+			$code .= substr($compiler->interpolate($line->value), $indent) . "\n";
40
+		}
41 41
 
42
-        if (method_exists($this, 'parse')) {
43
-            $code = $this->parse($code);
44
-        }
42
+		if (method_exists($this, 'parse')) {
43
+			$code = $this->parse($code);
44
+		}
45 45
 
46
-        if (isset($this->tag)) {
47
-            $code = '<' . $this->tag . (isset($this->textType) ? ' type="text/' . $this->textType . '"' : '') . '>' .
48
-                $code .
49
-                '</' . $this->tag . '>';
50
-        }
46
+		if (isset($this->tag)) {
47
+			$code = '<' . $this->tag . (isset($this->textType) ? ' type="text/' . $this->textType . '"' : '') . '>' .
48
+				$code .
49
+				'</' . $this->tag . '>';
50
+		}
51 51
 
52
-        return $code;
53
-    }
52
+		return $code;
53
+	}
54 54
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
      */
23 23
     protected function getNodeString(Filter $node, Compiler $compiler = null)
24 24
     {
25
-        return array_reduce($node->block->nodes, function ($result, $line) use ($compiler) {
26
-            return $result . ($compiler
25
+        return array_reduce($node->block->nodes, function($result, $line) use ($compiler) {
26
+            return $result.($compiler
27 27
                 ? $compiler->interpolate($line->value)
28 28
                 : $line->value
29
-            ) . "\n";
29
+            )."\n";
30 30
         });
31 31
     }
32 32
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         $indent = strlen($nodes[0]->value) - strlen(ltrim($nodes[0]->value));
37 37
         $code = '';
38 38
         foreach ($nodes as $line) {
39
-            $code .= substr($compiler->interpolate($line->value), $indent) . "\n";
39
+            $code .= substr($compiler->interpolate($line->value), $indent)."\n";
40 40
         }
41 41
 
42 42
         if (method_exists($this, 'parse')) {
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
         }
45 45
 
46 46
         if (isset($this->tag)) {
47
-            $code = '<' . $this->tag . (isset($this->textType) ? ' type="text/' . $this->textType . '"' : '') . '>' .
48
-                $code .
49
-                '</' . $this->tag . '>';
47
+            $code = '<'.$this->tag.(isset($this->textType) ? ' type="text/'.$this->textType.'"' : '').'>'.
48
+                $code.
49
+                '</'.$this->tag.'>';
50 50
         }
51 51
 
52 52
         return $code;
Please login to merge, or discard this patch.
dist/jate/modules/ExternalModules/pug-php/pug/src/Jade/Jade.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,6 +75,7 @@  discard block
 block discarded – undo
75 75
      * is missing in the executor include whitelist.
76 76
      * Returns false in any other case.
77 77
      *
78
+     * @param string $extension
78 79
      * @return bool
79 80
      */
80 81
     protected function whiteListNeeded($extension)
@@ -125,6 +126,7 @@  discard block
 block discarded – undo
125 126
      * Throw a invalid argument exception if the option does not exists.
126 127
      *
127 128
      * @param string name
129
+     * @param string $name
128 130
      *
129 131
      * @throws \InvalidArgumentException
130 132
      */
@@ -265,6 +267,7 @@  discard block
 block discarded – undo
265 267
      * the possibility to add $scope variables.
266 268
      *
267 269
      * @param string input
270
+     * @param string $input
268 271
      *
269 272
      * @throws \ErrorException
270 273
      *
@@ -287,7 +290,7 @@  discard block
 block discarded – undo
287 290
      * Add a variable or an array of variables to be shared with all templates that will be rendered
288 291
      * by the instance of Pug.
289 292
      *
290
-     * @param array|string $variables|$key an associatives array of variable names and values, or a
293
+     * @param array|string $variables an associatives array of variable names and values, or a
291 294
      *                                     variable name if you wish to sahre only one
292 295
      * @param mixed        $value          if you pass an array as first argument, the second
293 296
      *                                     argument will be ignored, else it will used as the
Please login to merge, or discard this patch.
Indentation   +300 added lines, -300 removed lines patch added patch discarded remove patch
@@ -9,304 +9,304 @@
 block discarded – undo
9 9
  */
10 10
 class Jade extends Keywords
11 11
 {
12
-    /**
13
-     * @var string
14
-     */
15
-    protected $streamName = 'jade';
16
-
17
-    /**
18
-     * @var array
19
-     */
20
-    protected $options = array(
21
-        'allowMixedIndent'   => true,
22
-        'allowMixinOverride' => true,
23
-        'cache'              => null,
24
-        'classAttribute'     => null,
25
-        'customKeywords'     => array(),
26
-        'extension'          => array('.pug', '.jade'),
27
-        'filterAutoLoad'     => true,
28
-        'indentChar'         => ' ',
29
-        'indentSize'         => 2,
30
-        'keepBaseName'       => false,
31
-        'keepNullAttributes' => false,
32
-        'phpSingleLine'      => false,
33
-        'postRender'         => null,
34
-        'preRender'          => null,
35
-        'prettyprint'        => false,
36
-        'restrictedScope'    => false,
37
-        'singleQuote'        => false,
38
-        'stream'             => null,
39
-        'upToDateCheck'      => true,
40
-    );
41
-
42
-    /**
43
-     * Built-in filters.
44
-     *
45
-     * @var array
46
-     */
47
-    protected $filters = array(
48
-        'php'        => 'Jade\Filter\Php',
49
-        'css'        => 'Jade\Filter\Css',
50
-        'cdata'      => 'Jade\Filter\Cdata',
51
-        'escaped'    => 'Jade\Filter\Escaped',
52
-        'javascript' => 'Jade\Filter\Javascript',
53
-    );
54
-
55
-    /**
56
-     * @var array
57
-     */
58
-    protected $sharedVariables = array();
59
-
60
-    /**
61
-     * Merge local options with constructor $options.
62
-     *
63
-     * @param array $options
64
-     */
65
-    public function __construct(array $options = array())
66
-    {
67
-        if (is_null($this->options['stream'])) {
68
-            $this->options['stream'] = $this->streamName . '.stream';
69
-        }
70
-        $this->options = array_merge($this->options, $options);
71
-    }
72
-
73
-    /**
74
-     * Returns true if suhosin extension is loaded and the stream name
75
-     * is missing in the executor include whitelist.
76
-     * Returns false in any other case.
77
-     *
78
-     * @return bool
79
-     */
80
-    protected function whiteListNeeded($extension)
81
-    {
82
-        return extension_loaded($extension) &&
83
-            false === strpos(
84
-                ini_get($extension . '.executor.include.whitelist'),
85
-                $this->options['stream']
86
-            );
87
-    }
88
-
89
-    /**
90
-     * Returns list of requirements in an array identified by keys.
91
-     * For each of them, the value can be true if the requirement is
92
-     * fullfilled, false else.
93
-     *
94
-     * If a requirement name is specified, returns only the matching
95
-     * boolean value for this requirement.
96
-     *
97
-     * @param string name
98
-     *
99
-     * @throws \InvalidArgumentException
100
-     *
101
-     * @return array|bool
102
-     */
103
-    public function requirements($name = null)
104
-    {
105
-        $requirements = array(
106
-            'streamWhiteListed' => !$this->whiteListNeeded('suhosin'),
107
-            'cacheFolderExists' => $this->options['cache'] && is_dir($this->options['cache']),
108
-            'cacheFolderIsWritable' => $this->options['cache'] && is_writable($this->options['cache']),
109
-        );
110
-
111
-        if ($name) {
112
-            if (!isset($requirements[$name])) {
113
-                throw new \InvalidArgumentException($name . ' is not in the requirements list (' . implode(', ', array_keys($requirements)) . ')', 19);
114
-            }
115
-
116
-            return $requirements[$name];
117
-        }
118
-
119
-        return $requirements;
120
-    }
121
-
122
-    /**
123
-     * Get standard or custom option, return the previously setted value or the default value else.
124
-     *
125
-     * Throw a invalid argument exception if the option does not exists.
126
-     *
127
-     * @param string name
128
-     *
129
-     * @throws \InvalidArgumentException
130
-     */
131
-    public function getOption($name)
132
-    {
133
-        if (!array_key_exists($name, $this->options)) {
134
-            throw new \InvalidArgumentException("$name is not a valid option name.", 2);
135
-        }
136
-
137
-        return $this->options[$name];
138
-    }
139
-
140
-    /**
141
-     * Set one standard option (listed in $this->options).
142
-     *
143
-     * @param string name
144
-     * @param mixed option value
145
-     *
146
-     * @throws \InvalidArgumentException
147
-     *
148
-     * @return $this
149
-     */
150
-    public function setOption($name, $value)
151
-    {
152
-        if (!array_key_exists($name, $this->options)) {
153
-            throw new \InvalidArgumentException("$name is not a valid option name.", 3);
154
-        }
155
-
156
-        $this->options[$name] = $value;
157
-
158
-        return $this;
159
-    }
160
-
161
-    /**
162
-     * Set multiple standard options.
163
-     *
164
-     * @param array option list
165
-     *
166
-     * @throws \InvalidArgumentException
167
-     *
168
-     * @return $this
169
-     */
170
-    public function setOptions($options)
171
-    {
172
-        foreach ($options as $name => $value) {
173
-            $this->setOption($name, $value);
174
-        }
175
-
176
-        return $this;
177
-    }
178
-
179
-    /**
180
-     * Set one custom option.
181
-     *
182
-     * @param string name
183
-     * @param mixed option value
184
-     *
185
-     * @return $this
186
-     */
187
-    public function setCustomOption($name, $value)
188
-    {
189
-        $this->options[$name] = $value;
190
-
191
-        return $this;
192
-    }
193
-
194
-    /**
195
-     * Set multiple custom options.
196
-     *
197
-     * @param array options list
198
-     *
199
-     * @return $this
200
-     */
201
-    public function setCustomOptions(array $options)
202
-    {
203
-        $this->options = array_merge($this->options, $options);
204
-
205
-        return $this;
206
-    }
207
-
208
-    /**
209
-     * Compile PHP code from a Pug input or a Pug file.
210
-     *
211
-     * @param string input
212
-     *
213
-     * @throws \Exception
214
-     *
215
-     * @return string
216
-     */
217
-    public function compile($input)
218
-    {
219
-        $parser = new Parser($input, null, $this->options);
220
-        $compiler = new Compiler($this->options, $this->filters, $parser->getFilename());
221
-        $php = $compiler->compile($parser->parse());
222
-        if (version_compare(PHP_VERSION, '7.0.0') < 0) {
223
-            $php = preg_replace_callback('/(' . preg_quote('\\Jade\\Compiler::getPropertyFromAnything', '/') . '\\(((?>[^()]+)|(?-2))*\\))[ \t]*(\\(((?>[^()]+)|(?-2))*\\))/', function ($match) {
224
-                return 'call_user_func(' . $match[1] . ', ' . $match[4] . ')';
225
-            }, $php);
226
-        }
227
-        $postRender = $this->getOption('postRender');
228
-        if (is_callable($postRender)) {
229
-            $php = call_user_func($postRender, $php);
230
-        }
231
-
232
-        return $php;
233
-    }
234
-
235
-    /**
236
-     * Compile HTML code from a Pug input or a Pug file.
237
-     *
238
-     * @param sring Pug input or file
239
-     * @param array vars to pass to the view
240
-     *
241
-     * @throws \Exception
242
-     *
243
-     * @return string
244
-     */
245
-    public function render($input, array $vars = array())
246
-    {
247
-        $file = $this->options['cache']
248
-            ? $this->cache($input)
249
-            : $this->stream($this->compile($input));
250
-
251
-        extract(array_merge($this->sharedVariables, $vars));
252
-        ob_start();
253
-        try {
254
-            include $file;
255
-        } catch (\Exception $e) {
256
-            ob_end_clean();
257
-            throw $e;
258
-        }
259
-
260
-        return ob_get_clean();
261
-    }
262
-
263
-    /**
264
-     * Create a stream wrapper to allow
265
-     * the possibility to add $scope variables.
266
-     *
267
-     * @param string input
268
-     *
269
-     * @throws \ErrorException
270
-     *
271
-     * @return string
272
-     */
273
-    public function stream($input)
274
-    {
275
-        if ($this->whiteListNeeded('suhosin')) {
276
-            throw new \ErrorException('To run Pug.php on the fly, add "' . $this->options['stream'] . '" to the "suhosin.executor.include.whitelist" settings in your php.ini file.', 4);
277
-        }
278
-
279
-        if (!in_array($this->options['stream'], stream_get_wrappers())) {
280
-            stream_wrapper_register($this->options['stream'], 'Jade\Stream\Template');
281
-        }
282
-
283
-        return $this->options['stream'] . '://data;' . $input;
284
-    }
285
-
286
-    /**
287
-     * Add a variable or an array of variables to be shared with all templates that will be rendered
288
-     * by the instance of Pug.
289
-     *
290
-     * @param array|string $variables|$key an associatives array of variable names and values, or a
291
-     *                                     variable name if you wish to sahre only one
292
-     * @param mixed        $value          if you pass an array as first argument, the second
293
-     *                                     argument will be ignored, else it will used as the
294
-     *                                     variable value for the variable name you passed as first
295
-     *                                     argument
296
-     */
297
-    public function share($variables, $value = null)
298
-    {
299
-        if (!is_array($variables)) {
300
-            $variables = array(strval($variables) => $value);
301
-        }
302
-        $this->sharedVariables = array_merge($this->sharedVariables, $variables);
303
-    }
304
-
305
-    /**
306
-     * Remove all previously set shared variables.
307
-     */
308
-    public function resetSharedVariables()
309
-    {
310
-        $this->sharedVariables = array();
311
-    }
12
+	/**
13
+	 * @var string
14
+	 */
15
+	protected $streamName = 'jade';
16
+
17
+	/**
18
+	 * @var array
19
+	 */
20
+	protected $options = array(
21
+		'allowMixedIndent'   => true,
22
+		'allowMixinOverride' => true,
23
+		'cache'              => null,
24
+		'classAttribute'     => null,
25
+		'customKeywords'     => array(),
26
+		'extension'          => array('.pug', '.jade'),
27
+		'filterAutoLoad'     => true,
28
+		'indentChar'         => ' ',
29
+		'indentSize'         => 2,
30
+		'keepBaseName'       => false,
31
+		'keepNullAttributes' => false,
32
+		'phpSingleLine'      => false,
33
+		'postRender'         => null,
34
+		'preRender'          => null,
35
+		'prettyprint'        => false,
36
+		'restrictedScope'    => false,
37
+		'singleQuote'        => false,
38
+		'stream'             => null,
39
+		'upToDateCheck'      => true,
40
+	);
41
+
42
+	/**
43
+	 * Built-in filters.
44
+	 *
45
+	 * @var array
46
+	 */
47
+	protected $filters = array(
48
+		'php'        => 'Jade\Filter\Php',
49
+		'css'        => 'Jade\Filter\Css',
50
+		'cdata'      => 'Jade\Filter\Cdata',
51
+		'escaped'    => 'Jade\Filter\Escaped',
52
+		'javascript' => 'Jade\Filter\Javascript',
53
+	);
54
+
55
+	/**
56
+	 * @var array
57
+	 */
58
+	protected $sharedVariables = array();
59
+
60
+	/**
61
+	 * Merge local options with constructor $options.
62
+	 *
63
+	 * @param array $options
64
+	 */
65
+	public function __construct(array $options = array())
66
+	{
67
+		if (is_null($this->options['stream'])) {
68
+			$this->options['stream'] = $this->streamName . '.stream';
69
+		}
70
+		$this->options = array_merge($this->options, $options);
71
+	}
72
+
73
+	/**
74
+	 * Returns true if suhosin extension is loaded and the stream name
75
+	 * is missing in the executor include whitelist.
76
+	 * Returns false in any other case.
77
+	 *
78
+	 * @return bool
79
+	 */
80
+	protected function whiteListNeeded($extension)
81
+	{
82
+		return extension_loaded($extension) &&
83
+			false === strpos(
84
+				ini_get($extension . '.executor.include.whitelist'),
85
+				$this->options['stream']
86
+			);
87
+	}
88
+
89
+	/**
90
+	 * Returns list of requirements in an array identified by keys.
91
+	 * For each of them, the value can be true if the requirement is
92
+	 * fullfilled, false else.
93
+	 *
94
+	 * If a requirement name is specified, returns only the matching
95
+	 * boolean value for this requirement.
96
+	 *
97
+	 * @param string name
98
+	 *
99
+	 * @throws \InvalidArgumentException
100
+	 *
101
+	 * @return array|bool
102
+	 */
103
+	public function requirements($name = null)
104
+	{
105
+		$requirements = array(
106
+			'streamWhiteListed' => !$this->whiteListNeeded('suhosin'),
107
+			'cacheFolderExists' => $this->options['cache'] && is_dir($this->options['cache']),
108
+			'cacheFolderIsWritable' => $this->options['cache'] && is_writable($this->options['cache']),
109
+		);
110
+
111
+		if ($name) {
112
+			if (!isset($requirements[$name])) {
113
+				throw new \InvalidArgumentException($name . ' is not in the requirements list (' . implode(', ', array_keys($requirements)) . ')', 19);
114
+			}
115
+
116
+			return $requirements[$name];
117
+		}
118
+
119
+		return $requirements;
120
+	}
121
+
122
+	/**
123
+	 * Get standard or custom option, return the previously setted value or the default value else.
124
+	 *
125
+	 * Throw a invalid argument exception if the option does not exists.
126
+	 *
127
+	 * @param string name
128
+	 *
129
+	 * @throws \InvalidArgumentException
130
+	 */
131
+	public function getOption($name)
132
+	{
133
+		if (!array_key_exists($name, $this->options)) {
134
+			throw new \InvalidArgumentException("$name is not a valid option name.", 2);
135
+		}
136
+
137
+		return $this->options[$name];
138
+	}
139
+
140
+	/**
141
+	 * Set one standard option (listed in $this->options).
142
+	 *
143
+	 * @param string name
144
+	 * @param mixed option value
145
+	 *
146
+	 * @throws \InvalidArgumentException
147
+	 *
148
+	 * @return $this
149
+	 */
150
+	public function setOption($name, $value)
151
+	{
152
+		if (!array_key_exists($name, $this->options)) {
153
+			throw new \InvalidArgumentException("$name is not a valid option name.", 3);
154
+		}
155
+
156
+		$this->options[$name] = $value;
157
+
158
+		return $this;
159
+	}
160
+
161
+	/**
162
+	 * Set multiple standard options.
163
+	 *
164
+	 * @param array option list
165
+	 *
166
+	 * @throws \InvalidArgumentException
167
+	 *
168
+	 * @return $this
169
+	 */
170
+	public function setOptions($options)
171
+	{
172
+		foreach ($options as $name => $value) {
173
+			$this->setOption($name, $value);
174
+		}
175
+
176
+		return $this;
177
+	}
178
+
179
+	/**
180
+	 * Set one custom option.
181
+	 *
182
+	 * @param string name
183
+	 * @param mixed option value
184
+	 *
185
+	 * @return $this
186
+	 */
187
+	public function setCustomOption($name, $value)
188
+	{
189
+		$this->options[$name] = $value;
190
+
191
+		return $this;
192
+	}
193
+
194
+	/**
195
+	 * Set multiple custom options.
196
+	 *
197
+	 * @param array options list
198
+	 *
199
+	 * @return $this
200
+	 */
201
+	public function setCustomOptions(array $options)
202
+	{
203
+		$this->options = array_merge($this->options, $options);
204
+
205
+		return $this;
206
+	}
207
+
208
+	/**
209
+	 * Compile PHP code from a Pug input or a Pug file.
210
+	 *
211
+	 * @param string input
212
+	 *
213
+	 * @throws \Exception
214
+	 *
215
+	 * @return string
216
+	 */
217
+	public function compile($input)
218
+	{
219
+		$parser = new Parser($input, null, $this->options);
220
+		$compiler = new Compiler($this->options, $this->filters, $parser->getFilename());
221
+		$php = $compiler->compile($parser->parse());
222
+		if (version_compare(PHP_VERSION, '7.0.0') < 0) {
223
+			$php = preg_replace_callback('/(' . preg_quote('\\Jade\\Compiler::getPropertyFromAnything', '/') . '\\(((?>[^()]+)|(?-2))*\\))[ \t]*(\\(((?>[^()]+)|(?-2))*\\))/', function ($match) {
224
+				return 'call_user_func(' . $match[1] . ', ' . $match[4] . ')';
225
+			}, $php);
226
+		}
227
+		$postRender = $this->getOption('postRender');
228
+		if (is_callable($postRender)) {
229
+			$php = call_user_func($postRender, $php);
230
+		}
231
+
232
+		return $php;
233
+	}
234
+
235
+	/**
236
+	 * Compile HTML code from a Pug input or a Pug file.
237
+	 *
238
+	 * @param sring Pug input or file
239
+	 * @param array vars to pass to the view
240
+	 *
241
+	 * @throws \Exception
242
+	 *
243
+	 * @return string
244
+	 */
245
+	public function render($input, array $vars = array())
246
+	{
247
+		$file = $this->options['cache']
248
+			? $this->cache($input)
249
+			: $this->stream($this->compile($input));
250
+
251
+		extract(array_merge($this->sharedVariables, $vars));
252
+		ob_start();
253
+		try {
254
+			include $file;
255
+		} catch (\Exception $e) {
256
+			ob_end_clean();
257
+			throw $e;
258
+		}
259
+
260
+		return ob_get_clean();
261
+	}
262
+
263
+	/**
264
+	 * Create a stream wrapper to allow
265
+	 * the possibility to add $scope variables.
266
+	 *
267
+	 * @param string input
268
+	 *
269
+	 * @throws \ErrorException
270
+	 *
271
+	 * @return string
272
+	 */
273
+	public function stream($input)
274
+	{
275
+		if ($this->whiteListNeeded('suhosin')) {
276
+			throw new \ErrorException('To run Pug.php on the fly, add "' . $this->options['stream'] . '" to the "suhosin.executor.include.whitelist" settings in your php.ini file.', 4);
277
+		}
278
+
279
+		if (!in_array($this->options['stream'], stream_get_wrappers())) {
280
+			stream_wrapper_register($this->options['stream'], 'Jade\Stream\Template');
281
+		}
282
+
283
+		return $this->options['stream'] . '://data;' . $input;
284
+	}
285
+
286
+	/**
287
+	 * Add a variable or an array of variables to be shared with all templates that will be rendered
288
+	 * by the instance of Pug.
289
+	 *
290
+	 * @param array|string $variables|$key an associatives array of variable names and values, or a
291
+	 *                                     variable name if you wish to sahre only one
292
+	 * @param mixed        $value          if you pass an array as first argument, the second
293
+	 *                                     argument will be ignored, else it will used as the
294
+	 *                                     variable value for the variable name you passed as first
295
+	 *                                     argument
296
+	 */
297
+	public function share($variables, $value = null)
298
+	{
299
+		if (!is_array($variables)) {
300
+			$variables = array(strval($variables) => $value);
301
+		}
302
+		$this->sharedVariables = array_merge($this->sharedVariables, $variables);
303
+	}
304
+
305
+	/**
306
+	 * Remove all previously set shared variables.
307
+	 */
308
+	public function resetSharedVariables()
309
+	{
310
+		$this->sharedVariables = array();
311
+	}
312 312
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     public function __construct(array $options = array())
66 66
     {
67 67
         if (is_null($this->options['stream'])) {
68
-            $this->options['stream'] = $this->streamName . '.stream';
68
+            $this->options['stream'] = $this->streamName.'.stream';
69 69
         }
70 70
         $this->options = array_merge($this->options, $options);
71 71
     }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     {
82 82
         return extension_loaded($extension) &&
83 83
             false === strpos(
84
-                ini_get($extension . '.executor.include.whitelist'),
84
+                ini_get($extension.'.executor.include.whitelist'),
85 85
                 $this->options['stream']
86 86
             );
87 87
     }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
         if ($name) {
112 112
             if (!isset($requirements[$name])) {
113
-                throw new \InvalidArgumentException($name . ' is not in the requirements list (' . implode(', ', array_keys($requirements)) . ')', 19);
113
+                throw new \InvalidArgumentException($name.' is not in the requirements list ('.implode(', ', array_keys($requirements)).')', 19);
114 114
             }
115 115
 
116 116
             return $requirements[$name];
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
         $compiler = new Compiler($this->options, $this->filters, $parser->getFilename());
221 221
         $php = $compiler->compile($parser->parse());
222 222
         if (version_compare(PHP_VERSION, '7.0.0') < 0) {
223
-            $php = preg_replace_callback('/(' . preg_quote('\\Jade\\Compiler::getPropertyFromAnything', '/') . '\\(((?>[^()]+)|(?-2))*\\))[ \t]*(\\(((?>[^()]+)|(?-2))*\\))/', function ($match) {
224
-                return 'call_user_func(' . $match[1] . ', ' . $match[4] . ')';
223
+            $php = preg_replace_callback('/('.preg_quote('\\Jade\\Compiler::getPropertyFromAnything', '/').'\\(((?>[^()]+)|(?-2))*\\))[ \t]*(\\(((?>[^()]+)|(?-2))*\\))/', function($match) {
224
+                return 'call_user_func('.$match[1].', '.$match[4].')';
225 225
             }, $php);
226 226
         }
227 227
         $postRender = $this->getOption('postRender');
@@ -273,14 +273,14 @@  discard block
 block discarded – undo
273 273
     public function stream($input)
274 274
     {
275 275
         if ($this->whiteListNeeded('suhosin')) {
276
-            throw new \ErrorException('To run Pug.php on the fly, add "' . $this->options['stream'] . '" to the "suhosin.executor.include.whitelist" settings in your php.ini file.', 4);
276
+            throw new \ErrorException('To run Pug.php on the fly, add "'.$this->options['stream'].'" to the "suhosin.executor.include.whitelist" settings in your php.ini file.', 4);
277 277
         }
278 278
 
279 279
         if (!in_array($this->options['stream'], stream_get_wrappers())) {
280 280
             stream_wrapper_register($this->options['stream'], 'Jade\Stream\Template');
281 281
         }
282 282
 
283
-        return $this->options['stream'] . '://data;' . $input;
283
+        return $this->options['stream'].'://data;'.$input;
284 284
     }
285 285
 
286 286
     /**
Please login to merge, or discard this patch.
jate/modules/ExternalModules/pug-php/pug/src/Jade/Lexer/InputHandler.php 3 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     }
51 51
 
52 52
     /**
53
-     * @param $code
53
+     * @param string $code
54 54
      *
55 55
      * @return string
56 56
      */
@@ -112,6 +112,10 @@  discard block
 block discarded – undo
112 112
         return $this->token('newline');
113 113
     }
114 114
 
115
+    /**
116
+     * @param string $firstChar
117
+     * @param integer $indents
118
+     */
115 119
     protected function getTokenFromIndent($firstChar, $indents)
116 120
     {
117 121
         if ($this->length() && $firstChar === "\n") {
Please login to merge, or discard this patch.
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -7,126 +7,126 @@
 block discarded – undo
7 7
  */
8 8
 abstract class InputHandler
9 9
 {
10
-    /**
11
-     * @var string
12
-     */
13
-    public $input;
14
-
15
-    /**
16
-     * @var array
17
-     */
18
-    protected $deferred = array();
19
-
20
-    /**
21
-     * @var array
22
-     */
23
-    protected $indentStack = array();
24
-
25
-    /**
26
-     * @var array
27
-     */
28
-    protected $stash = array();
29
-
30
-    /**
31
-     * Set lexer input.
32
-     *
33
-     * @param string $input input string
34
-     */
35
-    public function setInput($input)
36
-    {
37
-        $this->input = preg_replace("/\r\n|\r/", "\n", $input);
38
-        $this->lineno = 1;
39
-        $this->deferred = array();
40
-        $this->indentStack = array();
41
-        $this->stash = array();
42
-    }
43
-
44
-    /**
45
-     * @return int
46
-     */
47
-    public function length()
48
-    {
49
-        return strlen($this->input);
50
-    }
51
-
52
-    /**
53
-     * @param $code
54
-     *
55
-     * @return string
56
-     */
57
-    protected function normalizeCode($code)
58
-    {
59
-        return $code = (substr($code, -1) === ':' && substr($code, -2, 1) !== ':')
60
-            ? substr($code, 0, -1)
61
-            : $code;
62
-    }
63
-
64
-    protected function testIndent($indent)
65
-    {
66
-        if (!preg_match('/^' . $indent . '/', substr($this->input, 1), $matches)) {
67
-            return;
68
-        }
69
-
70
-        if (!isset($this->identRE)) {
71
-            $this->identRE = $indent;
72
-        }
73
-
74
-        return array(
75
-            "\n" . $matches[0],
76
-            $matches[0],
77
-        );
78
-    }
79
-
80
-    protected function getNextIndent()
81
-    {
82
-        if (substr($this->input, 0, 1) !== "\n") {
83
-            return;
84
-        }
85
-
86
-        $indents = isset($this->identRE)
87
-            ? array($this->identRE)
88
-            : ($this->allowMixedIndent
89
-                ? array('[\\t ]*')
90
-                : array('\\t+', ' *')
91
-            );
92
-
93
-        foreach ($indents as $indent) {
94
-            if ($matches = $this->testIndent($indent)) {
95
-                return $matches;
96
-            }
97
-        }
98
-    }
99
-
100
-    protected function getWhiteSpacesTokens($indents)
101
-    {
102
-        if ($indents && count($this->indentStack) && $indents === $this->indentStack[0]) {
103
-            return $this->token('newline');
104
-        }
105
-
106
-        if ($indents) {
107
-            array_unshift($this->indentStack, $indents);
108
-
109
-            return $this->token('indent', $indents);
110
-        }
111
-
112
-        return $this->token('newline');
113
-    }
114
-
115
-    protected function getTokenFromIndent($firstChar, $indents)
116
-    {
117
-        if ($this->length() && $firstChar === "\n") {
118
-            return $this->token('newline');
119
-        }
120
-
121
-        if (count($this->indentStack) && $indents < $this->indentStack[0]) {
122
-            while (count($this->indentStack) && $indents < $this->indentStack[0]) {
123
-                array_push($this->stash, $this->token('outdent'));
124
-                array_shift($this->indentStack);
125
-            }
126
-
127
-            return array_pop($this->stash);
128
-        }
129
-
130
-        return $this->getWhiteSpacesTokens($indents);
131
-    }
10
+	/**
11
+	 * @var string
12
+	 */
13
+	public $input;
14
+
15
+	/**
16
+	 * @var array
17
+	 */
18
+	protected $deferred = array();
19
+
20
+	/**
21
+	 * @var array
22
+	 */
23
+	protected $indentStack = array();
24
+
25
+	/**
26
+	 * @var array
27
+	 */
28
+	protected $stash = array();
29
+
30
+	/**
31
+	 * Set lexer input.
32
+	 *
33
+	 * @param string $input input string
34
+	 */
35
+	public function setInput($input)
36
+	{
37
+		$this->input = preg_replace("/\r\n|\r/", "\n", $input);
38
+		$this->lineno = 1;
39
+		$this->deferred = array();
40
+		$this->indentStack = array();
41
+		$this->stash = array();
42
+	}
43
+
44
+	/**
45
+	 * @return int
46
+	 */
47
+	public function length()
48
+	{
49
+		return strlen($this->input);
50
+	}
51
+
52
+	/**
53
+	 * @param $code
54
+	 *
55
+	 * @return string
56
+	 */
57
+	protected function normalizeCode($code)
58
+	{
59
+		return $code = (substr($code, -1) === ':' && substr($code, -2, 1) !== ':')
60
+			? substr($code, 0, -1)
61
+			: $code;
62
+	}
63
+
64
+	protected function testIndent($indent)
65
+	{
66
+		if (!preg_match('/^' . $indent . '/', substr($this->input, 1), $matches)) {
67
+			return;
68
+		}
69
+
70
+		if (!isset($this->identRE)) {
71
+			$this->identRE = $indent;
72
+		}
73
+
74
+		return array(
75
+			"\n" . $matches[0],
76
+			$matches[0],
77
+		);
78
+	}
79
+
80
+	protected function getNextIndent()
81
+	{
82
+		if (substr($this->input, 0, 1) !== "\n") {
83
+			return;
84
+		}
85
+
86
+		$indents = isset($this->identRE)
87
+			? array($this->identRE)
88
+			: ($this->allowMixedIndent
89
+				? array('[\\t ]*')
90
+				: array('\\t+', ' *')
91
+			);
92
+
93
+		foreach ($indents as $indent) {
94
+			if ($matches = $this->testIndent($indent)) {
95
+				return $matches;
96
+			}
97
+		}
98
+	}
99
+
100
+	protected function getWhiteSpacesTokens($indents)
101
+	{
102
+		if ($indents && count($this->indentStack) && $indents === $this->indentStack[0]) {
103
+			return $this->token('newline');
104
+		}
105
+
106
+		if ($indents) {
107
+			array_unshift($this->indentStack, $indents);
108
+
109
+			return $this->token('indent', $indents);
110
+		}
111
+
112
+		return $this->token('newline');
113
+	}
114
+
115
+	protected function getTokenFromIndent($firstChar, $indents)
116
+	{
117
+		if ($this->length() && $firstChar === "\n") {
118
+			return $this->token('newline');
119
+		}
120
+
121
+		if (count($this->indentStack) && $indents < $this->indentStack[0]) {
122
+			while (count($this->indentStack) && $indents < $this->indentStack[0]) {
123
+				array_push($this->stash, $this->token('outdent'));
124
+				array_shift($this->indentStack);
125
+			}
126
+
127
+			return array_pop($this->stash);
128
+		}
129
+
130
+		return $this->getWhiteSpacesTokens($indents);
131
+	}
132 132
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
     protected function testIndent($indent)
65 65
     {
66
-        if (!preg_match('/^' . $indent . '/', substr($this->input, 1), $matches)) {
66
+        if (!preg_match('/^'.$indent.'/', substr($this->input, 1), $matches)) {
67 67
             return;
68 68
         }
69 69
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         }
73 73
 
74 74
         return array(
75
-            "\n" . $matches[0],
75
+            "\n".$matches[0],
76 76
             $matches[0],
77 77
         );
78 78
     }
Please login to merge, or discard this patch.