@@ -34,6 +34,9 @@ |
||
34 | 34 | return false; |
35 | 35 | } |
36 | 36 | |
37 | + /** |
|
38 | + * @param \Transphporm\Hook\PseudoMatcher $pseudoMatcher |
|
39 | + */ |
|
37 | 40 | private function createHook($newRules, $pseudoMatcher, $properties) { |
38 | 41 | $hook = new \Transphporm\Hook\PropertyHook($newRules, $pseudoMatcher, new \Transphporm\Parser\Value($this->data)); |
39 | 42 | foreach ($properties as $name => $property) $hook->registerProperty($name, $property); |
@@ -12,6 +12,9 @@ discard block |
||
12 | 12 | private $prefix; |
13 | 13 | private $valueParser; |
14 | 14 | |
15 | + /** |
|
16 | + * @param string $tss |
|
17 | + */ |
|
15 | 18 | public function __construct($tss, $baseDir, Value $valueParser, $prefix = '') { |
16 | 19 | $this->tss = $this->stripComments($tss, '/*', '*/'); |
17 | 20 | $this->tss = $this->stripComments($this->tss, '//', "\n"); |
@@ -38,6 +41,10 @@ discard block |
||
38 | 41 | return $rules; |
39 | 42 | } |
40 | 43 | |
44 | + /** |
|
45 | + * @param string $selector |
|
46 | + * @param integer $index |
|
47 | + */ |
|
41 | 48 | private function CssToRules($selector, $index, $properties) { |
42 | 49 | $parts = explode(',', $selector); |
43 | 50 | $rules = []; |
@@ -60,6 +67,11 @@ discard block |
||
60 | 67 | return $rules; |
61 | 68 | } |
62 | 69 | |
70 | + /** |
|
71 | + * @param integer $pos |
|
72 | + * @param integer $next |
|
73 | + * @param integer $indexStart |
|
74 | + */ |
|
63 | 75 | private function processingInstructions($tss, $pos, $next, $indexStart) { |
64 | 76 | $rules = []; |
65 | 77 | while (($atPos = strpos($tss, '@', $pos)) !== false) { |
@@ -90,6 +102,10 @@ discard block |
||
90 | 102 | return ($a->depth < $b->depth) ? -1 : 1; |
91 | 103 | } |
92 | 104 | |
105 | + /** |
|
106 | + * @param string $open |
|
107 | + * @param string $close |
|
108 | + */ |
|
93 | 109 | private function stripComments($str, $open, $close) { |
94 | 110 | $pos = 0; |
95 | 111 | while (($pos = strpos($str, $open, $pos)) !== false) { |
@@ -100,6 +116,9 @@ discard block |
||
100 | 116 | return $str; |
101 | 117 | } |
102 | 118 | |
119 | + /** |
|
120 | + * @param string $str |
|
121 | + */ |
|
103 | 122 | private function getProperties($str) { |
104 | 123 | $stringExtractor = new StringExtractor($str); |
105 | 124 | $rules = explode(';', $stringExtractor); |
@@ -49,6 +49,10 @@ discard block |
||
49 | 49 | return $result; |
50 | 50 | } |
51 | 51 | |
52 | + /** |
|
53 | + * @param string $function |
|
54 | + * @param \DOMElement $element |
|
55 | + */ |
|
52 | 56 | private function parseString($function, $element) { |
53 | 57 | $result = []; |
54 | 58 | if ($function && in_array($function[0], ['\'', '"'])) { |
@@ -102,6 +106,9 @@ discard block |
||
102 | 106 | else return call_user_func_array([$obj, $func], $params); |
103 | 107 | } |
104 | 108 | |
109 | + /** |
|
110 | + * @param string $remaining |
|
111 | + */ |
|
105 | 112 | private function parseNextValue($remaining, $result, $element) { |
106 | 113 | if (strlen($remaining) > 0 && $remaining[0] == ',') $result = array_merge($result, $this->parse(trim(substr($remaining, 1)), $element)); |
107 | 114 | return $result; |
@@ -13,6 +13,9 @@ discard block |
||
13 | 13 | private $formatter; |
14 | 14 | private $baseDir; |
15 | 15 | |
16 | + /** |
|
17 | + * @param string $baseDir |
|
18 | + */ |
|
16 | 19 | public function __construct(Functionset $functionSet, Hook\ElementData $elementData, Hook\Formatter $formatter, &$headers, &$baseDir) { |
17 | 20 | $this->formatter = $formatter; |
18 | 21 | $this->headers = &$headers; |
@@ -41,10 +44,16 @@ discard block |
||
41 | 44 | return $this->functionSet; |
42 | 45 | } |
43 | 46 | |
47 | + /** |
|
48 | + * @return Hook\ElementData |
|
49 | + */ |
|
44 | 50 | public function getElementData() { |
45 | 51 | return $this->elementData; |
46 | 52 | } |
47 | 53 | |
54 | + /** |
|
55 | + * @param string $name |
|
56 | + */ |
|
48 | 57 | public function registerProperty($name, Property $property) { |
49 | 58 | $this->properties[$name] = $property; |
50 | 59 | } |
@@ -11,6 +11,9 @@ discard block |
||
11 | 11 | private $data; |
12 | 12 | private $baseDir; |
13 | 13 | |
14 | + /** |
|
15 | + * @param string $baseDir |
|
16 | + */ |
|
14 | 17 | public function __construct(Hook\ElementData $elementData, &$baseDir) { |
15 | 18 | $this->baseDir = &$baseDir; |
16 | 19 | $this->elementData = $elementData; |
@@ -23,6 +26,9 @@ discard block |
||
23 | 26 | else return \Transphporm\Parser\Value::IS_NOT_FUNCTION; |
24 | 27 | } |
25 | 28 | |
29 | + /** |
|
30 | + * @param string $name |
|
31 | + */ |
|
26 | 32 | public function addFunction($name, \Transphporm\TSSFunction $function) { |
27 | 33 | $this->functions[$name] = $function; |
28 | 34 | } |
@@ -11,6 +11,9 @@ discard block |
||
11 | 11 | private $formatter; |
12 | 12 | |
13 | 13 | |
14 | + /** |
|
15 | + * @param \Transphporm\FunctionSet $data |
|
16 | + */ |
|
14 | 17 | public function __construct($data, &$headers, \Transphporm\Hook\Formatter $formatter) { |
15 | 18 | $this->data = $data; |
16 | 19 | $this->headers = &$headers; |
@@ -30,6 +33,9 @@ discard block |
||
30 | 33 | } |
31 | 34 | } |
32 | 35 | |
36 | + /** |
|
37 | + * @param \DOMElement $element |
|
38 | + */ |
|
33 | 39 | private function shouldRun($element) { |
34 | 40 | if ($element->getAttribute('transphporm') === 'remove') return false; |
35 | 41 | do { |
@@ -43,6 +49,10 @@ discard block |
||
43 | 49 | return (isset($rules['content-mode'])) ? $rules['content-mode'] : 'append'; |
44 | 50 | } |
45 | 51 | |
52 | + /** |
|
53 | + * @param \DOMElement $element |
|
54 | + * @param \Transphporm\Hook\PseudoMatcher $pseudoMatcher |
|
55 | + */ |
|
46 | 56 | private function processPseudo($value, $element, $pseudoMatcher) { |
47 | 57 | $pseudoContent = ['attr', 'header', 'before', 'after']; |
48 | 58 | foreach ($pseudoContent as $pseudo) { |
@@ -93,6 +103,9 @@ discard block |
||
93 | 103 | } |
94 | 104 | } |
95 | 105 | |
106 | + /** |
|
107 | + * @param \DOMElement $element |
|
108 | + */ |
|
96 | 109 | private function replaceContent($element, $content) { |
97 | 110 | //If this rule was cached, the elements that were added last time need to be removed prior to running the rule again. |
98 | 111 | foreach ($this->getNode($content, $element->ownerDocument) as $node) { |
@@ -101,12 +114,18 @@ discard block |
||
101 | 114 | $element->setAttribute('transphporm', 'remove'); |
102 | 115 | } |
103 | 116 | |
117 | + /** |
|
118 | + * @param \DOMElement $element |
|
119 | + */ |
|
104 | 120 | private function appendContent($element, $content) { |
105 | 121 | foreach ($this->getNode($content, $element->ownerDocument) as $node) { |
106 | 122 | $element->appendChild($node); |
107 | 123 | } |
108 | 124 | } |
109 | 125 | |
126 | + /** |
|
127 | + * @param \DOMElement $element |
|
128 | + */ |
|
110 | 129 | private function removeAllChildren($element) { |
111 | 130 | while ($element->hasChildNodes()) $element->removeChild($element->firstChild); |
112 | 131 | } |
@@ -17,6 +17,9 @@ discard block |
||
17 | 17 | $this->functionSet = $functionSet; |
18 | 18 | } |
19 | 19 | |
20 | + /** |
|
21 | + * @param \DOMElement $element |
|
22 | + */ |
|
20 | 23 | private function traverse($name, $data, $element) { |
21 | 24 | $name = str_replace(['[', ']'], ['.', ''], $name); |
22 | 25 | $parts = explode('.', $name); |
@@ -37,6 +40,9 @@ discard block |
||
37 | 40 | return $obj; |
38 | 41 | } |
39 | 42 | |
43 | + /** |
|
44 | + * @param \Transphporm\Parser\Value $valueParser |
|
45 | + */ |
|
40 | 46 | private function traverseObj($part, $obj, $valueParser, $element) { |
41 | 47 | if (strpos($part, '(') !== false) { |
42 | 48 | $subObjParser = new \Transphporm\Parser\Value($obj, $valueParser, false); |