1 | <?php |
||
9 | class Sheet { |
||
10 | private $tss; |
||
11 | private $baseDir; |
||
12 | private $prefix; |
||
13 | private $valueParser; |
||
14 | |||
15 | public function __construct($tss, $baseDir, Value $valueParser, $prefix = '') { |
||
21 | |||
22 | public function parse($pos = 0, $rules = [], $indexStart = 0) { |
||
23 | while ($next = strpos($this->tss, '{', $pos)) { |
||
24 | if ($processing = $this->processingInstructions($this->tss, $pos, $next, count($rules)+$indexStart)) { |
||
25 | $pos = $processing['endPos']+1; |
||
26 | $rules = array_merge($rules, $processing['rules']); |
||
27 | } |
||
28 | |||
29 | $selector = trim(substr($this->tss, $pos, $next-$pos)); |
||
30 | $pos = strpos($this->tss, '}', $next)+1; |
||
31 | $newRules = $this->cssToRules($selector, count($rules)+$indexStart, $this->getProperties(trim(substr($this->tss, $next+1, $pos-2-$next)))); |
||
32 | $rules = $this->writeRule($rules, $newRules); |
||
33 | } |
||
34 | //there may be processing instructions at the end |
||
35 | if ($processing = $this->processingInstructions($this->tss, $pos, strlen($this->tss), count($rules)+$indexStart)) $rules = array_merge($rules, $processing['rules']); |
||
36 | usort($rules, [$this, 'sortRules']); |
||
37 | return $rules; |
||
38 | } |
||
39 | |||
40 | private function CssToRules($selector, $index, $properties) { |
||
41 | $parts = explode(',', $selector); |
||
42 | $rules = []; |
||
43 | foreach ($parts as $part) { |
||
44 | $xPath = new CssToXpath($part, $this->valueParser, $this->prefix); |
||
45 | $rules[$part] = new \Transphporm\Rule($xPath->getXpath(), $xPath->getPseudo(), $xPath->getDepth(), $index++); |
||
46 | $rules[$part]->properties = $properties; |
||
1 ignored issue
–
show
|
|||
47 | } |
||
48 | return $rules; |
||
49 | } |
||
50 | |||
51 | private function writeRule($rules, $newRules) { |
||
52 | foreach ($newRules as $selector => $newRule) { |
||
53 | if (isset($rules[$selector])) { |
||
54 | $newRule->properties = array_merge($rules[$selector]->properties, $newRule->properties); |
||
55 | } |
||
56 | $rules[$selector] = $newRule; |
||
57 | } |
||
58 | |||
59 | return $rules; |
||
60 | } |
||
61 | |||
62 | private function processingInstructions($tss, $pos, $next, $indexStart) { |
||
79 | |||
80 | private function import($args, $indexStart) { |
||
84 | |||
85 | private function sortRules($a, $b) { |
||
91 | |||
92 | private function stripComments($str) { |
||
101 | |||
102 | private function getProperties($str) { |
||
117 | } |
||
118 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.