@@ -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 |
@@ -470,10 +470,10 @@ discard block |
||
470 | 470 | /** |
471 | 471 | * Given a pair of nodes, replace the first with the second |
472 | 472 | * |
473 | - * @param mixed $node |
|
473 | + * @param \DOMElement $node |
|
474 | 474 | * Node to be replaced. Can either be an xpath string or a DOMDocument (or even a DOMNode). |
475 | 475 | * |
476 | - * @param mixed $replace |
|
476 | + * @param \DOMElement $replace |
|
477 | 477 | * Replace $node with $replace. Replace can be an XML string, or a DOMNode |
478 | 478 | * |
479 | 479 | * @return mixed |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | * $context can either be an xpath string, or a DOMElement. Ommiting it |
534 | 534 | * results in transforming the entire document |
535 | 535 | * |
536 | - * @return a new DOMDoc |
|
536 | + * @return DOMDoc new DOMDoc |
|
537 | 537 | */ |
538 | 538 | public function tranform($xsl, $context = NULL) { |
539 | 539 | if (!$context) { |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * it will transform all elements with xlink:type = simple into a <a href> element. |
616 | 616 | * Alternatively you may specify your own xpath for selecting which elements get transformed |
617 | 617 | * into <a href> tags. |
618 | - * @return HTML string |
|
618 | + * @return string string |
|
619 | 619 | */ |
620 | 620 | public function asHTML($context = NULL, $options = array()) { |
621 | 621 | $xslSimple = ' |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | * $context can either be an xpath string, or a DOMElement. Ommiting it |
698 | 698 | * results in outputting the entire document |
699 | 699 | * |
700 | - * @return XML string |
|
700 | + * @return string string |
|
701 | 701 | */ |
702 | 702 | public function out($context = NULL) { |
703 | 703 | $this->createContext($context, 'xpath'); |
@@ -745,6 +745,9 @@ discard block |
||
745 | 745 | ); |
746 | 746 | } |
747 | 747 | |
748 | + /** |
|
749 | + * @param string|boolean $error_checking |
|
750 | + */ |
|
748 | 751 | public function setErrorChecking($error_checking) { |
749 | 752 | // Check up error-checking |
750 | 753 | if ($error_checking == FALSE) { |
@@ -774,6 +777,9 @@ discard block |
||
774 | 777 | return boolval($success); |
775 | 778 | } |
776 | 779 | |
780 | + /** |
|
781 | + * @param integer $options |
|
782 | + */ |
|
777 | 783 | public function loadXML($source, $options = NULL) { |
778 | 784 | $success = parent::loadXML($source, $options); |
779 | 785 | $this->AutoRegisterNamespace(TRUE); |
@@ -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 | if (is_a($xml, 'DOMElement')) { |
45 | 45 | $this->appendChild($this->importNode($xml, true)); |
46 | 46 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | $prefix = $parts[0]; |
325 | 325 | if (isset($namespaces[$prefix])) { |
326 | 326 | if (!strpos($root_match[0], "xmlns:$prefix")) { |
327 | - $new_root .= " xmlns:$prefix='" . $namespaces[$prefix] . "'"; |
|
327 | + $new_root .= " xmlns:$prefix='".$namespaces[$prefix]."'"; |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | |
334 | 334 | $dom = new DOMDoc($xml, $this->auto_ns); |
335 | 335 | if (!$dom->documentElement) { |
336 | - trigger_error('BetterDomDocument\DOMDoc Error: Invalid XML: ' . $xml); |
|
336 | + trigger_error('BetterDomDocument\DOMDoc Error: Invalid XML: '.$xml); |
|
337 | 337 | } |
338 | 338 | $element = $dom->documentElement; |
339 | 339 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | $this->createContext($newnode, 'xml'); |
439 | 439 | $this->createContext($context, 'xpath'); |
440 | 440 | |
441 | - if (!$context){ |
|
441 | + if (!$context) { |
|
442 | 442 | return FALSE; |
443 | 443 | } |
444 | 444 | |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | |
510 | 510 | if ($node) { |
511 | 511 | if (is_array($node) || get_class($node) == 'BetterDOMDocument\DOMList') { |
512 | - foreach($node as $item) { |
|
512 | + foreach ($node as $item) { |
|
513 | 513 | $this->remove($item); |
514 | 514 | } |
515 | 515 | } |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | $xsl = ' |
582 | 582 | <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
583 | 583 | <xsl:template match="*"> |
584 | - <xsl:element name="' . $prefix . ':{local-name()}" namespace="' . $url . '"> |
|
584 | + <xsl:element name="' . $prefix.':{local-name()}" namespace="'.$url.'"> |
|
585 | 585 | <xsl:copy-of select="@*"/> |
586 | 586 | <xsl:apply-templates/> |
587 | 587 | </xsl:element> |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | } |
594 | 594 | else { |
595 | 595 | // @@TODO: Report the correct calling file and number |
596 | - throw new Exception("Changing the namespace of a " . get_class($node) . " is not supported"); |
|
596 | + throw new Exception("Changing the namespace of a ".get_class($node)." is not supported"); |
|
597 | 597 | } |
598 | 598 | } |
599 | 599 | |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | foreach ($this->getNamespaces() as $prefix => $url) { |
669 | 669 | $namespaces = ''; |
670 | 670 | if ($prefix != 'xsl' && $prefix != 'xlink') { |
671 | - $namespaces .= 'xmlns:' . $prefix . '="' . $url. '" '; |
|
671 | + $namespaces .= 'xmlns:'.$prefix.'="'.$url.'" '; |
|
672 | 672 | } |
673 | 673 | $xslOptions = str_replace("||namespaces||", $namespaces, $xslOptions); |
674 | 674 | } |
@@ -707,8 +707,8 @@ discard block |
||
707 | 707 | |
708 | 708 | // Copy namespace prefixes |
709 | 709 | foreach ($this->ns as $prefix => $namespace) { |
710 | - if (!empty($namespace) && !$context->hasAttribute('xmlns:' . $prefix)) { |
|
711 | - $context->setAttribute('xmlns:' . $prefix, $namespace); |
|
710 | + if (!empty($namespace) && !$context->hasAttribute('xmlns:'.$prefix)) { |
|
711 | + $context->setAttribute('xmlns:'.$prefix, $namespace); |
|
712 | 712 | } |
713 | 713 | } |
714 | 714 | |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | // The types listed are html "void" elements. |
719 | 719 | // Find any of these elements that have no child nodes and are therefore candidates for self-closing, replace them with a self-closed version. |
720 | 720 | $pattern = '<(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)(\b[^<]*)><\/\1>'; |
721 | - return preg_replace('/' . $pattern . '/', '<$1$2/>', $output); |
|
721 | + return preg_replace('/'.$pattern.'/', '<$1$2/>', $output); |
|
722 | 722 | } |
723 | 723 | else { |
724 | 724 | return $this->saveXML($context, LIBXML_NOEMPTYTAG); |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | |
787 | 787 | // If it's an "XML" document, then get namespaces via xpath |
788 | 788 | $xpath = new \DOMXPath($this); |
789 | - foreach($xpath->query('namespace::*') as $namespace) { |
|
789 | + foreach ($xpath->query('namespace::*') as $namespace) { |
|
790 | 790 | if (!empty($namespace->prefix)) { |
791 | 791 | if ($namespace->prefix != 'xml' && $namespace->nodeValue != 'http://www.w3.org/XML/1998/namespace') { |
792 | 792 | $this->registerNamespace($namespace->prefix, $namespace->nodeValue); |
@@ -824,8 +824,8 @@ discard block |
||
824 | 824 | } |
825 | 825 | } |
826 | 826 | } |
827 | - else if (substr($attr->name,0,6) == 'xmlns:') { |
|
828 | - $prefix = substr($attr->name,6); |
|
827 | + else if (substr($attr->name, 0, 6) == 'xmlns:') { |
|
828 | + $prefix = substr($attr->name, 6); |
|
829 | 829 | $this->registerNamespace($prefix, $attr->value); |
830 | 830 | } |
831 | 831 | } |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | @$this->loadXML($xml, LIBXML_COMPACT); |
883 | 883 | } |
884 | 884 | else if (!$this->loadXML($xml, LIBXML_COMPACT)) { |
885 | - trigger_error('BetterDOMDocument\DOMDoc: Could not load: ' . htmlspecialchars($xml), E_USER_WARNING); |
|
885 | + trigger_error('BetterDOMDocument\DOMDoc: Could not load: '.htmlspecialchars($xml), E_USER_WARNING); |
|
886 | 886 | } |
887 | 887 | } |
888 | 888 | } |