Passed
Push — master ( 020752...f1625c )
by David
05:47 queued 02:32
created
lib/Dwoo/Compilation/Exception.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -26,35 +26,35 @@
 block discarded – undo
26 26
  */
27 27
 class Exception extends DwooException
28 28
 {
29
-    protected $compiler;
30
-    protected $template;
29
+	protected $compiler;
30
+	protected $template;
31 31
 
32
-    /**
33
-     * Exception constructor.
34
-     *
35
-     * @param DwooCompiler $compiler
36
-     * @param int          $message
37
-     */
38
-    public function __construct(DwooCompiler $compiler, $message)
39
-    {
40
-        $this->compiler = $compiler;
41
-        $this->template = $compiler->getCore()->getTemplate();
42
-        parent::__construct('Compilation error at line ' . $compiler->getLine() . ' in "' . $this->template->getResourceName() . ':' . $this->template->getResourceIdentifier() . '" : ' . $message);
43
-    }
32
+	/**
33
+	 * Exception constructor.
34
+	 *
35
+	 * @param DwooCompiler $compiler
36
+	 * @param int          $message
37
+	 */
38
+	public function __construct(DwooCompiler $compiler, $message)
39
+	{
40
+		$this->compiler = $compiler;
41
+		$this->template = $compiler->getCore()->getTemplate();
42
+		parent::__construct('Compilation error at line ' . $compiler->getLine() . ' in "' . $this->template->getResourceName() . ':' . $this->template->getResourceIdentifier() . '" : ' . $message);
43
+	}
44 44
 
45
-    /**
46
-     * @return DwooCompiler
47
-     */
48
-    public function getCompiler()
49
-    {
50
-        return $this->compiler;
51
-    }
45
+	/**
46
+	 * @return DwooCompiler
47
+	 */
48
+	public function getCompiler()
49
+	{
50
+		return $this->compiler;
51
+	}
52 52
 
53
-    /**
54
-     * @return \Dwoo\ITemplate|null
55
-     */
56
-    public function getTemplate()
57
-    {
58
-        return $this->template;
59
-    }
53
+	/**
54
+	 * @return \Dwoo\ITemplate|null
55
+	 */
56
+	public function getTemplate()
57
+	{
58
+		return $this->template;
59
+	}
60 60
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
     {
40 40
         $this->compiler = $compiler;
41 41
         $this->template = $compiler->getCore()->getTemplate();
42
-        parent::__construct('Compilation error at line ' . $compiler->getLine() . ' in "' . $this->template->getResourceName() . ':' . $this->template->getResourceIdentifier() . '" : ' . $message);
42
+        parent::__construct('Compilation error at line '.$compiler->getLine().' in "'.$this->template->getResourceName().':'.$this->template->getResourceIdentifier().'" : '.$message);
43 43
     }
44 44
 
45 45
     /**
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginExtends.php 3 patches
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -34,28 +34,28 @@  discard block
 block discarded – undo
34 34
  */
35 35
 class PluginExtends extends Plugin implements ICompilable
36 36
 {
37
-    protected static $childSource;
38
-    protected static $regex;
39
-    protected static $l;
40
-    protected static $r;
41
-    protected static $lastReplacement;
42
-
43
-    public function process()
44
-    {
45
-    }
46
-
47
-    /**
48
-     * @param Compiler $compiler
49
-     * @param          $file
50
-     *
51
-     * @throws CompilationException
52
-     */
53
-    public static function compile(Compiler $compiler, $file)
54
-    {
55
-        list($l, $r) = $compiler->getDelimiters();
56
-        self::$l     = preg_quote($l, '/');
57
-        self::$r     = preg_quote($r, '/');
58
-        self::$regex = '/
37
+	protected static $childSource;
38
+	protected static $regex;
39
+	protected static $l;
40
+	protected static $r;
41
+	protected static $lastReplacement;
42
+
43
+	public function process()
44
+	{
45
+	}
46
+
47
+	/**
48
+	 * @param Compiler $compiler
49
+	 * @param          $file
50
+	 *
51
+	 * @throws CompilationException
52
+	 */
53
+	public static function compile(Compiler $compiler, $file)
54
+	{
55
+		list($l, $r) = $compiler->getDelimiters();
56
+		self::$l     = preg_quote($l, '/');
57
+		self::$r     = preg_quote($r, '/');
58
+		self::$regex = '/
59 59
 			' . self::$l . 'block\s(["\']?)(.+?)\1' . self::$r . '(?:\r?\n?)
60 60
 			((?:
61 61
 				(?R)
@@ -70,137 +70,137 @@  discard block
 block discarded – undo
70 70
 			' . self::$l . '\/block' . self::$r . '
71 71
 			/six';
72 72
 
73
-        if ($compiler->getLooseOpeningHandling()) {
74
-            self::$l .= '\s*';
75
-            self::$r = '\s*' . self::$r;
76
-        }
77
-        $inheritanceTree = array(array('source' => $compiler->getTemplateSource()));
78
-        $curPath         = dirname($compiler->getCore()->getTemplate()->getResourceIdentifier()) . DIRECTORY_SEPARATOR;
79
-        $curTpl          = $compiler->getCore()->getTemplate();
80
-
81
-        while (!empty($file)) {
82
-            if ($file === '""' || $file === "''" || (substr($file, 0, 1) !== '"' && substr($file, 0, 1) !== '\'')) {
83
-                throw new CompilationException($compiler, 'Extends : The file name must be a non-empty string');
84
-            }
85
-
86
-            if (preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m)) {
87
-                // resource:identifier given, extract them
88
-                $resource   = $m[1];
89
-                $identifier = $m[2];
90
-            } else {
91
-                // get the current template's resource
92
-                $resource   = $curTpl->getResourceName();
93
-                $identifier = substr($file, 1, - 1);
94
-            }
95
-
96
-            try {
97
-                $parent = $compiler->getCore()->templateFactory($resource, $identifier, null, null, null, $curTpl);
98
-            }
99
-            catch (SecurityException $e) {
100
-                throw new CompilationException($compiler, 'Extends : Security restriction : ' . $e->getMessage());
101
-            }
102
-            catch (Exception $e) {
103
-                throw new CompilationException($compiler, 'Extends : ' . $e->getMessage());
104
-            }
105
-
106
-            if ($parent === null) {
107
-                throw new CompilationException($compiler, 'Extends : Resource "' . $resource . ':' . $identifier . '" not found.');
108
-            } elseif ($parent === false) {
109
-                throw new CompilationException($compiler, 'Extends : Resource "' . $resource . '" does not support extends.');
110
-            }
111
-
112
-            $curTpl    = $parent;
113
-            $newParent = array(
114
-                'source'     => $parent->getSource(),
115
-                'resource'   => $resource,
116
-                'identifier' => $parent->getResourceIdentifier(),
117
-                'uid'        => $parent->getUid()
118
-            );
119
-            if (array_search($newParent, $inheritanceTree, true) !== false) {
120
-                throw new CompilationException($compiler, 'Extends : Recursive template inheritance detected');
121
-            }
122
-            $inheritanceTree[] = $newParent;
123
-
124
-            if (preg_match('/^' . self::$l . 'extends(?:\(?\s*|\s+)(?:file=)?\s*((["\']).+?\2|\S+?)\s*\)?\s*?' . self::$r . '/i', $parent->getSource(), $match)) {
125
-                $curPath = dirname($identifier) . DIRECTORY_SEPARATOR;
126
-                if (isset($match[2]) && $match[2] == '"') {
127
-                    $file = '"' . str_replace('"', '\\"', substr($match[1], 1, - 1)) . '"';
128
-                } elseif (isset($match[2]) && $match[2] == "'") {
129
-                    $file = '"' . substr($match[1], 1, - 1) . '"';
130
-                } else {
131
-                    $file = '"' . $match[1] . '"';
132
-                }
133
-            } else {
134
-                $file = false;
135
-            }
136
-        }
137
-
138
-        while (true) {
139
-            $parent                = array_pop($inheritanceTree);
140
-            $child                 = end($inheritanceTree);
141
-            self::$childSource     = $child['source'];
142
-            self::$lastReplacement = count($inheritanceTree) === 1;
143
-            if (!isset($newSource)) {
144
-                $newSource = $parent['source'];
145
-            }
146
-            $newSource = preg_replace_callback(self::$regex, array(
147
-                'Dwoo\Plugins\Functions\PluginExtends',
148
-                'replaceBlock'
149
-            ), $newSource);
150
-            $newSource = $l . 'do extendsCheck(' . var_export($parent['resource'] . ':' . $parent['identifier'], true) . ')' . $r . $newSource;
151
-
152
-            if (self::$lastReplacement) {
153
-                break;
154
-            }
155
-        }
156
-        $compiler->setTemplateSource($newSource);
157
-        $compiler->recompile();
158
-    }
159
-
160
-    /**
161
-     * @param array $matches
162
-     *
163
-     * @return mixed|string
164
-     */
165
-    protected static function replaceBlock(array $matches)
166
-    {
167
-        $matches[3] = self::removeTrailingNewline($matches[3]);
168
-
169
-        if (preg_match_all(self::$regex, self::$childSource, $override) && in_array($matches[2], $override[2])) {
170
-            $key      = array_search($matches[2], $override[2]);
171
-            $override = self::removeTrailingNewline($override[3][$key]);
172
-
173
-            $l = stripslashes(self::$l);
174
-            $r = stripslashes(self::$r);
175
-
176
-            if (self::$lastReplacement) {
177
-                return preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override);
178
-            }
179
-
180
-            return $l . 'block ' . $matches[1] . $matches[2] . $matches[1] . $r . preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override) . $l . '/block' . $r;
181
-        }
182
-
183
-        if (preg_match(self::$regex, $matches[3])) {
184
-            return preg_replace_callback(self::$regex, array(
185
-                'Dwoo\Plugins\Functions\PluginExtends',
186
-                'replaceBlock'
187
-            ), $matches[3]);
188
-        }
189
-
190
-        if (self::$lastReplacement) {
191
-            return $matches[3];
192
-        }
193
-
194
-        return $matches[0];
195
-    }
196
-
197
-    /**
198
-     * @param $text
199
-     *
200
-     * @return string
201
-     */
202
-    protected static function removeTrailingNewline($text)
203
-    {
204
-        return substr($text, - 1) === "\n" ? substr($text, - 2, 1) === "\r" ? substr($text, 0, - 2) : substr($text, 0, - 1) : $text;
205
-    }
73
+		if ($compiler->getLooseOpeningHandling()) {
74
+			self::$l .= '\s*';
75
+			self::$r = '\s*' . self::$r;
76
+		}
77
+		$inheritanceTree = array(array('source' => $compiler->getTemplateSource()));
78
+		$curPath         = dirname($compiler->getCore()->getTemplate()->getResourceIdentifier()) . DIRECTORY_SEPARATOR;
79
+		$curTpl          = $compiler->getCore()->getTemplate();
80
+
81
+		while (!empty($file)) {
82
+			if ($file === '""' || $file === "''" || (substr($file, 0, 1) !== '"' && substr($file, 0, 1) !== '\'')) {
83
+				throw new CompilationException($compiler, 'Extends : The file name must be a non-empty string');
84
+			}
85
+
86
+			if (preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m)) {
87
+				// resource:identifier given, extract them
88
+				$resource   = $m[1];
89
+				$identifier = $m[2];
90
+			} else {
91
+				// get the current template's resource
92
+				$resource   = $curTpl->getResourceName();
93
+				$identifier = substr($file, 1, - 1);
94
+			}
95
+
96
+			try {
97
+				$parent = $compiler->getCore()->templateFactory($resource, $identifier, null, null, null, $curTpl);
98
+			}
99
+			catch (SecurityException $e) {
100
+				throw new CompilationException($compiler, 'Extends : Security restriction : ' . $e->getMessage());
101
+			}
102
+			catch (Exception $e) {
103
+				throw new CompilationException($compiler, 'Extends : ' . $e->getMessage());
104
+			}
105
+
106
+			if ($parent === null) {
107
+				throw new CompilationException($compiler, 'Extends : Resource "' . $resource . ':' . $identifier . '" not found.');
108
+			} elseif ($parent === false) {
109
+				throw new CompilationException($compiler, 'Extends : Resource "' . $resource . '" does not support extends.');
110
+			}
111
+
112
+			$curTpl    = $parent;
113
+			$newParent = array(
114
+				'source'     => $parent->getSource(),
115
+				'resource'   => $resource,
116
+				'identifier' => $parent->getResourceIdentifier(),
117
+				'uid'        => $parent->getUid()
118
+			);
119
+			if (array_search($newParent, $inheritanceTree, true) !== false) {
120
+				throw new CompilationException($compiler, 'Extends : Recursive template inheritance detected');
121
+			}
122
+			$inheritanceTree[] = $newParent;
123
+
124
+			if (preg_match('/^' . self::$l . 'extends(?:\(?\s*|\s+)(?:file=)?\s*((["\']).+?\2|\S+?)\s*\)?\s*?' . self::$r . '/i', $parent->getSource(), $match)) {
125
+				$curPath = dirname($identifier) . DIRECTORY_SEPARATOR;
126
+				if (isset($match[2]) && $match[2] == '"') {
127
+					$file = '"' . str_replace('"', '\\"', substr($match[1], 1, - 1)) . '"';
128
+				} elseif (isset($match[2]) && $match[2] == "'") {
129
+					$file = '"' . substr($match[1], 1, - 1) . '"';
130
+				} else {
131
+					$file = '"' . $match[1] . '"';
132
+				}
133
+			} else {
134
+				$file = false;
135
+			}
136
+		}
137
+
138
+		while (true) {
139
+			$parent                = array_pop($inheritanceTree);
140
+			$child                 = end($inheritanceTree);
141
+			self::$childSource     = $child['source'];
142
+			self::$lastReplacement = count($inheritanceTree) === 1;
143
+			if (!isset($newSource)) {
144
+				$newSource = $parent['source'];
145
+			}
146
+			$newSource = preg_replace_callback(self::$regex, array(
147
+				'Dwoo\Plugins\Functions\PluginExtends',
148
+				'replaceBlock'
149
+			), $newSource);
150
+			$newSource = $l . 'do extendsCheck(' . var_export($parent['resource'] . ':' . $parent['identifier'], true) . ')' . $r . $newSource;
151
+
152
+			if (self::$lastReplacement) {
153
+				break;
154
+			}
155
+		}
156
+		$compiler->setTemplateSource($newSource);
157
+		$compiler->recompile();
158
+	}
159
+
160
+	/**
161
+	 * @param array $matches
162
+	 *
163
+	 * @return mixed|string
164
+	 */
165
+	protected static function replaceBlock(array $matches)
166
+	{
167
+		$matches[3] = self::removeTrailingNewline($matches[3]);
168
+
169
+		if (preg_match_all(self::$regex, self::$childSource, $override) && in_array($matches[2], $override[2])) {
170
+			$key      = array_search($matches[2], $override[2]);
171
+			$override = self::removeTrailingNewline($override[3][$key]);
172
+
173
+			$l = stripslashes(self::$l);
174
+			$r = stripslashes(self::$r);
175
+
176
+			if (self::$lastReplacement) {
177
+				return preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override);
178
+			}
179
+
180
+			return $l . 'block ' . $matches[1] . $matches[2] . $matches[1] . $r . preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override) . $l . '/block' . $r;
181
+		}
182
+
183
+		if (preg_match(self::$regex, $matches[3])) {
184
+			return preg_replace_callback(self::$regex, array(
185
+				'Dwoo\Plugins\Functions\PluginExtends',
186
+				'replaceBlock'
187
+			), $matches[3]);
188
+		}
189
+
190
+		if (self::$lastReplacement) {
191
+			return $matches[3];
192
+		}
193
+
194
+		return $matches[0];
195
+	}
196
+
197
+	/**
198
+	 * @param $text
199
+	 *
200
+	 * @return string
201
+	 */
202
+	protected static function removeTrailingNewline($text)
203
+	{
204
+		return substr($text, - 1) === "\n" ? substr($text, - 2, 1) === "\r" ? substr($text, 0, - 2) : substr($text, 0, - 1) : $text;
205
+	}
206 206
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -56,26 +56,26 @@  discard block
 block discarded – undo
56 56
         self::$l     = preg_quote($l, '/');
57 57
         self::$r     = preg_quote($r, '/');
58 58
         self::$regex = '/
59
-			' . self::$l . 'block\s(["\']?)(.+?)\1' . self::$r . '(?:\r?\n?)
59
+			' . self::$l.'block\s(["\']?)(.+?)\1'.self::$r.'(?:\r?\n?)
60 60
 			((?:
61 61
 				(?R)
62 62
 				|
63
-				[^' . self::$l . ']*
63
+				[^' . self::$l.']*
64 64
 				(?:
65
-					(?! ' . self::$l . '\/?block\b )
66
-					' . self::$l . '
67
-					[^' . self::$l . ']*+
65
+					(?! ' . self::$l.'\/?block\b )
66
+					' . self::$l.'
67
+					[^' . self::$l.']*+
68 68
 				)*
69 69
 			)*)
70
-			' . self::$l . '\/block' . self::$r . '
70
+			' . self::$l.'\/block'.self::$r.'
71 71
 			/six';
72 72
 
73 73
         if ($compiler->getLooseOpeningHandling()) {
74 74
             self::$l .= '\s*';
75
-            self::$r = '\s*' . self::$r;
75
+            self::$r = '\s*'.self::$r;
76 76
         }
77 77
         $inheritanceTree = array(array('source' => $compiler->getTemplateSource()));
78
-        $curPath         = dirname($compiler->getCore()->getTemplate()->getResourceIdentifier()) . DIRECTORY_SEPARATOR;
78
+        $curPath         = dirname($compiler->getCore()->getTemplate()->getResourceIdentifier()).DIRECTORY_SEPARATOR;
79 79
         $curTpl          = $compiler->getCore()->getTemplate();
80 80
 
81 81
         while (!empty($file)) {
@@ -97,16 +97,16 @@  discard block
 block discarded – undo
97 97
                 $parent = $compiler->getCore()->templateFactory($resource, $identifier, null, null, null, $curTpl);
98 98
             }
99 99
             catch (SecurityException $e) {
100
-                throw new CompilationException($compiler, 'Extends : Security restriction : ' . $e->getMessage());
100
+                throw new CompilationException($compiler, 'Extends : Security restriction : '.$e->getMessage());
101 101
             }
102 102
             catch (Exception $e) {
103
-                throw new CompilationException($compiler, 'Extends : ' . $e->getMessage());
103
+                throw new CompilationException($compiler, 'Extends : '.$e->getMessage());
104 104
             }
105 105
 
106 106
             if ($parent === null) {
107
-                throw new CompilationException($compiler, 'Extends : Resource "' . $resource . ':' . $identifier . '" not found.');
107
+                throw new CompilationException($compiler, 'Extends : Resource "'.$resource.':'.$identifier.'" not found.');
108 108
             } elseif ($parent === false) {
109
-                throw new CompilationException($compiler, 'Extends : Resource "' . $resource . '" does not support extends.');
109
+                throw new CompilationException($compiler, 'Extends : Resource "'.$resource.'" does not support extends.');
110 110
             }
111 111
 
112 112
             $curTpl    = $parent;
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
             }
122 122
             $inheritanceTree[] = $newParent;
123 123
 
124
-            if (preg_match('/^' . self::$l . 'extends(?:\(?\s*|\s+)(?:file=)?\s*((["\']).+?\2|\S+?)\s*\)?\s*?' . self::$r . '/i', $parent->getSource(), $match)) {
125
-                $curPath = dirname($identifier) . DIRECTORY_SEPARATOR;
124
+            if (preg_match('/^'.self::$l.'extends(?:\(?\s*|\s+)(?:file=)?\s*((["\']).+?\2|\S+?)\s*\)?\s*?'.self::$r.'/i', $parent->getSource(), $match)) {
125
+                $curPath = dirname($identifier).DIRECTORY_SEPARATOR;
126 126
                 if (isset($match[2]) && $match[2] == '"') {
127
-                    $file = '"' . str_replace('"', '\\"', substr($match[1], 1, - 1)) . '"';
127
+                    $file = '"'.str_replace('"', '\\"', substr($match[1], 1, - 1)).'"';
128 128
                 } elseif (isset($match[2]) && $match[2] == "'") {
129
-                    $file = '"' . substr($match[1], 1, - 1) . '"';
129
+                    $file = '"'.substr($match[1], 1, - 1).'"';
130 130
                 } else {
131
-                    $file = '"' . $match[1] . '"';
131
+                    $file = '"'.$match[1].'"';
132 132
                 }
133 133
             } else {
134 134
                 $file = false;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
                 'Dwoo\Plugins\Functions\PluginExtends',
148 148
                 'replaceBlock'
149 149
             ), $newSource);
150
-            $newSource = $l . 'do extendsCheck(' . var_export($parent['resource'] . ':' . $parent['identifier'], true) . ')' . $r . $newSource;
150
+            $newSource = $l.'do extendsCheck('.var_export($parent['resource'].':'.$parent['identifier'], true).')'.$r.$newSource;
151 151
 
152 152
             if (self::$lastReplacement) {
153 153
                 break;
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
             $r = stripslashes(self::$r);
175 175
 
176 176
             if (self::$lastReplacement) {
177
-                return preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override);
177
+                return preg_replace('/'.self::$l.'\$dwoo\.parent'.self::$r.'/is', $matches[3], $override);
178 178
             }
179 179
 
180
-            return $l . 'block ' . $matches[1] . $matches[2] . $matches[1] . $r . preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override) . $l . '/block' . $r;
180
+            return $l.'block '.$matches[1].$matches[2].$matches[1].$r.preg_replace('/'.self::$l.'\$dwoo\.parent'.self::$r.'/is', $matches[3], $override).$l.'/block'.$r;
181 181
         }
182 182
 
183 183
         if (preg_match(self::$regex, $matches[3])) {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -95,11 +95,9 @@
 block discarded – undo
95 95
 
96 96
             try {
97 97
                 $parent = $compiler->getCore()->templateFactory($resource, $identifier, null, null, null, $curTpl);
98
-            }
99
-            catch (SecurityException $e) {
98
+            } catch (SecurityException $e) {
100 99
                 throw new CompilationException($compiler, 'Extends : Security restriction : ' . $e->getMessage());
101
-            }
102
-            catch (Exception $e) {
100
+            } catch (Exception $e) {
103 101
                 throw new CompilationException($compiler, 'Extends : ' . $e->getMessage());
104 102
             }
105 103
 
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginExtendsCheck.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -28,37 +28,37 @@  discard block
 block discarded – undo
28 28
  */
29 29
 class PluginExtendsCheck extends Plugin implements ICompilable
30 30
 {
31
-    /**
32
-     * @param Compiler $compiler
33
-     * @param          $file
34
-     *
35
-     * @return string
36
-     * @throws CompilationException
37
-     */
38
-    public static function compile(Compiler $compiler, $file)
39
-    {
40
-        preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m);
41
-        $resource   = $m[1];
42
-        $identifier = $m[2];
31
+	/**
32
+	 * @param Compiler $compiler
33
+	 * @param          $file
34
+	 *
35
+	 * @return string
36
+	 * @throws CompilationException
37
+	 */
38
+	public static function compile(Compiler $compiler, $file)
39
+	{
40
+		preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m);
41
+		$resource   = $m[1];
42
+		$identifier = $m[2];
43 43
 
44
-        $tpl = $compiler->getCore()->templateFactory($resource, $identifier);
44
+		$tpl = $compiler->getCore()->templateFactory($resource, $identifier);
45 45
 
46
-        if ($tpl === null) {
47
-            throw new CompilationException($compiler,
48
-                'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.');
49
-        } elseif ($tpl === false) {
50
-            throw new CompilationException($compiler,
51
-                'Load Templates : Resource "' . $resource . '" does not support includes.');
52
-        }
46
+		if ($tpl === null) {
47
+			throw new CompilationException($compiler,
48
+				'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.');
49
+		} elseif ($tpl === false) {
50
+			throw new CompilationException($compiler,
51
+				'Load Templates : Resource "' . $resource . '" does not support includes.');
52
+		}
53 53
 
54
-        $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n";
54
+		$out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n";
55 55
 
56
-        $modCheck = $tpl->getIsModifiedCode();
56
+		$modCheck = $tpl->getIsModifiedCode();
57 57
 
58
-        if ($modCheck) {
59
-            $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }';
60
-        } else {
61
-            $out .= 'try {
58
+		if ($modCheck) {
59
+			$out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }';
60
+		} else {
61
+			$out .= 'try {
62 62
 	$tpl = $this->templateFactory("' . $resource . '", "' . $identifier . '");
63 63
 } catch (Dwoo\Exception $e) {
64 64
 	$this->triggerError(\'Load Templates : Resource <em>' . $resource . '</em> was not added to Dwoo, can not extend <em>' . $identifier . '</em>\', E_USER_WARNING);
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 elseif ($tpl === false)
69 69
 	$this->triggerError(\'Load Templates : Resource "' . $resource . '" does not support extends.\', E_USER_WARNING);
70 70
 if ($tpl->getUid() != "' . $tpl->getUid() . '") { ob_end_clean(); return false; }';
71
-        }
71
+		}
72 72
 
73
-        return $out;
74
-    }
73
+		return $out;
74
+	}
75 75
 }
76 76
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginTif.php 3 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -36,70 +36,70 @@
 block discarded – undo
36 36
  */
37 37
 class PluginTif extends Plugin implements ICompilable
38 38
 {
39
-    /**
40
-     * @param Compiler $compiler
41
-     * @param array    $rest
42
-     * @param array    $tokens
43
-     *
44
-     * @return mixed|string
45
-     * @throws CompilationException
46
-     */
47
-    public static function compile(Compiler $compiler, array $rest, array $tokens)
48
-    {
49
-        // load if plugin
50
-        if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf')) {
51
-            try {
52
-                $compiler->getCore()->getLoader()->loadPlugin('if');
53
-            }
54
-            catch (Exception $e) {
55
-                throw new CompilationException($compiler, 'Tif: the if plugin is required to use Tif');
56
-            }
57
-        }
39
+	/**
40
+	 * @param Compiler $compiler
41
+	 * @param array    $rest
42
+	 * @param array    $tokens
43
+	 *
44
+	 * @return mixed|string
45
+	 * @throws CompilationException
46
+	 */
47
+	public static function compile(Compiler $compiler, array $rest, array $tokens)
48
+	{
49
+		// load if plugin
50
+		if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf')) {
51
+			try {
52
+				$compiler->getCore()->getLoader()->loadPlugin('if');
53
+			}
54
+			catch (Exception $e) {
55
+				throw new CompilationException($compiler, 'Tif: the if plugin is required to use Tif');
56
+			}
57
+		}
58 58
 
59
-        if (count($rest) == 1) {
60
-            return $rest[0];
61
-        }
59
+		if (count($rest) == 1) {
60
+			return $rest[0];
61
+		}
62 62
 
63
-        // fetch false result and remove the ":" if it was present
64
-        $falseResult = array_pop($rest);
63
+		// fetch false result and remove the ":" if it was present
64
+		$falseResult = array_pop($rest);
65 65
 
66
-        if (trim(end($rest), '"\'') === ':') {
67
-            // remove the ':' if present
68
-            array_pop($rest);
69
-        } elseif (trim(end($rest), '"\'') === '?' || count($rest) === 1) {
70
-            if ($falseResult === '?' || $falseResult === ':') {
71
-                throw new CompilationException($compiler,
72
-                    'Tif: incomplete tif statement, value missing after ' . $falseResult);
73
-            }
74
-            // there was in fact no false result provided, so we move it to be the true result instead
75
-            $trueResult = $falseResult;
76
-            $falseResult = "''";
77
-        }
66
+		if (trim(end($rest), '"\'') === ':') {
67
+			// remove the ':' if present
68
+			array_pop($rest);
69
+		} elseif (trim(end($rest), '"\'') === '?' || count($rest) === 1) {
70
+			if ($falseResult === '?' || $falseResult === ':') {
71
+				throw new CompilationException($compiler,
72
+					'Tif: incomplete tif statement, value missing after ' . $falseResult);
73
+			}
74
+			// there was in fact no false result provided, so we move it to be the true result instead
75
+			$trueResult = $falseResult;
76
+			$falseResult = "''";
77
+		}
78 78
 
79
-        // fetch true result if needed
80
-        if (!isset($trueResult)) {
81
-            $trueResult = array_pop($rest);
82
-            // no true result provided so we use the expression arg
83
-            if ($trueResult === '?') {
84
-                $trueResult = true;
85
-            }
86
-        }
79
+		// fetch true result if needed
80
+		if (!isset($trueResult)) {
81
+			$trueResult = array_pop($rest);
82
+			// no true result provided so we use the expression arg
83
+			if ($trueResult === '?') {
84
+				$trueResult = true;
85
+			}
86
+		}
87 87
 
88
-        // remove the '?' if present
89
-        if (trim(end($rest), '"\'') === '?') {
90
-            array_pop($rest);
91
-        }
88
+		// remove the '?' if present
89
+		if (trim(end($rest), '"\'') === '?') {
90
+			array_pop($rest);
91
+		}
92 92
 
93
-        // check params were correctly provided
94
-        if (empty($rest) || $trueResult === null || $falseResult === null) {
95
-            throw new CompilationException($compiler,
96
-                'Tif: you must provide three parameters serving as <expression> ? <true value> : <false value>');
97
-        }
93
+		// check params were correctly provided
94
+		if (empty($rest) || $trueResult === null || $falseResult === null) {
95
+			throw new CompilationException($compiler,
96
+				'Tif: you must provide three parameters serving as <expression> ? <true value> : <false value>');
97
+		}
98 98
 
99
-        // parse condition
100
-        $condition = PluginIf::replaceKeywords($rest, $tokens, $compiler);
99
+		// parse condition
100
+		$condition = PluginIf::replaceKeywords($rest, $tokens, $compiler);
101 101
 
102
-        return '((' . implode(' ', $condition) . ') ? ' . ($trueResult === true ? implode(' ',
103
-                $condition) : $trueResult) . ' : ' . $falseResult . ')';
104
-    }
102
+		return '((' . implode(' ', $condition) . ') ? ' . ($trueResult === true ? implode(' ',
103
+				$condition) : $trueResult) . ' : ' . $falseResult . ')';
104
+	}
105 105
 }
106 106
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     public static function compile(Compiler $compiler, array $rest, array $tokens)
48 48
     {
49 49
         // load if plugin
50
-        if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf')) {
50
+        if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS.'PluginIf')) {
51 51
             try {
52 52
                 $compiler->getCore()->getLoader()->loadPlugin('if');
53 53
             }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         } elseif (trim(end($rest), '"\'') === '?' || count($rest) === 1) {
70 70
             if ($falseResult === '?' || $falseResult === ':') {
71 71
                 throw new CompilationException($compiler,
72
-                    'Tif: incomplete tif statement, value missing after ' . $falseResult);
72
+                    'Tif: incomplete tif statement, value missing after '.$falseResult);
73 73
             }
74 74
             // there was in fact no false result provided, so we move it to be the true result instead
75 75
             $trueResult = $falseResult;
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         // parse condition
100 100
         $condition = PluginIf::replaceKeywords($rest, $tokens, $compiler);
101 101
 
102
-        return '((' . implode(' ', $condition) . ') ? ' . ($trueResult === true ? implode(' ',
103
-                $condition) : $trueResult) . ' : ' . $falseResult . ')';
102
+        return '(('.implode(' ', $condition).') ? '.($trueResult === true ? implode(' ',
103
+                $condition) : $trueResult).' : '.$falseResult.')';
104 104
     }
105 105
 }
106 106
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,8 +50,7 @@
 block discarded – undo
50 50
         if (!class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf')) {
51 51
             try {
52 52
                 $compiler->getCore()->getLoader()->loadPlugin('if');
53
-            }
54
-            catch (Exception $e) {
53
+            } catch (Exception $e) {
55 54
                 throw new CompilationException($compiler, 'Tif: the if plugin is required to use Tif');
56 55
             }
57 56
         }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Functions/PluginLoadTemplates.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -31,58 +31,58 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class PluginLoadTemplates extends Plugin implements ICompilable
33 33
 {
34
-    /**
35
-     * @param Compiler $compiler
36
-     * @param string   $file
37
-     *
38
-     * @return string
39
-     * @throws CompilationException
40
-     */
41
-    public static function compile(Compiler $compiler, $file)
42
-    {
43
-        $file = substr($file, 1, - 1);
34
+	/**
35
+	 * @param Compiler $compiler
36
+	 * @param string   $file
37
+	 *
38
+	 * @return string
39
+	 * @throws CompilationException
40
+	 */
41
+	public static function compile(Compiler $compiler, $file)
42
+	{
43
+		$file = substr($file, 1, - 1);
44 44
 
45
-        if ($file === '') {
46
-            return '';
47
-        }
45
+		if ($file === '') {
46
+			return '';
47
+		}
48 48
 
49
-        if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) {
50
-            // resource:identifier given, extract them
51
-            $resource   = $m[1];
52
-            $identifier = $m[2];
53
-        } else {
54
-            // get the current template's resource
55
-            $resource   = $compiler->getCore()->getTemplate()->getResourceName();
56
-            $identifier = $file;
57
-        }
49
+		if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) {
50
+			// resource:identifier given, extract them
51
+			$resource   = $m[1];
52
+			$identifier = $m[2];
53
+		} else {
54
+			// get the current template's resource
55
+			$resource   = $compiler->getCore()->getTemplate()->getResourceName();
56
+			$identifier = $file;
57
+		}
58 58
 
59
-        $tpl = $compiler->getCore()->templateFactory($resource, $identifier);
59
+		$tpl = $compiler->getCore()->templateFactory($resource, $identifier);
60 60
 
61
-        if ($tpl === null) {
62
-            throw new CompilationException($compiler,
63
-                'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.');
64
-        } elseif ($tpl === false) {
65
-            throw new CompilationException($compiler,
66
-                'Load Templates : Resource "' . $resource . '" does not support includes.');
67
-        }
61
+		if ($tpl === null) {
62
+			throw new CompilationException($compiler,
63
+				'Load Templates : Resource "' . $resource . ':' . $identifier . '" not found.');
64
+		} elseif ($tpl === false) {
65
+			throw new CompilationException($compiler,
66
+				'Load Templates : Resource "' . $resource . '" does not support includes.');
67
+		}
68 68
 
69
-        $cmp = clone $compiler;
70
-        $cmp->compile($compiler->getCore(), $tpl);
71
-        foreach ($cmp->getTemplatePlugins() as $template => $args) {
72
-            $compiler->addTemplatePlugin($template, $args['params'], $args['uuid'], $args['body']);
73
-        }
74
-        foreach ($cmp->getUsedPlugins() as $plugin => $type) {
75
-            $compiler->addUsedPlugin($plugin, $type);
76
-        }
69
+		$cmp = clone $compiler;
70
+		$cmp->compile($compiler->getCore(), $tpl);
71
+		foreach ($cmp->getTemplatePlugins() as $template => $args) {
72
+			$compiler->addTemplatePlugin($template, $args['params'], $args['uuid'], $args['body']);
73
+		}
74
+		foreach ($cmp->getUsedPlugins() as $plugin => $type) {
75
+			$compiler->addUsedPlugin($plugin, $type);
76
+		}
77 77
 
78
-        $out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n";
78
+		$out = '\'\';// checking for modification in ' . $resource . ':' . $identifier . "\r\n";
79 79
 
80
-        $modCheck = $tpl->getIsModifiedCode();
80
+		$modCheck = $tpl->getIsModifiedCode();
81 81
 
82
-        if ($modCheck) {
83
-            $out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }';
84
-        } else {
85
-            $out .= 'try {
82
+		if ($modCheck) {
83
+			$out .= 'if (!(' . $modCheck . ')) { ob_end_clean(); return false; }';
84
+		} else {
85
+			$out .= 'try {
86 86
 	$tpl = $this->templateFactory("' . $resource . '", "' . $identifier . '");
87 87
 } catch (Dwoo\Exception $e) {
88 88
 	$this->triggerError(\'Load Templates : Resource <em>' . $resource . '</em> was not added to Dwoo, can not extend <em>' . $identifier . '</em>\', E_USER_WARNING);
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 elseif ($tpl === false)
93 93
 	$this->triggerError(\'Load Templates : Resource "' . $resource . '" does not support extends.\', E_USER_WARNING);
94 94
 if ($tpl->getUid() != "' . $tpl->getUid() . '") { ob_end_clean(); return false; }';
95
-        }
95
+		}
96 96
 
97
-        return $out;
98
-    }
97
+		return $out;
98
+	}
99 99
 }
100 100
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Blocks/PluginSmartyinterface.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -28,69 +28,69 @@
 block discarded – undo
28 28
  */
29 29
 class PluginSmartyinterface extends BlockPlugin implements ICompilableBlock
30 30
 {
31
-    /**
32
-     * @param       $__funcname
33
-     * @param       $__functype
34
-     * @param array $rest
35
-     */
36
-    public function init($__funcname, $__functype, array $rest = array())
37
-    {
38
-    }
31
+	/**
32
+	 * @param       $__funcname
33
+	 * @param       $__functype