Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
 */ public function getAllDeclarationBlocks(): array { $result = []; foreach ($this->contents as $item) { if ($item instanceof DeclarationBlock) { $result[] = $item; } elseif ($item instanceof CSSBlockList) { $result = \array_merge($result, $item->getAllDeclarationBlocks()); } } return $result; } /** * Returns all `RuleSet` objects recursively found in the tree, no matter how deeply nested the rule sets are. * * @return list */ public function getAllRuleSets(): array { $result = []; foreach ($this->contents as $item) { if ($item instanceof RuleSet) { $result[] = $item; } elseif ($item instanceof CSSBlockList) { $result = \array_merge($result, $item->getAllRuleSets()); } elseif ($item instanceof DeclarationBlock) { $result[] = $item->getRuleSet(); } } return $result; } /** * Returns all `Value` objects found recursively in `Declaration`s in the tree. * * @param CSSElement|null $element * This is the `CSSList` or `RuleSet` to start the search from (defaults to the whole document). * @param string|null $ruleSearchPattern * This allows filtering rules by property name * (e.g. if "color" is passed, only `Value`s from `color` properties will be returned, * or if "font-" is provided, `Value`s from all font rules, like `font-size`, and including `font` itself, * will be returned). * @param bool $searchInFunctionArguments whether to also return `Value` objects used as `CSSFunction` arguments. * * @return list * * @see RuleSet->getRules() */ public function getAllValues( ?CSSElement $element = null, ?string $ruleSearchPattern = null, bool $searchInFunctionArguments = false ): array { $element = $element ?? $this; $result = []; if ($element instanceof CSSBlockList) { foreach ($element->getContents() as $contentItem) { // Statement at-rules are skipped since they do not contain values. if ($contentItem instanceof CSSElement) { $result = \array_merge( $result, $this->getAllValues($contentItem, $ruleSearchPattern, $searchInFunctionArguments) ); } } } elseif ($element instanceof DeclarationList) { foreach ($element->getRules($ruleSearchPattern) as $rule) { $result = \array_merge( $result, $this->getAllValues($rule, $ruleSearchPattern, $searchInFunctionArguments) ); } } elseif ($element instanceof Declaration) { $value = $element->getValue(); // `string` values are discarded. if ($value instanceof CSSElement) { $result = \array_merge( $result, $this->getAllValues($value, $ruleSearchPattern, $searchInFunctionArguments) ); } } elseif ($element instanceof ValueList) { if ($searchInFunctionArguments || !($element instanceof CSSFunction)) { foreach ($element->getListComponents() as $component) { // `string` components are discarded. if ($component instanceof CSSElement) { $result = \array_merge( $result, $this->getAllValues($component, $ruleSearchPattern, $searchInFunctionArguments) ); } } } } elseif ($element instanceof Value) { $result[] = $element; } return $result; } /** * @return list */ protected function getAllSelectors(?string $specificitySearch = null): array { $result = []; foreach ($this->getAllDeclarationBlocks() as $declarationBlock) { foreach ($declarationBlock->getSelectors() as $selector) { if ($specificitySearch === null) { $result[] = $selector; } else { $comparator = '==='; $expressionParts = \explode(' ', $specificitySearch); $targetSpecificity = $expressionParts[0]; if (\count($expressionParts) > 1) { $comparator = $expressionParts[0]; $targetSpecificity = $expressionParts[1]; } $targetSpecificity = (int) $targetSpecificity; $selectorSpecificity = $selector->getSpecificity(); switch ($comparator) { case '<=': $comparatorMatched = $selectorSpecificity <= $targetSpecificity; break; case '<': $comparatorMatched = $selectorSpecificity < $targetSpecificity; break; case '>=': $comparatorMatched = $selectorSpecificity >= $targetSpecificity; break; case '>': $comparatorMatched = $selectorSpecificity > $targetSpecificity; break; default: $comparatorMatched = $selectorSpecificity === $targetSpecificity; break; } if ($comparatorMatched) { $result[] = $selector; } } } } return $result; } }