@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | * $xml can either be an XML string, a DOMDocument, or a DOMElement. |
23 | 23 | * You can also pass FALSE or NULL (or omit it) and load XML later using loadXML or loadHTML |
24 | 24 | * |
25 | - * @param mixed $auto_register_namespaces |
|
25 | + * @param boolean $auto_register_namespaces |
|
26 | 26 | * Auto-register namespaces. All namespaces in the root element will be registered for use in xpath queries. |
27 | 27 | * Namespaces that are not declared in the root element will not be auto-registered |
28 | 28 | * Defaults to TRUE (Meaning it will auto register all auxiliary namespaces but not the default namespace). |
29 | 29 | * Pass a prefix string to automatically register the default namespace. |
30 | 30 | * Pass FALSE to disable auto-namespace registeration |
31 | 31 | * |
32 | - * @param bool $error_checking |
|
32 | + * @param string|boolean $error_checking |
|
33 | 33 | * Can be 'strict', 'warning', or 'none. Defaults to 'strict'. |
34 | 34 | * 'none' supresses all errors |
35 | 35 | * 'warning' is the default behavior in DOMDocument |
@@ -489,10 +489,10 @@ discard block |
||
489 | 489 | /** |
490 | 490 | * Given a pair of nodes, replace the first with the second |
491 | 491 | * |
492 | - * @param mixed $node |
|
492 | + * @param \DOMElement $node |
|
493 | 493 | * Node to be replaced. Can either be an xpath string or a DOMDocument (or even a DOMNode). |
494 | 494 | * |
495 | - * @param mixed $replace |
|
495 | + * @param \DOMElement $replace |
|
496 | 496 | * Replace $node with $replace. Replace can be an XML string, or a DOMNode |
497 | 497 | * |
498 | 498 | * @return mixed |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | * $context can either be an xpath string, or a DOMElement. Ommiting it |
553 | 553 | * results in transforming the entire document |
554 | 554 | * |
555 | - * @return a new DOMDoc |
|
555 | + * @return DOMDoc new DOMDoc |
|
556 | 556 | */ |
557 | 557 | function tranform($xsl, $context = NULL) { |
558 | 558 | if (!$context) { |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | * it will transform all elements with xlink:type = simple into a <a href> element. |
637 | 637 | * Alternatively you may specify your own xpath for selecting which elements get transformed |
638 | 638 | * into <a href> tags. |
639 | - * @return HTML string |
|
639 | + * @return string string |
|
640 | 640 | */ |
641 | 641 | function asHTML($context = NULL, $options = array()) { |
642 | 642 | $xslSimple = ' |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | * $context can either be an xpath string, or a DOMElement. Ommiting it |
719 | 719 | * results in outputting the entire document |
720 | 720 | * |
721 | - * @return XML string |
|
721 | + * @return string string |
|
722 | 722 | */ |
723 | 723 | function out($context = NULL) { |
724 | 724 | $this->createContext($context, 'xpath'); |
@@ -753,6 +753,9 @@ discard block |
||
753 | 753 | return $this->out(); |
754 | 754 | } |
755 | 755 | |
756 | + /** |
|
757 | + * @param string|boolean $error_checking |
|
758 | + */ |
|
756 | 759 | public function setErrorChecking($error_checking) { |
757 | 760 | // Check up error-checking |
758 | 761 | if ($error_checking == FALSE) { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | $this->setErrorChecking($error_checking); |
42 | 42 | |
43 | - if(is_object($xml)){ |
|
43 | + if (is_object($xml)) { |
|
44 | 44 | $class = get_class($xml); |
45 | 45 | if ($class == 'DOMElement') { |
46 | 46 | $this->appendChild($this->importNode($xml, true)); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | } |
65 | 65 | else { |
66 | 66 | if (!$this->loadXML($xml, LIBXML_COMPACT)) { |
67 | - trigger_error('BetterDOMDocument\DOMDoc: Could not load: ' . htmlspecialchars($xml), E_USER_WARNING); |
|
67 | + trigger_error('BetterDOMDocument\DOMDoc: Could not load: '.htmlspecialchars($xml), E_USER_WARNING); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | } |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $prefix = $parts[0]; |
330 | 330 | if (isset($namespaces[$prefix])) { |
331 | 331 | if (!strpos($root_match[0], "xmlns:$prefix")) { |
332 | - $new_root .= " xmlns:$prefix='" . $namespaces[$prefix] . "'"; |
|
332 | + $new_root .= " xmlns:$prefix='".$namespaces[$prefix]."'"; |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | |
339 | 339 | $dom = new DOMDoc($xml, $this->auto_ns); |
340 | 340 | if (!$dom->documentElement) { |
341 | - trigger_error('BetterDomDocument\DOMDoc Error: Invalid XML: ' . $xml); |
|
341 | + trigger_error('BetterDomDocument\DOMDoc Error: Invalid XML: '.$xml); |
|
342 | 342 | } |
343 | 343 | $element = $dom->documentElement; |
344 | 344 | |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | $this->createContext($newnode, 'xml'); |
451 | 451 | $this->createContext($context, 'xpath'); |
452 | 452 | |
453 | - if (!$context){ |
|
453 | + if (!$context) { |
|
454 | 454 | return FALSE; |
455 | 455 | } |
456 | 456 | |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | |
529 | 529 | if ($node) { |
530 | 530 | if (is_array($node) || get_class($node) == 'BetterDOMDocument\DOMList') { |
531 | - foreach($node as $item) { |
|
531 | + foreach ($node as $item) { |
|
532 | 532 | $this->remove($item); |
533 | 533 | } |
534 | 534 | } |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | $xsl = ' |
603 | 603 | <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
604 | 604 | <xsl:template match="*"> |
605 | - <xsl:element name="' . $prefix . ':{local-name()}" namespace="' . $url . '"> |
|
605 | + <xsl:element name="' . $prefix.':{local-name()}" namespace="'.$url.'"> |
|
606 | 606 | <xsl:copy-of select="@*"/> |
607 | 607 | <xsl:apply-templates/> |
608 | 608 | </xsl:element> |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | } |
615 | 615 | else { |
616 | 616 | // @@TODO: Report the correct calling file and number |
617 | - throw new Exception("Changing the namespace of a " . get_class($node) . " is not supported"); |
|
617 | + throw new Exception("Changing the namespace of a ".get_class($node)." is not supported"); |
|
618 | 618 | } |
619 | 619 | } |
620 | 620 | |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | foreach ($this->getNamespaces() as $prefix => $url) { |
690 | 690 | $namespaces = ''; |
691 | 691 | if ($prefix != 'xsl' && $prefix != 'xlink') { |
692 | - $namespaces .= 'xmlns:' . $prefix . '="' . $url. '" '; |
|
692 | + $namespaces .= 'xmlns:'.$prefix.'="'.$url.'" '; |
|
693 | 693 | } |
694 | 694 | $xslOptions = str_replace("||namespaces||", $namespaces, $xslOptions); |
695 | 695 | } |
@@ -728,8 +728,8 @@ discard block |
||
728 | 728 | |
729 | 729 | // Copy namespace prefixes |
730 | 730 | foreach ($this->ns as $prefix => $namespace) { |
731 | - if (!$context->hasAttribute('xmlns:' . $prefix)) { |
|
732 | - $context->setAttribute('xmlns:' . $prefix, $namespace); |
|
731 | + if (!$context->hasAttribute('xmlns:'.$prefix)) { |
|
732 | + $context->setAttribute('xmlns:'.$prefix, $namespace); |
|
733 | 733 | } |
734 | 734 | } |
735 | 735 | |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | // The types listed are html "void" elements. |
740 | 740 | // Find any of these elements that have no child nodes and are therefore candidates for self-closing, replace them with a self-closed version. |
741 | 741 | $pattern = '<(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)(\b[^<]*)><\/\1>'; |
742 | - return preg_replace('/' . $pattern . '/', '<$1$2/>', $output); |
|
742 | + return preg_replace('/'.$pattern.'/', '<$1$2/>', $output); |
|
743 | 743 | } |
744 | 744 | else { |
745 | 745 | return $this->saveXML($context, LIBXML_NOEMPTYTAG); |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | |
781 | 781 | // If it's an "XML" document, then get namespaces via xpath |
782 | 782 | $xpath = new \DOMXPath($this); |
783 | - foreach($xpath->query('namespace::*') as $namespace) { |
|
783 | + foreach ($xpath->query('namespace::*') as $namespace) { |
|
784 | 784 | if (!empty($namespace->prefix)) { |
785 | 785 | if ($namespace->prefix != 'xml' && $namespace->nodeValue != 'http://www.w3.org/XML/1998/namespace') { |
786 | 786 | $this->registerNamespace($namespace->prefix, $namespace->nodeValue); |
@@ -818,8 +818,8 @@ discard block |
||
818 | 818 | } |
819 | 819 | } |
820 | 820 | } |
821 | - else if (substr($attr->name,0,6) == 'xmlns:') { |
|
822 | - $prefix = substr($attr->name,6); |
|
821 | + else if (substr($attr->name, 0, 6) == 'xmlns:') { |
|
822 | + $prefix = substr($attr->name, 6); |
|
823 | 823 | $this->registerNamespace($prefix, $attr->value); |
824 | 824 | } |
825 | 825 | } |