Completed
Push — master ( 751bec...101b9a )
by David
11s
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/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/ICompiler.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -29,31 +29,31 @@
 block discarded – undo
29 29
  */
30 30
 interface ICompiler
31 31
 {
32
-    /**
33
-     * Compiles the provided string down to php code.
34
-     *
35
-     * @param Core      $core
36
-     * @param ITemplate $template the template to compile
37
-     *
38
-     * @return string a compiled php code string
39
-     */
40
-    public function compile(Core $core, ITemplate $template);
32
+	/**
33
+	 * Compiles the provided string down to php code.
34
+	 *
35
+	 * @param Core      $core
36
+	 * @param ITemplate $template the template to compile
37
+	 *
38
+	 * @return string a compiled php code string
39
+	 */
40
+	public function compile(Core $core, ITemplate $template);
41 41
 
42
-    /**
43
-     * Adds the custom plugins loaded into Dwoo to the compiler so it can load them.
44
-     *
45
-     * @see Core::addPlugin
46
-     *
47
-     * @param array $customPlugins an array of custom plugins
48
-     */
49
-    public function setCustomPlugins(array $customPlugins);
42
+	/**
43
+	 * Adds the custom plugins loaded into Dwoo to the compiler so it can load them.
44
+	 *
45
+	 * @see Core::addPlugin
46
+	 *
47
+	 * @param array $customPlugins an array of custom plugins
48
+	 */
49
+	public function setCustomPlugins(array $customPlugins);
50 50
 
51
-    /**
52
-     * Sets the security policy object to enforce some php security settings.
53
-     * use this if untrusted persons can modify templates,
54
-     * set it on the Dwoo object as it will be passed onto the compiler automatically
55
-     *
56
-     * @param SecurityPolicy $policy the security policy object
57
-     */
58
-    public function setSecurityPolicy(SecurityPolicy $policy = null);
51
+	/**
52
+	 * Sets the security policy object to enforce some php security settings.
53
+	 * use this if untrusted persons can modify templates,
54
+	 * set it on the Dwoo object as it will be passed onto the compiler automatically
55
+	 *
56
+	 * @param SecurityPolicy $policy the security policy object
57
+	 */
58
+	public function setSecurityPolicy(SecurityPolicy $policy = null);
59 59
 }
Please login to merge, or discard this patch.
lib/Dwoo/Loader.php 2 patches
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -23,168 +23,168 @@
 block discarded – undo
23 23
  */
24 24
 class Loader implements ILoader
25 25
 {
26
-    /**
27
-     * Stores the plugin directories.
28
-     *
29
-     * @see addDirectory
30
-     * @var array
31
-     */
32
-    protected $paths = array();
33
-
34
-    /**
35
-     * Stores the plugins names/paths relationships
36
-     * don't edit this on your own, use addDirectory.
37
-     *
38
-     * @see addDirectory
39
-     * @var array
40
-     */
41
-    protected $classPath = array();
42
-
43
-    /**
44
-     * Path where class paths cache files are written.
45
-     *
46
-     * @var string
47
-     */
48
-    protected $cacheDir;
49
-
50
-    /**
51
-     * Path where builtin plugins are stored.
52
-     *
53
-     * @var string
54
-     */
55
-    protected $corePluginDir;
56
-
57
-    /**
58
-     * Loader constructor.
59
-     *
60
-     * @param $cacheDir
61
-     */
62
-    public function __construct($cacheDir)
63
-    {
64
-        $this->corePluginDir = __DIR__ . DIRECTORY_SEPARATOR . 'Plugins';
65
-        $this->cacheDir      = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
66
-
67
-        // include class paths or rebuild paths if the cache file isn't there
68
-        $cacheFile = $this->cacheDir . 'classpath.cache.d' . Core::RELEASE_TAG . '.php';
69
-
70
-        $chachedClassPath = null;
71
-
72
-        if (file_exists($cacheFile)) {
73
-
74
-            $chachedClassPath = unserialize(file_get_contents($cacheFile));
75
-
76
-            if (is_array($chachedClassPath)) {
77
-                $this->classPath = $chachedClassPath + $this->classPath;
78
-            }
79
-        }
80
-
81
-        if (!is_array($chachedClassPath)) {
82
-            $this->rebuildClassPathCache($this->corePluginDir, $cacheFile);
83
-        }
84
-    }
85
-
86
-    /**
87
-     * Rebuilds class paths, scans the given directory recursively and saves all paths in the given file.
88
-     *
89
-     * @param string         $path      the plugin path to scan
90
-     * @param string|boolean $cacheFile the file where to store the plugin paths cache, it will be overwritten
91
-     *
92
-     * @throws Exception
93
-     */
94
-    protected function rebuildClassPathCache($path, $cacheFile)
95
-    {
96
-        $tmp = array();
97
-        if ($cacheFile !== false) {
98
-            $tmp             = $this->classPath;
99
-            $this->classPath = array();
100
-        }
101
-
102
-        // iterates over all files/folders
103
-        foreach (new \DirectoryIterator($path) as $fileInfo) {
104
-            if (!$fileInfo->isDot()) {
105
-                if ($fileInfo->isDir()) {
106
-                    $this->rebuildClassPathCache($fileInfo->getPathname(), false);
107
-                } else {
108
-                    $this->classPath[$fileInfo->getBasename('.php')] = $fileInfo->getPathname();
109
-                }
110
-            }
111
-        }
112
-
113
-        // save in file if it's the first call (not recursed)
114
-        if ($cacheFile !== false) {
115
-            if (!file_put_contents($cacheFile, serialize($this->classPath), LOCK_EX)) {
116
-                throw new Exception('Could not write into ' . $cacheFile . ', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()');
117
-            }
118
-            $this->classPath += $tmp;
119
-        }
120
-    }
121
-
122
-    /**
123
-     * Loads a plugin file.
124
-     *
125
-     * @param string $class       the plugin name, without the `Plugin` prefix
126
-     * @param bool   $forceRehash if true, the class path caches will be rebuilt if the plugin is not found, in case it
127
-     *                            has just been added, defaults to true
128
-     *
129
-     * @throws Exception
130
-     */
131
-    public function loadPlugin($class, $forceRehash = true)
132
-    {
133
-        /**
134
-         * An unknown class was requested (maybe newly added) or the
135
-         * include failed so we rebuild the cache. include() will fail
136
-         * with an uncatchable error if the file doesn't exist, which
137
-         * usually means that the cache is stale and must be rebuilt,
138
-         * so we check for that before trying to include() the plugin.
139
-         */
140
-        if ((!isset($this->classPath[$class]) || !is_readable($this->classPath[$class])) || (!isset
141
-                ($this->classPath[$class . 'Compile']) || !is_readable($this->classPath[$class . 'Compile']))) {
142
-            if ($forceRehash) {
143
-                $this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir . 'classpath.cache.d' .
144
-                    Core::RELEASE_TAG . '.php');
145
-                foreach ($this->paths as $path => $file) {
146
-                    $this->rebuildClassPathCache($path, $file);
147
-                }
148
-                if (isset($this->classPath[$class])) {
149
-                    include_once $this->classPath[$class];
150
-                } elseif (isset($this->classPath[$class . 'Compile'])) {
151
-                    include_once $this->classPath[$class . 'Compile'];
152
-                } else {
153
-                    throw new Exception('Plugin "' . $class . '" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
154
-                }
155
-            } else {
156
-                throw new Exception('Plugin "' . $class . '" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
157
-            }
158
-        }
159
-    }
160
-
161
-    /**
162
-     * Adds a plugin directory, the plugins found in the new plugin directory
163
-     * will take precedence over the other directories (including the default
164
-     * dwoo plugin directory), you can use this for example to override plugins
165
-     * in a specific directory for a specific application while keeping all your
166
-     * usual plugins in the same place for all applications.
167
-     * TOCOM don't forget that php functions overrides are not rehashed so you
168
-     * need to clear the classpath caches by hand when adding those.
169
-     *
170
-     * @param string $pluginDirectory the plugin path to scan
171
-     *
172
-     * @throws Exception
173
-     */
174
-    public function addDirectory($pluginDirectory)
175
-    {
176
-        $pluginDir = realpath($pluginDirectory);
177
-        if (!$pluginDir) {
178
-            throw new Exception('Plugin directory does not exist or can not be read : ' . $pluginDirectory);
179
-        }
180
-        $cacheFile = $this->cacheDir . 'classpath-' . substr(strtr($pluginDir, '/\\:' . PATH_SEPARATOR, '----'),
181
-                strlen($pluginDir) > 80 ? - 80 : 0) . '.d' . Core::RELEASE_TAG . '.php';
182
-        $this->paths[$pluginDir] = $cacheFile;
183
-        if (file_exists($cacheFile)) {
184
-            $classpath       = file_get_contents($cacheFile);
185
-            $this->classPath = unserialize($classpath) + $this->classPath;
186
-        } else {
187
-            $this->rebuildClassPathCache($pluginDir, $cacheFile);
188
-        }
189
-    }
26
+	/**
27
+	 * Stores the plugin directories.
28
+	 *
29
+	 * @see addDirectory
30
+	 * @var array
31
+	 */
32
+	protected $paths = array();
33
+
34
+	/**
35
+	 * Stores the plugins names/paths relationships
36
+	 * don't edit this on your own, use addDirectory.
37
+	 *
38
+	 * @see addDirectory
39
+	 * @var array
40
+	 */
41
+	protected $classPath = array();
42
+
43
+	/**
44
+	 * Path where class paths cache files are written.
45
+	 *
46
+	 * @var string
47
+	 */
48
+	protected $cacheDir;
49
+
50
+	/**
51
+	 * Path where builtin plugins are stored.
52
+	 *
53
+	 * @var string
54
+	 */
55
+	protected $corePluginDir;
56
+
57
+	/**
58
+	 * Loader constructor.
59
+	 *
60
+	 * @param $cacheDir
61
+	 */
62
+	public function __construct($cacheDir)
63
+	{
64
+		$this->corePluginDir = __DIR__ . DIRECTORY_SEPARATOR . 'Plugins';
65
+		$this->cacheDir      = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
66
+
67
+		// include class paths or rebuild paths if the cache file isn't there
68
+		$cacheFile = $this->cacheDir . 'classpath.cache.d' . Core::RELEASE_TAG . '.php';
69
+
70
+		$chachedClassPath = null;
71
+
72
+		if (file_exists($cacheFile)) {
73
+
74
+			$chachedClassPath = unserialize(file_get_contents($cacheFile));
75
+
76
+			if (is_array($chachedClassPath)) {
77
+				$this->classPath = $chachedClassPath + $this->classPath;
78
+			}
79
+		}
80
+
81
+		if (!is_array($chachedClassPath)) {
82
+			$this->rebuildClassPathCache($this->corePluginDir, $cacheFile);
83
+		}
84
+	}
85
+
86
+	/**
87
+	 * Rebuilds class paths, scans the given directory recursively and saves all paths in the given file.
88
+	 *
89
+	 * @param string         $path      the plugin path to scan
90
+	 * @param string|boolean $cacheFile the file where to store the plugin paths cache, it will be overwritten
91
+	 *
92
+	 * @throws Exception
93
+	 */
94
+	protected function rebuildClassPathCache($path, $cacheFile)
95
+	{
96
+		$tmp = array();
97
+		if ($cacheFile !== false) {
98
+			$tmp             = $this->classPath;
99
+			$this->classPath = array();
100
+		}
101
+
102
+		// iterates over all files/folders
103
+		foreach (new \DirectoryIterator($path) as $fileInfo) {
104
+			if (!$fileInfo->isDot()) {
105
+				if ($fileInfo->isDir()) {
106
+					$this->rebuildClassPathCache($fileInfo->getPathname(), false);
107
+				} else {
108
+					$this->classPath[$fileInfo->getBasename('.php')] = $fileInfo->getPathname();
109
+				}
110
+			}
111
+		}
112
+
113
+		// save in file if it's the first call (not recursed)
114
+		if ($cacheFile !== false) {
115
+			if (!file_put_contents($cacheFile, serialize($this->classPath), LOCK_EX)) {
116
+				throw new Exception('Could not write into ' . $cacheFile . ', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()');
117
+			}
118
+			$this->classPath += $tmp;
119
+		}
120
+	}
121
+
122
+	/**
123
+	 * Loads a plugin file.
124
+	 *
125
+	 * @param string $class       the plugin name, without the `Plugin` prefix
126
+	 * @param bool   $forceRehash if true, the class path caches will be rebuilt if the plugin is not found, in case it
127
+	 *                            has just been added, defaults to true
128
+	 *
129
+	 * @throws Exception
130
+	 */
131
+	public function loadPlugin($class, $forceRehash = true)
132
+	{
133
+		/**
134
+		 * An unknown class was requested (maybe newly added) or the
135
+		 * include failed so we rebuild the cache. include() will fail
136
+		 * with an uncatchable error if the file doesn't exist, which
137
+		 * usually means that the cache is stale and must be rebuilt,
138
+		 * so we check for that before trying to include() the plugin.
139
+		 */
140
+		if ((!isset($this->classPath[$class]) || !is_readable($this->classPath[$class])) || (!isset
141
+				($this->classPath[$class . 'Compile']) || !is_readable($this->classPath[$class . 'Compile']))) {
142
+			if ($forceRehash) {
143
+				$this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir . 'classpath.cache.d' .
144
+					Core::RELEASE_TAG . '.php');
145
+				foreach ($this->paths as $path => $file) {
146
+					$this->rebuildClassPathCache($path, $file);
147
+				}
148
+				if (isset($this->classPath[$class])) {
149
+					include_once $this->classPath[$class];
150
+				} elseif (isset($this->classPath[$class . 'Compile'])) {
151
+					include_once $this->classPath[$class . 'Compile'];
152
+				} else {
153
+					throw new Exception('Plugin "' . $class . '" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
154
+				}
155
+			} else {
156
+				throw new Exception('Plugin "' . $class . '" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
157
+			}
158
+		}
159
+	}
160
+
161
+	/**
162
+	 * Adds a plugin directory, the plugins found in the new plugin directory
163
+	 * will take precedence over the other directories (including the default
164
+	 * dwoo plugin directory), you can use this for example to override plugins
165
+	 * in a specific directory for a specific application while keeping all your
166
+	 * usual plugins in the same place for all applications.
167
+	 * TOCOM don't forget that php functions overrides are not rehashed so you
168
+	 * need to clear the classpath caches by hand when adding those.
169
+	 *
170
+	 * @param string $pluginDirectory the plugin path to scan
171
+	 *
172
+	 * @throws Exception
173
+	 */
174
+	public function addDirectory($pluginDirectory)
175
+	{
176
+		$pluginDir = realpath($pluginDirectory);
177
+		if (!$pluginDir) {
178
+			throw new Exception('Plugin directory does not exist or can not be read : ' . $pluginDirectory);
179
+		}
180
+		$cacheFile = $this->cacheDir . 'classpath-' . substr(strtr($pluginDir, '/\\:' . PATH_SEPARATOR, '----'),
181
+				strlen($pluginDir) > 80 ? - 80 : 0) . '.d' . Core::RELEASE_TAG . '.php';
182
+		$this->paths[$pluginDir] = $cacheFile;
183
+		if (file_exists($cacheFile)) {
184
+			$classpath       = file_get_contents($cacheFile);
185
+			$this->classPath = unserialize($classpath) + $this->classPath;
186
+		} else {
187
+			$this->rebuildClassPathCache($pluginDir, $cacheFile);
188
+		}
189
+	}
190 190
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function __construct($cacheDir)
63 63
     {
64
-        $this->corePluginDir = __DIR__ . DIRECTORY_SEPARATOR . 'Plugins';
65
-        $this->cacheDir      = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
64
+        $this->corePluginDir = __DIR__.DIRECTORY_SEPARATOR.'Plugins';
65
+        $this->cacheDir      = rtrim($cacheDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
66 66
 
67 67
         // include class paths or rebuild paths if the cache file isn't there
68
-        $cacheFile = $this->cacheDir . 'classpath.cache.d' . Core::RELEASE_TAG . '.php';
68
+        $cacheFile = $this->cacheDir.'classpath.cache.d'.Core::RELEASE_TAG.'.php';
69 69
 
70 70
         $chachedClassPath = null;
71 71
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             $chachedClassPath = unserialize(file_get_contents($cacheFile));
75 75
 
76 76
             if (is_array($chachedClassPath)) {
77
-                $this->classPath = $chachedClassPath + $this->classPath;
77
+                $this->classPath = $chachedClassPath+$this->classPath;
78 78
             }
79 79
         }
80 80
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         // save in file if it's the first call (not recursed)
114 114
         if ($cacheFile !== false) {
115 115
             if (!file_put_contents($cacheFile, serialize($this->classPath), LOCK_EX)) {
116
-                throw new Exception('Could not write into ' . $cacheFile . ', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()');
116
+                throw new Exception('Could not write into '.$cacheFile.', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()');
117 117
             }
118 118
             $this->classPath += $tmp;
119 119
         }
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
          * so we check for that before trying to include() the plugin.
139 139
          */
140 140
         if ((!isset($this->classPath[$class]) || !is_readable($this->classPath[$class])) || (!isset
141
-                ($this->classPath[$class . 'Compile']) || !is_readable($this->classPath[$class . 'Compile']))) {
141
+                ($this->classPath[$class.'Compile']) || !is_readable($this->classPath[$class.'Compile']))) {
142 142
             if ($forceRehash) {
143
-                $this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir . 'classpath.cache.d' .
144
-                    Core::RELEASE_TAG . '.php');
143
+                $this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir.'classpath.cache.d'.
144
+                    Core::RELEASE_TAG.'.php');
145 145
                 foreach ($this->paths as $path => $file) {
146 146
                     $this->rebuildClassPathCache($path, $file);
147 147
                 }
148 148
                 if (isset($this->classPath[$class])) {
149 149
                     include_once $this->classPath[$class];
150
-                } elseif (isset($this->classPath[$class . 'Compile'])) {
151
-                    include_once $this->classPath[$class . 'Compile'];
150
+                } elseif (isset($this->classPath[$class.'Compile'])) {
151
+                    include_once $this->classPath[$class.'Compile'];
152 152
                 } else {
153
-                    throw new Exception('Plugin "' . $class . '" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
153
+                    throw new Exception('Plugin "'.$class.'" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
154 154
                 }
155 155
             } else {
156
-                throw new Exception('Plugin "' . $class . '" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
156
+                throw new Exception('Plugin "'.$class.'" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
157 157
             }
158 158
         }
159 159
     }
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
     {
176 176
         $pluginDir = realpath($pluginDirectory);
177 177
         if (!$pluginDir) {
178
-            throw new Exception('Plugin directory does not exist or can not be read : ' . $pluginDirectory);
178
+            throw new Exception('Plugin directory does not exist or can not be read : '.$pluginDirectory);
179 179
         }
180
-        $cacheFile = $this->cacheDir . 'classpath-' . substr(strtr($pluginDir, '/\\:' . PATH_SEPARATOR, '----'),
181
-                strlen($pluginDir) > 80 ? - 80 : 0) . '.d' . Core::RELEASE_TAG . '.php';
180
+        $cacheFile = $this->cacheDir.'classpath-'.substr(strtr($pluginDir, '/\\:'.PATH_SEPARATOR, '----'),
181
+                strlen($pluginDir) > 80 ? -80 : 0).'.d'.Core::RELEASE_TAG.'.php';
182 182
         $this->paths[$pluginDir] = $cacheFile;
183 183
         if (file_exists($cacheFile)) {
184 184
             $classpath       = file_get_contents($cacheFile);
185
-            $this->classPath = unserialize($classpath) + $this->classPath;
185
+            $this->classPath = unserialize($classpath)+$this->classPath;
186 186
         } else {
187 187
             $this->rebuildClassPathCache($pluginDir, $cacheFile);
188 188
         }
Please login to merge, or discard this patch.