Completed
Push — master ( 23863d...4a9b8e )
by Tom
02:43
created
src/TSSCache.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace Transphporm;
3 3
 class TSSCache {
4
-    private $cache;
5
-    private $prefix;
4
+	private $cache;
5
+	private $prefix;
6 6
 
7
-    public function __construct(Cache $cache, $prefix) {
8
-        $this->cache = $cache;
9
-        $this->prefix = $prefix;
10
-    }
7
+	public function __construct(Cache $cache, $prefix) {
8
+		$this->cache = $cache;
9
+		$this->prefix = $prefix;
10
+	}
11 11
 
12 12
 	private function getRulesFromCache($file) {
13 13
 		//The cache for the key: the filename and template prefix
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 		return $file . $this->prefix . dirname(realpath($file)) . DIRECTORY_SEPARATOR;
29 29
 	}
30 30
 
31
-    public function load($tss) {
32
-        return $this->getRulesFromCache($tss);
33
-    }
31
+	public function load($tss) {
32
+		return $this->getRulesFromCache($tss);
33
+	}
34 34
 
35
-    public function write($file, $rules, $imports = []) {
36
-        if (is_file($file)) $this->cache->write($this->getCacheKey($file), ['rules' => $rules, 'import' => $imports]);
37
-        return $rules;
38
-    }
35
+	public function write($file, $rules, $imports = []) {
36
+		if (is_file($file)) $this->cache->write($this->getCacheKey($file), ['rules' => $rules, 'import' => $imports]);
37
+		return $rules;
38
+	}
39 39
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 	}
26 26
 
27 27
 	private function getCacheKey($file) {
28
-		return $file . $this->prefix . dirname(realpath($file)) . DIRECTORY_SEPARATOR;
28
+		return $file.$this->prefix.dirname(realpath($file)).DIRECTORY_SEPARATOR;
29 29
 	}
30 30
 
31 31
     public function load($tss) {
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@  discard block
 block discarded – undo
18 18
 		$rules = $this->cache->load($key, filemtime($file));
19 19
 		if ($rules) {
20 20
 			foreach ($rules['import'] as $file) {
21
-				if (!$this->cache->load($this->getCacheKey($file), filemtime($file))) return false;
21
+				if (!$this->cache->load($this->getCacheKey($file), filemtime($file))) {
22
+					return false;
23
+				}
22 24
 			}
23 25
 		}
24 26
 		return $rules;
@@ -33,7 +35,9 @@  discard block
 block discarded – undo
33 35
     }
34 36
 
35 37
     public function write($file, $rules, $imports = []) {
36
-        if (is_file($file)) $this->cache->write($this->getCacheKey($file), ['rules' => $rules, 'import' => $imports]);
38
+        if (is_file($file)) {
39
+        	$this->cache->write($this->getCacheKey($file), ['rules' => $rules, 'import' => $imports]);
40
+        }
37 41
         return $rules;
38 42
     }
39 43
 }
Please login to merge, or discard this patch.
src/TSSFunction/Template.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -17,6 +17,9 @@
 block discarded – undo
17 17
 		$this->xPath = $xPath;
18 18
 	}
19 19
 
20
+	/**
21
+	 * @param integer $index
22
+	 */
20 23
 	private function readArray($array, $index) {
21 24
 		return isset($array[$index]) ? $array[$index] : null;
22 25
 	}
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 		$result = [];
42 42
 		if ($newNode->tagName === 'template') {
43 43
 			foreach ($newNode->childNodes as $node) {
44
-                if (isset($node->tagName) && $node->tagName === 'template') $result[] = $this->getTemplateContent($node, $tss);
44
+				if (isset($node->tagName) && $node->tagName === 'template') $result[] = $this->getTemplateContent($node, $tss);
45 45
 				else $result[] = $this->getClonedElement($node, $tss);
46 46
 			}
47 47
 		}
Please login to merge, or discard this patch.
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,13 +25,18 @@  discard block
 block discarded – undo
25 25
 		$selector = $this->readArray($args, 1);
26 26
 		$tss = $this->readArray($args, 2);
27 27
 
28
-		if (trim($args[0])[0] === '<') $xml = $args[0];
29
-		else $xml = $this->filePath->getFilePath($args[0]);
28
+		if (trim($args[0])[0] === '<') {
29
+			$xml = $args[0];
30
+		} else {
31
+			$xml = $this->filePath->getFilePath($args[0]);
32
+		}
30 33
 
31 34
 		$newTemplate = new \Transphporm\Builder($xml, $tss ? $this->filePath->getFilePath($tss) : null);
32 35
 
33 36
 		$doc = $newTemplate->output($this->elementData->getData($element), true)->body;
34
-		if ($selector != '') return $this->templateSubsection($doc, $selector);
37
+		if ($selector != '') {
38
+			return $this->templateSubsection($doc, $selector);
39
+		}
35 40
 
36 41
 		return $this->getTemplateContent($doc->documentElement, $tss);
37 42
 
@@ -41,8 +46,11 @@  discard block
 block discarded – undo
41 46
 		$result = [];
42 47
 		if ($newNode->tagName === 'template') {
43 48
 			foreach ($newNode->childNodes as $node) {
44
-                if (isset($node->tagName) && $node->tagName === 'template') $result[] = $this->getTemplateContent($node, $tss);
45
-				else $result[] = $this->getClonedElement($node, $tss);
49
+                if (isset($node->tagName) && $node->tagName === 'template') {
50
+                	$result[] = $this->getTemplateContent($node, $tss);
51
+                } else {
52
+					$result[] = $this->getClonedElement($node, $tss);
53
+				}
46 54
 			}
47 55
 		}
48 56
 		return $result;
@@ -62,7 +70,9 @@  discard block
 block discarded – undo
62 70
 
63 71
 	private function getClonedElement($node, $tss) {
64 72
 		$clone = $node->cloneNode(true);
65
-		if ($tss != null && $clone instanceof \DomElement) $clone->setAttribute('transphporm', 'includedtemplate');
73
+		if ($tss != null && $clone instanceof \DomElement) {
74
+			$clone->setAttribute('transphporm', 'includedtemplate');
75
+		}
66 76
 		return $clone;
67 77
 	}
68 78
 }
Please login to merge, or discard this patch.
src/TSSFunction/Json.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@
 block discarded – undo
12 12
 
13 13
         if ($this->isJsonFile($json)) {
14 14
             $path = $this->filePath->getFilePath($json);
15
-            if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
15
+            if (!file_exists($path)) throw new \Exception('File does not exist at: '.$path);
16 16
             $json = file_get_contents($path);
17 17
         }
18 18
 
19 19
         $map = json_decode($json, true);
20 20
 
21
-        if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
21
+        if (!is_array($map)) throw new \Exception('Could not decode json: '.json_last_error_msg());
22 22
 
23 23
         return $map;
24 24
     }
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,29 +1,29 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Transphporm\TSSFunction;
3 3
 class Json implements \Transphporm\TSSFunction {
4
-    private $filePath;
4
+	private $filePath;
5 5
 
6
-    public function __construct(\Transphporm\FilePath $filePath) {
7
-        $this->filePath = $filePath;
8
-    }
6
+	public function __construct(\Transphporm\FilePath $filePath) {
7
+		$this->filePath = $filePath;
8
+	}
9 9
 
10
-    public function run(array $args, \DomElement $element = null) {
11
-        $json = $args[0];
10
+	public function run(array $args, \DomElement $element = null) {
11
+		$json = $args[0];
12 12
 
13
-        if ($this->isJsonFile($json)) {
14
-            $path = $this->filePath->getFilePath($json);
15
-            if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
16
-            $json = file_get_contents($path);
17
-        }
13
+		if ($this->isJsonFile($json)) {
14
+			$path = $this->filePath->getFilePath($json);
15
+			if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
16
+			$json = file_get_contents($path);
17
+		}
18 18
 
19
-        $map = json_decode($json, true);
19
+		$map = json_decode($json, true);
20 20
 
21
-        if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
21
+		if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
22 22
 
23
-        return $map;
24
-    }
23
+		return $map;
24
+	}
25 25
 
26
-    private function isJsonFile($json) {
27
-        return trim($json)[0] != '{' && trim($json)[0] != '[';
28
-    }
26
+	private function isJsonFile($json) {
27
+		return trim($json)[0] != '{' && trim($json)[0] != '[';
28
+	}
29 29
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,13 +12,17 @@
 block discarded – undo
12 12
 
13 13
         if ($this->isJsonFile($json)) {
14 14
             $path = $this->filePath->getFilePath($json);
15
-            if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
15
+            if (!file_exists($path)) {
16
+            	throw new \Exception('File does not exist at: ' . $path);
17
+            }
16 18
             $json = file_get_contents($path);
17 19
         }
18 20
 
19 21
         $map = json_decode($json, true);
20 22
 
21
-        if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
23
+        if (!is_array($map)) {
24
+        	throw new \Exception('Could not decode json: ' . json_last_error_msg());
25
+        }
22 26
 
23 27
         return $map;
24 28
     }
Please login to merge, or discard this patch.
src/FilePath.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     }
13 13
 
14 14
     public function getFilePath($filePath = "") {
15
-		if (isset($filePath[0]) && $filePath[0] == "/") return $this->customBase . $filePath;
16
-		else return $this->baseDir . $filePath;
15
+		if (isset($filePath[0]) && $filePath[0] == "/") return $this->customBase.$filePath;
16
+		else return $this->baseDir.$filePath;
17 17
 	}
18 18
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,12 +7,18 @@
 block discarded – undo
7 7
 
8 8
     public function __construct(&$baseDir, $customBase = null) {
9 9
         $this->baseDir = &$baseDir;
10
-        if ($customBase === null) $this->customBase = getcwd();
11
-        else $this->customBase = rtrim($customBase, '/');
10
+        if ($customBase === null) {
11
+        	$this->customBase = getcwd();
12
+        } else {
13
+        	$this->customBase = rtrim($customBase, '/');
14
+        }
12 15
     }
13 16
 
14 17
     public function getFilePath($filePath = "") {
15
-		if (isset($filePath[0]) && $filePath[0] == "/") return $this->customBase . $filePath;
16
-		else return $this->baseDir . $filePath;
18
+		if (isset($filePath[0]) && $filePath[0] == "/") {
19
+			return $this->customBase . $filePath;
20
+		} else {
21
+			return $this->baseDir . $filePath;
22
+		}
17 23
 	}
18 24
 }
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,16 +2,16 @@
 block discarded – undo
2 2
 namespace Transphporm;
3 3
 
4 4
 class FilePath {
5
-    private $baseDir;
6
-    private $customBase;
5
+	private $baseDir;
6
+	private $customBase;
7 7
 
8
-    public function __construct(&$baseDir, $customBase = null) {
9
-        $this->baseDir = &$baseDir;
10
-        if ($customBase === null) $this->customBase = getcwd();
11
-        else $this->customBase = rtrim($customBase, '/');
12
-    }
8
+	public function __construct(&$baseDir, $customBase = null) {
9
+		$this->baseDir = &$baseDir;
10
+		if ($customBase === null) $this->customBase = getcwd();
11
+		else $this->customBase = rtrim($customBase, '/');
12
+	}
13 13
 
14
-    public function getFilePath($filePath = "") {
14
+	public function getFilePath($filePath = "") {
15 15
 		if (isset($filePath[0]) && $filePath[0] == "/") return $this->customBase . $filePath;
16 16
 		else return $this->baseDir . $filePath;
17 17
 	}
Please login to merge, or discard this patch.
src/Hook/PseudoMatcher.php 1 patch
Braces   +16 added lines, -9 removed lines patch added patch discarded remove patch
@@ -27,9 +27,10 @@  discard block
 block discarded – undo
27 27
 				try {
28 28
 					$parts = $this->getFuncParts($tokens);
29 29
 					$matches = $function->match($parts['name'], $parts['args'], $element);
30
-					if ($matches === false) return false;
31
-				}
32
-				catch (\Exception $e) {
30
+					if ($matches === false) {
31
+						return false;
32
+					}
33
+				} catch (\Exception $e) {
33 34
 					throw new \Transphporm\RunException(\Transphporm\Exception::PSEUDO, $parts['name'], $e);
34 35
 				}
35 36
 			}
@@ -42,31 +43,37 @@  discard block
 block discarded – undo
42 43
 		$parts['name'] = $this->getFuncName($tokens);
43 44
 		if ($parts['name'] === null || in_array($parts['name'], ['data', 'iteration', 'root'])) {
44 45
 			$parts['args'] = $this->valueParser->parseTokens($tokens);
45
-		}
46
-		else if (count($tokens) > 1) {
46
+		} else if (count($tokens) > 1) {
47 47
 			$tokens->rewind();
48 48
 			$tokens->next();
49 49
 			$parts['args'] = $this->valueParser->parseTokens($tokens->current()['value']);
50
+		} else {
51
+			$parts['args'] = [['']];
50 52
 		}
51
-		else $parts['args'] = [['']];
52 53
 		return $parts;
53 54
 	}
54 55
 
55 56
 	private function getFuncName($tokens) {
56
-		if ($tokens->type() === Tokenizer::NAME) return $tokens->read();
57
+		if ($tokens->type() === Tokenizer::NAME) {
58
+			return $tokens->read();
59
+		}
57 60
 		return null;
58 61
 	}
59 62
 
60 63
 	public function hasFunction($name) {
61 64
 		foreach ($this->pseudo as $tokens) {
62
-			if ($name === $this->getFuncName($tokens)) return true;
65
+			if ($name === $this->getFuncName($tokens)) {
66
+				return true;
67
+			}
63 68
 		}
64 69
 	}
65 70
 
66 71
 	public function getFuncArgs($name) {
67 72
 		foreach ($this->pseudo as $tokens) {
68 73
 			$parts = $this->getFuncParts($tokens);
69
-			if ($name === $parts['name']) return $parts['args'];
74
+			if ($name === $parts['name']) {
75
+				return $parts['args'];
76
+			}
70 77
 		}
71 78
 	}
72 79
 }
Please login to merge, or discard this patch.
src/FunctionSet.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,15 +21,13 @@
 block discarded – undo
21 21
 				$tokens = $args[0];
22 22
 				$parser = new \Transphporm\Parser\Value($this);
23 23
 				$args[0] = $parser->parseTokens($tokens, $this->elementData->getData($this->element));
24
-			}
25
-			else if (isset($args[0]) && $args[0] instanceof Parser\Tokens) {
24
+			} else if (isset($args[0]) && $args[0] instanceof Parser\Tokens) {
26 25
 				$args[0] = iterator_to_array($args[0]);
27 26
 			}
28 27
 			if (isset($this->functions[$name])) {
29 28
 				return $this->functions[$name]->run($args[0], $this->element);
30 29
 			}
31
-		}
32
-		catch (\Exception $e) {
30
+		} catch (\Exception $e) {
33 31
 			throw new RunException(Exception::TSS_FUNCTION, $name, $e);
34 32
 		}
35 33
 		return true;
Please login to merge, or discard this patch.
src/Property/Repeat.php 2 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@  discard block
 block discarded – undo
10 10
 	private $elementData;
11 11
 	private $line;
12 12
 
13
+	/**
14
+	 * @param integer $line
15
+	 */
13 16
 	public function __construct(\Transphporm\FunctionSet $functionSet, \Transphporm\Hook\ElementData $elementData, &$line) {
14 17
 		$this->functionSet = $functionSet;
15 18
 		$this->elementData = $elementData;
@@ -58,6 +61,12 @@  discard block
 block discarded – undo
58 61
 		return $value;
59 62
 	}
60 63
 
64
+	/**
65
+	 * @param \DOMElement $element
66
+	 * @param integer $count
67
+	 *
68
+	 * @return \DOMElement
69
+	 */
61 70
 	private function cloneElement($element, $iteration, $key, $count) {
62 71
 		$clone = $element->cloneNode(true);
63 72
 		$this->tagElement($clone, $count);
@@ -77,6 +86,9 @@  discard block
 block discarded – undo
77 86
 		return isset($values[1]) ? $values[1] : PHP_INT_MAX;
78 87
 	}
79 88
 
89
+	/**
90
+	 * @param \Transphporm\Hook\PseudoMatcher $pseudoMatcher
91
+	 */
80 92
 	private function createHook($newRules, $pseudoMatcher, $properties) {
81 93
 		$var = ""; // PropertyHook requires that baseDir be passed by refrence
82 94
 		// and there is no reason to pass it so create $var to avoid errors
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@  discard block
 block discarded – undo
18 18
 
19 19
 	public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) {
20 20
 		$values = $this->fixEmpty($values);
21
-		if ($element->getAttribute('transphporm') === 'added') return $element->parentNode->removeChild($element);
21
+		if ($element->getAttribute('transphporm') === 'added') {
22
+			return $element->parentNode->removeChild($element);
23
+		}
22 24
 		$max = $this->getMax($values);
23 25
 		$count = 0;
24 26
 
@@ -29,7 +31,9 @@  discard block
 block discarded – undo
29 31
 		$hook = $this->createHook($rules, $pseudoMatcher, $properties);
30 32
 
31 33
 		foreach ($repeat as $key => $iteration) {
32
-			if ($count+1 > $max) break;
34
+			if ($count+1 > $max) {
35
+				break;
36
+			}
33 37
 			$clone = $this->cloneElement($element, $iteration, $key, $count++);
34 38
 			//Re-run the hook on the new element, but use the iterated data
35 39
 			$hook->run($clone);
@@ -41,8 +45,9 @@  discard block
 block discarded – undo
41 45
 
42 46
 	private function getRepeatValue($values, &$max) {
43 47
 		$mode = $this->getMode($values);
44
-		if ($mode === 'each') $repeat = $values[0];
45
-		else if ($mode === 'loop') {
48
+		if ($mode === 'each') {
49
+			$repeat = $values[0];
50
+		} else if ($mode === 'loop') {
46 51
 			$repeat = range($values[0], $max);
47 52
 			$max++;
48 53
 		}
@@ -54,7 +59,9 @@  discard block
 block discarded – undo
54 59
 	}
55 60
 
56 61
 	private function fixEmpty($value) {
57
-		if (empty($value[0])) $value[0] = [];
62
+		if (empty($value[0])) {
63
+			$value[0] = [];
64
+		}
58 65
 		return $value;
59 66
 	}
60 67
 
@@ -70,7 +77,9 @@  discard block
 block discarded – undo
70 77
 
71 78
 	private function tagElement($element, $count) {
72 79
 		//Mark all but one of the nodes as having been added by transphporm, when the hook is run again, these are removed
73
-		if ($count > 0) $element->setAttribute('transphporm', 'added');
80
+		if ($count > 0) {
81
+			$element->setAttribute('transphporm', 'added');
82
+		}
74 83
 	}
75 84
 
76 85
 	private function getMax($values) {
@@ -81,7 +90,9 @@  discard block
 block discarded – undo
81 90
 		$var = ""; // PropertyHook requires that baseDir be passed by refrence
82 91
 		// and there is no reason to pass it so create $var to avoid errors
83 92
 		$hook = new \Transphporm\Hook\PropertyHook($newRules, $var, $this->line, "", $this->line, $pseudoMatcher, new \Transphporm\Parser\Value($this->functionSet), $this->functionSet);
84
-		foreach ($properties as $name => $property) $hook->registerProperty($name, $property);
93
+		foreach ($properties as $name => $property) {
94
+			$hook->registerProperty($name, $property);
95
+		}
85 96
 		return $hook;
86 97
 	}
87 98
 }
Please login to merge, or discard this patch.
src/Parser/ValueData.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 
49 49
 	public function extract($last, $autoLookup, $traversing) {
50 50
 		$value = $this->read($last);
51
-		if ($value && ($autoLookup || $traversing) ) {
51
+		if ($value && ($autoLookup || $traversing)) {
52 52
 			return $value;
53 53
 		}
54 54
 		throw new \UnexpectedValueException('Not found');
Please login to merge, or discard this patch.
Braces   +22 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,16 +14,23 @@  discard block
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	public function traverse($key) {
17
-		if (isset($this->data->{$key})) $this->data = $this->data->{$key};
18
-		else if ((is_array($this->data) || $this->data instanceof \ArrayAccess) && isset($this->data[$key])) $this->data = $this->data[$key];
17
+		if (isset($this->data->{$key})) {
18
+			$this->data = $this->data->{$key};
19
+		} else if ((is_array($this->data) || $this->data instanceof \ArrayAccess) && isset($this->data[$key])) {
20
+			$this->data = $this->data[$key];
21
+		}
19 22
 	}
20 23
 
21 24
 	public function read($value) {
22 25
 		if ((is_array($this->data) || $this->data instanceof \ArrayAccess)) {
23
-			if (isset($this->data[$value])) return $this->data[$value];
26
+			if (isset($this->data[$value])) {
27
+				return $this->data[$value];
28
+			}
29
+		} else if (isset($this->data->$value)) {
30
+			return $this->data->$value;
31
+		} else {
32
+			return false;
24 33
 		}
25
-		else if (isset($this->data->$value)) return $this->data->$value;
26
-		else return false;
27 34
 	}
28 35
 
29 36
 	public function call($func, $args) {
@@ -36,14 +43,20 @@  discard block
 block discarded – undo
36 43
 
37 44
 	public function parseNested($parser, $token, $funcName) {
38 45
 		$args = $parser->parseTokens($token['value'], $this->data);
39
-		if ($args[0] == $this->data) $args = [];
46
+		if ($args[0] == $this->data) {
47
+			$args = [];
48
+		}
40 49
 		return $this->callFuncOnObject($this->data, $funcName, $args);
41 50
 	}
42 51
 
43 52
 	private function callFuncOnObject($obj, $func, $args) {
44
-		if (isset($obj->$func) && is_callable($obj->$func)) return call_user_func_array($obj->$func, $args);
45
-		else if (is_callable([$obj, $func])) return call_user_func_array([$obj, $func], $args);
46
-		else return false;
53
+		if (isset($obj->$func) && is_callable($obj->$func)) {
54
+			return call_user_func_array($obj->$func, $args);
55
+		} else if (is_callable([$obj, $func])) {
56
+			return call_user_func_array([$obj, $func], $args);
57
+		} else {
58
+			return false;
59
+		}
47 60
 	}
48 61
 
49 62
 	public function extract($last, $autoLookup, $traversing) {
Please login to merge, or discard this patch.
src/Parser/ValueResult.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,10 +31,11 @@
 block discarded – undo
31 31
 		];
32 32
 
33 33
 		if ($funcs[$this->mode] === 'concat' && is_numeric($newValue)
34
-			&& is_numeric($this->result[count($this->result)-1]))
35
-			$this->add($newValue);
36
-		else
37
-			$this->{$funcs[$this->mode]}($newValue);
34
+			&& is_numeric($this->result[count($this->result)-1])) {
35
+					$this->add($newValue);
36
+		} else {
37
+					$this->{$funcs[$this->mode]}($newValue);
38
+		}
38 39
 	}
39 40
 
40 41
 	public function arg($value) {
Please login to merge, or discard this patch.