@@ -87,7 +87,7 @@ |
||
87 | 87 | if ($token['type'] === $tokenType) $i++; |
88 | 88 | else $splitTokens[$i][] = $token; |
89 | 89 | } |
90 | - return array_map(function ($tokens) { |
|
90 | + return array_map(function($tokens) { |
|
91 | 91 | return new Tokens($tokens); |
92 | 92 | }, $splitTokens); |
93 | 93 | //return $splitTokens; |
@@ -39,8 +39,11 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | public function add($token) { |
42 | - if ($token instanceof Tokens) $this->tokens = array_merge($token->tokens); |
|
43 | - else $this->tokens[] = $token; |
|
42 | + if ($token instanceof Tokens) { |
|
43 | + $this->tokens = array_merge($token->tokens); |
|
44 | + } else { |
|
45 | + $this->tokens[] = $token; |
|
46 | + } |
|
44 | 47 | } |
45 | 48 | |
46 | 49 | |
@@ -54,9 +57,13 @@ discard block |
||
54 | 57 | |
55 | 58 | private function getKeyToSlice($tokenType) { |
56 | 59 | $keys = $this->getKeysOfTokenType($tokenType); |
57 | - if (empty($keys)) return false; |
|
60 | + if (empty($keys)) { |
|
61 | + return false; |
|
62 | + } |
|
58 | 63 | $key = $keys[0]; |
59 | - for ($i = 0; $key < $this->iterator && isset($keys[$i]); $i++) $key = $keys[$i]; |
|
64 | + for ($i = 0; $key < $this->iterator && isset($keys[$i]); $i++) { |
|
65 | + $key = $keys[$i]; |
|
66 | + } |
|
60 | 67 | return $key; |
61 | 68 | } |
62 | 69 | |
@@ -70,10 +77,17 @@ discard block |
||
70 | 77 | |
71 | 78 | private function sliceTokens($tokenType, $type, $increment = false) { |
72 | 79 | $key = $this->getKeyToSlice($tokenType); |
73 | - if ($key === false) return new Tokens([]); |
|
74 | - if ($increment) $key++; |
|
75 | - if ($type === "from") return new Tokens(array_slice($this->tokens, $key)); |
|
76 | - else return new Tokens(array_slice($this->tokens, $this->iterator, $key)); |
|
80 | + if ($key === false) { |
|
81 | + return new Tokens([]); |
|
82 | + } |
|
83 | + if ($increment) { |
|
84 | + $key++; |
|
85 | + } |
|
86 | + if ($type === "from") { |
|
87 | + return new Tokens(array_slice($this->tokens, $key)); |
|
88 | + } else { |
|
89 | + return new Tokens(array_slice($this->tokens, $this->iterator, $key)); |
|
90 | + } |
|
77 | 91 | } |
78 | 92 | |
79 | 93 | public function skip($count) { |
@@ -84,8 +98,11 @@ discard block |
||
84 | 98 | $splitTokens = []; |
85 | 99 | $i = 0; |
86 | 100 | foreach ($this->tokens as $token) { |
87 | - if ($token['type'] === $tokenType) $i++; |
|
88 | - else $splitTokens[$i][] = $token; |
|
101 | + if ($token['type'] === $tokenType) { |
|
102 | + $i++; |
|
103 | + } else { |
|
104 | + $splitTokens[$i][] = $token; |
|
105 | + } |
|
89 | 106 | } |
90 | 107 | return array_map(function ($tokens) { |
91 | 108 | return new Tokens($tokens); |
@@ -109,7 +126,9 @@ discard block |
||
109 | 126 | |
110 | 127 | public function removeLine() { |
111 | 128 | $tokens = $this->tokens; |
112 | - foreach ($tokens as &$token) unset($token['line']); |
|
129 | + foreach ($tokens as &$token) { |
|
130 | + unset($token['line']); |
|
131 | + } |
|
113 | 132 | return new Tokens($tokens); |
114 | 133 | } |
115 | 134 |
@@ -55,21 +55,21 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | public function read($offset = 0) { |
58 | - return $this->str[$this->pos + $offset]; |
|
58 | + return $this->str[$this->pos+$offset]; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | public function identifyChar($offset = 0) { |
62 | - $chr = $this->str[$this->pos + $offset]; |
|
62 | + $chr = $this->str[$this->pos+$offset]; |
|
63 | 63 | if (!empty($this->chars[$chr])) return $this->chars[$chr]; |
64 | 64 | else return Tokenizer::NAME; |
65 | 65 | } |
66 | 66 | |
67 | 67 | public function has($offset = 0) { |
68 | - return isset($this->str[$this->pos + $offset]); |
|
68 | + return isset($this->str[$this->pos+$offset]); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | public function pos($str) { |
72 | - $pos = strpos($this->str, $str, $this->pos); |
|
72 | + $pos = strpos($this->str, $str, $this->pos); |
|
73 | 73 | return $pos ? $pos-$this->pos : false; |
74 | 74 | } |
75 | 75 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | public function extractString($offset = 0) { |
85 | - $pos = $this->pos + $offset; |
|
85 | + $pos = $this->pos+$offset; |
|
86 | 86 | $char = $this->str[$pos]; |
87 | 87 | $end = strpos($this->str, $char, $pos+1); |
88 | 88 | while ($end !== false && $this->str[$end-1] == '\\') $end = strpos($this->str, $char, $end+1); |
@@ -40,8 +40,11 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | public function move($n) { |
43 | - if ($n === false) $this->pos = strlen($this->str)-1; |
|
44 | - else $this->pos += $n; |
|
43 | + if ($n === false) { |
|
44 | + $this->pos = strlen($this->str)-1; |
|
45 | + } else { |
|
46 | + $this->pos += $n; |
|
47 | + } |
|
45 | 48 | } |
46 | 49 | |
47 | 50 | public function next() { |
@@ -60,8 +63,11 @@ discard block |
||
60 | 63 | |
61 | 64 | public function identifyChar($offset = 0) { |
62 | 65 | $chr = $this->str[$this->pos + $offset]; |
63 | - if (!empty($this->chars[$chr])) return $this->chars[$chr]; |
|
64 | - else return Tokenizer::NAME; |
|
66 | + if (!empty($this->chars[$chr])) { |
|
67 | + return $this->chars[$chr]; |
|
68 | + } else { |
|
69 | + return Tokenizer::NAME; |
|
70 | + } |
|
65 | 71 | } |
66 | 72 | |
67 | 73 | public function has($offset = 0) { |
@@ -85,7 +91,9 @@ discard block |
||
85 | 91 | $pos = $this->pos + $offset; |
86 | 92 | $char = $this->str[$pos]; |
87 | 93 | $end = strpos($this->str, $char, $pos+1); |
88 | - while ($end !== false && $this->str[$end-1] == '\\') $end = strpos($this->str, $char, $end+1); |
|
94 | + while ($end !== false && $this->str[$end-1] == '\\') { |
|
95 | + $end = strpos($this->str, $char, $end+1); |
|
96 | + } |
|
89 | 97 | |
90 | 98 | return substr($this->str, $pos+1, $end-$pos-1); |
91 | 99 | } |
@@ -95,7 +103,9 @@ discard block |
||
95 | 103 | $close = strpos($this->str, $closeBracket, $open); |
96 | 104 | |
97 | 105 | $cPos = $open+1; |
98 | - while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) $close = strpos($this->str, $closeBracket, $close+1); |
|
106 | + while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) { |
|
107 | + $close = strpos($this->str, $closeBracket, $close+1); |
|
108 | + } |
|
99 | 109 | return substr($this->str, $open+1, $close-$open-1); |
100 | 110 | } |
101 | 111 |
@@ -5,7 +5,7 @@ |
||
5 | 5 | |
6 | 6 | class Brackets implements \Transphporm\Parser\Tokenize { |
7 | 7 | |
8 | - private $types = [ |
|
8 | + private $types = [ |
|
9 | 9 | Tokenizer::OPEN_BRACKET => ['(', ')'], |
10 | 10 | Tokenizer::OPEN_BRACE => ['{', '}'], |
11 | 11 | Tokenizer::OPEN_SQUARE_BRACKET => ['[', ']'] |
@@ -32,9 +32,14 @@ |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | private function processLiterals($tokens, $name, $str) { |
35 | - if (is_numeric($name)) $tokens->add(['type' => Tokenizer::NUMERIC, 'value' => $name]); |
|
36 | - else if ($name == 'true') $tokens->add(['type' => Tokenizer::BOOL, 'value' => true]); |
|
37 | - else if ($name == 'false') $tokens->add(['type' => Tokenizer::BOOL, 'value' => false]); |
|
38 | - else $tokens->add(['type' => Tokenizer::NAME, 'value' => $name, 'line' => $str->lineNo()]); |
|
35 | + if (is_numeric($name)) { |
|
36 | + $tokens->add(['type' => Tokenizer::NUMERIC, 'value' => $name]); |
|
37 | + } else if ($name == 'true') { |
|
38 | + $tokens->add(['type' => Tokenizer::BOOL, 'value' => true]); |
|
39 | + } else if ($name == 'false') { |
|
40 | + $tokens->add(['type' => Tokenizer::BOOL, 'value' => false]); |
|
41 | + } else { |
|
42 | + $tokens->add(['type' => Tokenizer::NAME, 'value' => $name, 'line' => $str->lineNo()]); |
|
43 | + } |
|
39 | 44 | } |
40 | 45 | } |
41 | 46 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
10 | 10 | $chr = $str->read(); |
11 | 11 | $string = $str->extractString(); |
12 | 12 | $length = strlen($string)+1; |
13 | - $string = str_replace('\\' . $chr, $chr, $string); |
|
13 | + $string = str_replace('\\'.$chr, $chr, $string); |
|
14 | 14 | $tokens->add(['type' => Tokenizer::STRING, 'value' => $string, 'line' => $str->lineNo()]); |
15 | 15 | $str->move($length); |
16 | 16 | } |
@@ -4,6 +4,9 @@ |
||
4 | 4 | private $insertLocation; |
5 | 5 | private $content; |
6 | 6 | |
7 | + /** |
|
8 | + * @param string $insertLocation |
|
9 | + */ |
|
7 | 10 | public function __construct($insertLocation, \Transphporm\Property\Content $content) { |
8 | 11 | $this->insertLocation = $insertLocation; |
9 | 12 | $this->content = $content; |
@@ -5,10 +5,10 @@ |
||
5 | 5 | $implodedValue = implode('', $value); |
6 | 6 | |
7 | 7 | if ($pseudoMatcher->hasFunction('before')) { |
8 | - $attrValue = $implodedValue . $element->getAttribute($pseudoArgs); |
|
8 | + $attrValue = $implodedValue.$element->getAttribute($pseudoArgs); |
|
9 | 9 | } |
10 | 10 | else if ($pseudoMatcher->hasFunction('after')) { |
11 | - $attrValue = $element->getAttribute($pseudoArgs) . $implodedValue; |
|
11 | + $attrValue = $element->getAttribute($pseudoArgs).$implodedValue; |
|
12 | 12 | } |
13 | 13 | else { |
14 | 14 | $attrValue = implode('', $value); |
@@ -6,11 +6,9 @@ |
||
6 | 6 | |
7 | 7 | if ($pseudoMatcher->hasFunction('before')) { |
8 | 8 | $attrValue = $implodedValue . $element->getAttribute($pseudoArgs); |
9 | - } |
|
10 | - else if ($pseudoMatcher->hasFunction('after')) { |
|
9 | + } else if ($pseudoMatcher->hasFunction('after')) { |
|
11 | 10 | $attrValue = $element->getAttribute($pseudoArgs) . $implodedValue; |
12 | - } |
|
13 | - else { |
|
11 | + } else { |
|
14 | 12 | $attrValue = implode('', $value); |
15 | 13 | } |
16 | 14 |
@@ -2,5 +2,5 @@ |
||
2 | 2 | namespace Transphporm\Property; |
3 | 3 | |
4 | 4 | interface ContentPseudo { |
5 | - public function run($value, $pseudoArgs, $element, \Transphporm\Hook\PseudoMatcher $pseudoMatcher); |
|
5 | + public function run($value, $pseudoArgs, $element, \Transphporm\Hook\PseudoMatcher $pseudoMatcher); |
|
6 | 6 | } |
@@ -6,9 +6,9 @@ |
||
6 | 6 | * @version 1.2 */ |
7 | 7 | namespace Transphporm; |
8 | 8 | class RunException extends \Exception { |
9 | - public function __construct($operationType, $operationName, \Exception $previous = null) { |
|
10 | - $message = 'TSS Error: Problem carrying out ' . $operationType . ' "' . $operationName . '"'; |
|
9 | + public function __construct($operationType, $operationName, \Exception $previous = null) { |
|
10 | + $message = 'TSS Error: Problem carrying out ' . $operationType . ' "' . $operationName . '"'; |
|
11 | 11 | |
12 | - parent::__construct($message, 0, $previous); |
|
13 | - } |
|
12 | + parent::__construct($message, 0, $previous); |
|
13 | + } |
|
14 | 14 | } |
@@ -7,7 +7,7 @@ |
||
7 | 7 | namespace Transphporm; |
8 | 8 | class RunException extends \Exception { |
9 | 9 | public function __construct($operationType, $operationName, \Exception $previous = null) { |
10 | - $message = 'TSS Error: Problem carrying out ' . $operationType . ' "' . $operationName . '"'; |
|
10 | + $message = 'TSS Error: Problem carrying out '.$operationType.' "'.$operationName.'"'; |
|
11 | 11 | |
12 | 12 | parent::__construct($message, 0, $previous); |
13 | 13 | } |