@@ -12,6 +12,9 @@ |
||
| 12 | 12 | private $locale; |
| 13 | 13 | private $baseDir; |
| 14 | 14 | |
| 15 | + /** |
|
| 16 | + * @param string $baseDir |
|
| 17 | + */ |
|
| 15 | 18 | public function __construct(\SplObjectStorage $objectStorage, $data, $locale, $baseDir) { |
| 16 | 19 | $this->dataStorage = $objectStorage; |
| 17 | 20 | $this->data = $data; |
@@ -63,6 +63,9 @@ discard block |
||
| 63 | 63 | return $array; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | + /** |
|
| 67 | + * @param \DOMElement $element |
|
| 68 | + */ |
|
| 66 | 69 | private function callFunc($name, $params, $element) { |
| 67 | 70 | if ($name && is_callable([$this->dataFunction, $name])) { |
| 68 | 71 | return $this->dataFunction->$name($this->parse($params, $element), $element); |
@@ -70,6 +73,10 @@ discard block |
||
| 70 | 73 | return false; |
| 71 | 74 | } |
| 72 | 75 | |
| 76 | + /** |
|
| 77 | + * @param string $remaining |
|
| 78 | + * @param \DOMElement $element |
|
| 79 | + */ |
|
| 73 | 80 | private function parseNextValue($remaining, $result, $element) { |
| 74 | 81 | if (strlen($remaining) > 0 && $remaining[0] == ',') $result = array_merge($result, $this->parse(trim(substr($remaining, 1)), $element)); |
| 75 | 82 | return $result; |
@@ -50,6 +50,9 @@ |
||
| 50 | 50 | return $attr; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | + /** |
|
| 54 | + * @param string $comparator |
|
| 55 | + */ |
|
| 53 | 56 | private static function compare($comparator, $a, $b) { |
| 54 | 57 | if ($comparator == '=') return $a == $b; |
| 55 | 58 | else if ($comparator == '!=') return $a != $b; |
@@ -34,6 +34,10 @@ discard block |
||
| 34 | 34 | return (isset($rules['content-mode'])) ? $rules['content-mode'] : 'append'; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | + /** |
|
| 38 | + * @param \DOMElement $element |
|
| 39 | + * @param \Transphporm\Hook\PseudoMatcher $pseudoMatcher |
|
| 40 | + */ |
|
| 37 | 41 | private function processPseudo($value, $element, $pseudoMatcher) { |
| 38 | 42 | $pseudoContent = ['attr', 'header', 'before', 'after']; |
| 39 | 43 | foreach ($pseudoContent as $pseudo) { |
@@ -91,6 +95,9 @@ discard block |
||
| 91 | 95 | foreach ($remove as $r) $r->parentNode->removeChild($r); |
| 92 | 96 | } |
| 93 | 97 | |
| 98 | + /** |
|
| 99 | + * @param \DOMElement $element |
|
| 100 | + */ |
|
| 94 | 101 | private function replaceContent($element, $content) { |
| 95 | 102 | //If this rule was cached, the elements that were added last time need to be removed prior to running the rule again. |
| 96 | 103 | $this->removeAdded($element); |
@@ -100,12 +107,18 @@ discard block |
||
| 100 | 107 | $element->setAttribute('transphporm', 'remove'); |
| 101 | 108 | } |
| 102 | 109 | |
| 110 | + /** |
|
| 111 | + * @param \DOMElement $element |
|
| 112 | + */ |
|
| 103 | 113 | private function appendContent($element, $content) { |
| 104 | 114 | foreach ($this->getNode($content, $element->ownerDocument) as $node) { |
| 105 | 115 | $element->appendChild($node); |
| 106 | 116 | } |
| 107 | 117 | } |
| 108 | 118 | |
| 119 | + /** |
|
| 120 | + * @param \DOMElement $element |
|
| 121 | + */ |
|
| 109 | 122 | private function removeAllChildren($element) { |
| 110 | 123 | while ($element->hasChildNodes()) $element->removeChild($element->firstChild); |
| 111 | 124 | } |
@@ -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); |