@@ -148,7 +148,7 @@ |
||
148 | 148 | } |
149 | 149 | else $parsedVal = null; |
150 | 150 | |
151 | - $this->result->postProcess($this->data, $val, $parsedVal, $this->allowNullResult); |
|
151 | + $this->result->postProcess($this->data, $val, $parsedVal, $this->allowNullResult); |
|
152 | 152 | |
153 | 153 | $this->last->clear(); |
154 | 154 | } |
@@ -85,7 +85,7 @@ |
||
85 | 85 | if ($lastResult) { |
86 | 86 | $this->last->makeTraversing(); |
87 | 87 | } |
88 | - else if ($this->last->isEmpty()) { |
|
88 | + else if ($this->last->isEmpty()) { |
|
89 | 89 | $this->processString(['value' => '.']); |
90 | 90 | $this->result->setMode(Tokenizer::CONCAT); |
91 | 91 | } |
@@ -58,7 +58,9 @@ discard block |
||
58 | 58 | $this->last = new Last($this->data, $this->result, $this->autoLookup); |
59 | 59 | $this->traversing = false; |
60 | 60 | |
61 | - if (count($tokens) <= 0) return [$data]; |
|
61 | + if (count($tokens) <= 0) { |
|
62 | + return [$data]; |
|
63 | + } |
|
62 | 64 | |
63 | 65 | foreach (new TokenFilterIterator($tokens, [Tokenizer::WHITESPACE, Tokenizer::NEW_LINE]) as $name => $token) { |
64 | 66 | $this->{$this->tokenFuncs[$token['type']]}($token); |
@@ -86,8 +88,7 @@ discard block |
||
86 | 88 | // foo.bar is treated as looking up `bar` in `foo` whereas .foo is treated as the string ".foo" |
87 | 89 | if ($lastResult) { |
88 | 90 | $this->last->makeTraversing(); |
89 | - } |
|
90 | - else if ($this->last->isEmpty()) { |
|
91 | + } else if ($this->last->isEmpty()) { |
|
91 | 92 | $this->processString(['value' => '.']); |
92 | 93 | $this->result->setMode(Tokenizer::CONCAT); |
93 | 94 | } |
@@ -102,11 +103,12 @@ discard block |
||
102 | 103 | private function processSquareBracket($token) { |
103 | 104 | if ($this->hasFunction($this->last->read())) { |
104 | 105 | $this->callTransphpormFunctions($token); |
105 | - } |
|
106 | - else { |
|
106 | + } else { |
|
107 | 107 | $this->last->traverse(); |
108 | 108 | $this->last->set($this->getNewParser()->parseTokens($token['value'], null)[0]); |
109 | - if (!is_bool($this->last->read())) $this->last->makeTraversing(); |
|
109 | + if (!is_bool($this->last->read())) { |
|
110 | + $this->last->makeTraversing(); |
|
111 | + } |
|
110 | 112 | } |
111 | 113 | } |
112 | 114 | |
@@ -129,8 +131,7 @@ discard block |
||
129 | 131 | if ($this->hasFunction($this->last->read()) |
130 | 132 | && !$this->data->methodExists($this->last->read())) { |
131 | 133 | $this->callTransphpormFunctions($token); |
132 | - } |
|
133 | - else { |
|
134 | + } else { |
|
134 | 135 | $this->last->processNested($this->getNewParser(), $token); |
135 | 136 | } |
136 | 137 | } |
@@ -147,8 +148,9 @@ discard block |
||
147 | 148 | $parser = new Value($this->data->getData()); |
148 | 149 | $parsedArr = $parser->parse($val); |
149 | 150 | $parsedVal = isset($parsedArr[0]) ? $parsedArr[0] : null; |
151 | + } else { |
|
152 | + $parsedVal = null; |
|
150 | 153 | } |
151 | - else $parsedVal = null; |
|
152 | 154 | |
153 | 155 | $this->result->postProcess($this->data, $val, $parsedVal, $this->allowNullResult); |
154 | 156 |
@@ -68,7 +68,9 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | public function registerContentPseudo($name, Property\ContentPseudo $pseudo) { |
71 | - if (isset($this->properties['content'])) $this->properties['content']->addContentPseudo($name, $pseudo); |
|
71 | + if (isset($this->properties['content'])) { |
|
72 | + $this->properties['content']->addContentPseudo($name, $pseudo); |
|
73 | + } |
|
72 | 74 | } |
73 | 75 | |
74 | 76 | public function registerPseudo(Pseudo $pseudo) { |
@@ -76,12 +78,16 @@ discard block |
||
76 | 78 | } |
77 | 79 | |
78 | 80 | public function loadProperties(Hook\PropertyHook $hook) { |
79 | - foreach ($this->properties as $name => $property) $hook->registerProperty($name, $property); |
|
81 | + foreach ($this->properties as $name => $property) { |
|
82 | + $hook->registerProperty($name, $property); |
|
83 | + } |
|
80 | 84 | } |
81 | 85 | |
82 | 86 | public function createPseudoMatcher($pseudo) { |
83 | 87 | $pseudoMatcher = new Hook\PseudoMatcher($pseudo, $this->valueParser); |
84 | - foreach ($this->pseudo as $pseudoFunction) $pseudoMatcher->registerFunction(clone $pseudoFunction); |
|
88 | + foreach ($this->pseudo as $pseudoFunction) { |
|
89 | + $pseudoMatcher->registerFunction(clone $pseudoFunction); |
|
90 | + } |
|
85 | 91 | return $pseudoMatcher; |
86 | 92 | } |
87 | 93 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | public function &getLine() { |
43 | - $line = &$this->line; |
|
43 | + $line = &$this->line; |
|
44 | 44 | return $line; |
45 | 45 | } |
46 | 46 | |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | $this->properties[$name] = $property; |
69 | 69 | } |
70 | 70 | |
71 | - public function registerContentPseudo($name, Property\ContentPseudo $pseudo) { |
|
72 | - if (isset($this->properties['content'])) $this->properties['content']->addContentPseudo($name, $pseudo); |
|
73 | - } |
|
71 | + public function registerContentPseudo($name, Property\ContentPseudo $pseudo) { |
|
72 | + if (isset($this->properties['content'])) $this->properties['content']->addContentPseudo($name, $pseudo); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | public function registerPseudo(Pseudo $pseudo) { |
76 | 76 | $this->pseudo[] = $pseudo; |
@@ -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 |
@@ -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 | } |
@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | $this->functionSet = $functionSet; |
20 | 20 | |
21 | 21 | $this->translators = [ |
22 | - Tokenizer::WHITESPACE => function($string) use ($prefix) { return '//' . $prefix . $string; }, |
|
23 | - Tokenizer::MULTIPLY => function () { return '*'; }, |
|
24 | - '' => function($string) use ($prefix) { return '/' . $prefix . $string; }, |
|
25 | - Tokenizer::GREATER_THAN => function($string) use ($prefix) { return '/' . $prefix . $string; }, |
|
26 | - Tokenizer::NUM_SIGN => function($string) { return '[@id=\'' . $string . '\']'; }, |
|
27 | - Tokenizer::DOT => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' ' . $string . ' \')]'; }, |
|
28 | - Tokenizer::OPEN_SQUARE_BRACKET => function($string) { return '[' .'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \'' . base64_encode(serialize($string)) . '\', ., "' . $this->id . '")' . ']'; } |
|
22 | + Tokenizer::WHITESPACE => function($string) use ($prefix) { return '//'.$prefix.$string; }, |
|
23 | + Tokenizer::MULTIPLY => function() { return '*'; }, |
|
24 | + '' => function($string) use ($prefix) { return '/'.$prefix.$string; }, |
|
25 | + Tokenizer::GREATER_THAN => function($string) use ($prefix) { return '/'.$prefix.$string; }, |
|
26 | + Tokenizer::NUM_SIGN => function($string) { return '[@id=\''.$string.'\']'; }, |
|
27 | + Tokenizer::DOT => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' '.$string.' \')]'; }, |
|
28 | + Tokenizer::OPEN_SQUARE_BRACKET => function($string) { return '['.'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \''.base64_encode(serialize($string)).'\', ., "'.$this->id.'")'.']'; } |
|
29 | 29 | ]; |
30 | 30 | } |
31 | 31 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $functionSet->setElement($element[0]); |
45 | 45 | |
46 | 46 | $attributes = []; |
47 | - foreach($element[0]->attributes as $name => $node) { |
|
47 | + foreach ($element[0]->attributes as $name => $node) { |
|
48 | 48 | $attributes[$name] = $node->nodeValue; |
49 | 49 | } |
50 | 50 |
@@ -69,7 +69,9 @@ discard block |
||
69 | 69 | $selector->type = $token['type']; |
70 | 70 | $selectors[] = $selector; |
71 | 71 | } |
72 | - if (isset($token['value'])) $selectors[count($selectors)-1]->string = $token['value']; |
|
72 | + if (isset($token['value'])) { |
|
73 | + $selectors[count($selectors)-1]->string = $token['value']; |
|
74 | + } |
|
73 | 75 | } |
74 | 76 | return $selectors; |
75 | 77 | } |
@@ -79,7 +81,9 @@ discard block |
||
79 | 81 | $selectors = $this->split($css); |
80 | 82 | $xpath = '/'; |
81 | 83 | foreach ($selectors as $selector) { |
82 | - if (isset($this->translators[$selector->type])) $xpath .= $this->translators[$selector->type]($selector->string, $xpath); |
|
84 | + if (isset($this->translators[$selector->type])) { |
|
85 | + $xpath .= $this->translators[$selector->type]($selector->string, $xpath); |
|
86 | + } |
|
83 | 87 | } |
84 | 88 | |
85 | 89 | $xpath = str_replace('/[', '/*[', $xpath); |
@@ -92,11 +96,15 @@ discard block |
||
92 | 96 | $split = $css->splitOnToken(Tokenizer::GREATER_THAN); |
93 | 97 | $numSplits = count($split); |
94 | 98 | |
95 | - if ($numSplits <= 1) return $css; |
|
99 | + if ($numSplits <= 1) { |
|
100 | + return $css; |
|
101 | + } |
|
96 | 102 | |
97 | 103 | for ($i = 0; $i < $numSplits; $i++) { |
98 | 104 | $tokens->add($split[$i]->trim()); |
99 | - if (isset($split[$i+1])) $tokens->add(['type' => Tokenizer::GREATER_THAN]); |
|
105 | + if (isset($split[$i+1])) { |
|
106 | + $tokens->add(['type' => Tokenizer::GREATER_THAN]); |
|
107 | + } |
|
100 | 108 | } |
101 | 109 | |
102 | 110 | return $tokens; |
@@ -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 | } |