@@ -62,6 +62,10 @@ discard block |
||
| 62 | 62 | return (object) $result; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | + /** |
|
| 66 | + * @param Template $template |
|
| 67 | + * @param Config $config |
|
| 68 | + */ |
|
| 65 | 69 | private function processRules($template, $config) { |
| 66 | 70 | $rules = $this->getRules($template, $config); |
| 67 | 71 | |
@@ -71,6 +75,10 @@ discard block |
||
| 71 | 75 | } |
| 72 | 76 | |
| 73 | 77 | //Add a postprocessing hook. This cleans up anything transphporm has added to the markup which needs to be removed |
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @param Template $template |
|
| 81 | + */ |
|
| 74 | 82 | private function doPostProcessing($template) { |
| 75 | 83 | $template->addHook('//*[@transphporm]', new Hook\PostProcess()); |
| 76 | 84 | return $template; |
@@ -17,6 +17,9 @@ |
||
| 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 | } |
@@ -7,6 +7,9 @@ |
||
| 7 | 7 | $this->templateFunction = $templateFunction; |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | + /** |
|
| 11 | + * @param string $val |
|
| 12 | + */ |
|
| 10 | 13 | public function html($val) { |
| 11 | 14 | return $this->templateFunction->run(['<template>' . $val . '</template>']); |
| 12 | 15 | } |
@@ -28,6 +28,9 @@ discard block |
||
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | + /** |
|
| 32 | + * @param \DOMElement $element |
|
| 33 | + */ |
|
| 31 | 34 | private function shouldRun($element) { |
| 32 | 35 | do { |
| 33 | 36 | if ($element->getAttribute('transphporm') == 'includedtemplate') return false; |
@@ -40,6 +43,10 @@ discard block |
||
| 40 | 43 | return (isset($rules['content-mode'])) ? $rules['content-mode']->read() : 'append'; |
| 41 | 44 | } |
| 42 | 45 | |
| 46 | + /** |
|
| 47 | + * @param \DOMElement $element |
|
| 48 | + * @param \Transphporm\Hook\PseudoMatcher $pseudoMatcher |
|
| 49 | + */ |
|
| 43 | 50 | private function processPseudo($value, $element, $pseudoMatcher) { |
| 44 | 51 | $pseudoContent = ['attr', 'header', 'before', 'after']; |
| 45 | 52 | foreach ($pseudoContent as $pseudo) { |
@@ -101,6 +108,9 @@ discard block |
||
| 101 | 108 | } |
| 102 | 109 | } |
| 103 | 110 | |
| 111 | + /** |
|
| 112 | + * @param \DOMElement $element |
|
| 113 | + */ |
|
| 104 | 114 | private function replaceContent($element, $content) { |
| 105 | 115 | //If this rule was cached, the elements that were added last time need to be removed prior to running the rule again. |
| 106 | 116 | foreach ($this->getNode($content, $element->ownerDocument) as $node) { |
@@ -109,12 +119,18 @@ discard block |
||
| 109 | 119 | $element->setAttribute('transphporm', 'remove'); |
| 110 | 120 | } |
| 111 | 121 | |
| 122 | + /** |
|
| 123 | + * @param \DOMElement $element |
|
| 124 | + */ |
|
| 112 | 125 | private function appendContent($element, $content) { |
| 113 | 126 | foreach ($this->getNode($content, $element->ownerDocument) as $node) { |
| 114 | 127 | $element->appendChild($node); |
| 115 | 128 | } |
| 116 | 129 | } |
| 117 | 130 | |
| 131 | + /** |
|
| 132 | + * @param \DOMElement $element |
|
| 133 | + */ |
|
| 118 | 134 | private function removeAllChildren($element) { |
| 119 | 135 | while ($element->hasChildNodes()) $element->removeChild($element->firstChild); |
| 120 | 136 | } |
@@ -11,6 +11,9 @@ discard block |
||
| 11 | 11 | private $line; |
| 12 | 12 | private $filePath; |
| 13 | 13 | |
| 14 | + /** |
|
| 15 | + * @param integer $line |
|
| 16 | + */ |
|
| 14 | 17 | public function __construct(\Transphporm\FunctionSet $functionSet, \Transphporm\Hook\ElementData $elementData, &$line, \Transphporm\FilePath $filePath) { |
| 15 | 18 | $this->functionSet = $functionSet; |
| 16 | 19 | $this->elementData = $elementData; |
@@ -58,6 +61,12 @@ discard block |
||
| 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 |
||
| 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 | $hook = new \Transphporm\Hook\PropertyHook($newRules, $this->line, null, $this->line, $pseudoMatcher, new \Transphporm\Parser\Value($this->functionSet), $this->functionSet, $this->filePath); |
| 82 | 94 | foreach ($properties as $name => $property) $hook->registerProperty($name, $property); |
@@ -42,6 +42,9 @@ discard block |
||
| 42 | 42 | return $this->cache->write($this->file, $rules, $this->import); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | + /** |
|
| 46 | + * @param integer $indexStart |
|
| 47 | + */ |
|
| 45 | 48 | private function parseTokens($indexStart) { |
| 46 | 49 | $this->rules = []; |
| 47 | 50 | foreach (new TokenFilterIterator($this->tss, [Tokenizer::WHITESPACE]) as $token) { |
@@ -66,6 +69,9 @@ discard block |
||
| 66 | 69 | if (empty($rules) && count($this->tss) > 0) throw new \Exception('No TSS rules parsed'); |
| 67 | 70 | } |
| 68 | 71 | |
| 72 | + /** |
|
| 73 | + * @param integer $index |
|
| 74 | + */ |
|
| 69 | 75 | private function CssToRules($selector, $index, $properties, $line) { |
| 70 | 76 | $parts = $selector->trim()->splitOnToken(Tokenizer::ARG); |
| 71 | 77 | $rules = []; |
@@ -89,6 +95,9 @@ discard block |
||
| 89 | 95 | return $rules; |
| 90 | 96 | } |
| 91 | 97 | |
| 98 | + /** |
|
| 99 | + * @param integer $indexStart |
|
| 100 | + */ |
|
| 92 | 101 | private function processingInstructions($token, $indexStart) { |
| 93 | 102 | if ($token['type'] !== Tokenizer::AT_SIGN) return false; |
| 94 | 103 | $tokens = $this->tss->from(Tokenizer::AT_SIGN, false)->to(Tokenizer::SEMI_COLON, false); |
@@ -119,6 +128,10 @@ discard block |
||
| 119 | 128 | return ($a->depth < $b->depth) ? -1 : 1; |
| 120 | 129 | } |
| 121 | 130 | |
| 131 | + /** |
|
| 132 | + * @param string $open |
|
| 133 | + * @param string $close |
|
| 134 | + */ |
|
| 122 | 135 | private function stripComments($str, $open, $close) { |
| 123 | 136 | $pos = 0; |
| 124 | 137 | while (($pos = strpos($str, $open, $pos)) !== false) { |
@@ -91,6 +91,10 @@ |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | //Postprocessing - replace values with null where allowed, or override a value at position |
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * @param boolean $allowNull |
|
| 97 | + */ |
|
| 94 | 98 | public function postProcess(ValueData $data, $val, $overrideVal, $allowNull) { |
| 95 | 99 | foreach ($this->getResult() as $i => $value) { |
| 96 | 100 | if (is_scalar($value)) { |
@@ -8,6 +8,9 @@ |
||
| 8 | 8 | $this->paths[] = rtrim($path, DIRECTORY_SEPARATOR); |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | + /** |
|
| 12 | + * @param string $baseDir |
|
| 13 | + */ |
|
| 11 | 14 | public function setBaseDir($baseDir) { |
| 12 | 15 | $this->baseDir = $baseDir; |
| 13 | 16 | } |