/** * @return string */ public function __toString() { if (isset($this->context)) { $reflection = new \ReflectionClass(get_class($this->context)); $class_name = $reflection->getShortName(); } else { $class_name = 'no context provided'; } if (isset($this->rule)) { $reflection = new \ReflectionClass(get_class($this->rule)); $rule_name = $reflection->getShortName(); } else { $rule_name = 'no rule provided'; } $has_properties = false; $str_properties = ''; foreach ($this->rule->getProperties() as $name => $value) { if (!$has_properties) { $str_properties = ''; } else { $str_properties = $str_properties . ','; } $reflection = new \ReflectionClass(get_class($value)); $value_name = $reflection->getShortName(); $str_properties = $str_properties . ' ' . $name . '=' . $value_name; } return "Invalid selector for fields ({$this->fields}). " . "The node being transformed was <{$this->node->nodeName}> in the " . "context of {$class_name} within the Rule {$rule_name} with these " . "properties: {{$str_properties}}"; }
public function matchesNode($node) { $matches_node = parent::matchesNode($node); if ($matches_node && $this->childSelector) { $matches_node = false; if ($node->hasChildNodes()) { foreach ($node->childNodes as $child) { $domXPath = new \DOMXPath($child->ownerDocument); $converter = new CssSelectorConverter(); $xpath = $converter->toXPath($this->childSelector); $results = $domXPath->query($xpath, $node); foreach ($results as $result) { if ($result === $child) { $matches_node = true; } } } } } return $matches_node; }