Skip to content

Commit

Permalink
Replace xp::typeOf() with typeof()
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed May 20, 2017
1 parent 8eedc69 commit fd4a4ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ XML APIs for the XP Framework ChangeLog

## ?.?.? / ????-??-??

## 8.0.2 / 2017-05-20

* Refactored code to use `typeof()` instead of `xp::typeOf()`, see
https://github.com/xp-framework/rfc/issues/323
(@thekid)

## 8.0.1 / 2017-01-31

* Code QA (no functional changes!) - @thekid
Expand Down
39 changes: 17 additions & 22 deletions src/main/php/xml/XPath.class.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?php namespace xml;


use lang\IllegalArgumentException;

/**
* XPath class
*
* <code>
* uses('xml.XPath');
* ```php
* use xml\XPath;
*
* $xml= '<dialog id="file.open">
* <caption>Open a file</caption>
* <buttons>
* <button name="ok"/>
* <button name="cancel"/>
* </buttons>
* </dialog>';
* $xml= '<dialog id="file.open">
* <caption>Open a file</caption>
* <buttons>
* <button name="ok"/>
* <button name="cancel"/>
* </buttons>
* </dialog>';
*
* echo create(new XPath($xml))->query('/dialog/buttons/button/@name'));
* </code>
* echo (new XPath($xml))->query('/dialog/buttons/button/@name'));
* ```
*
* @ext dom
* @test xp://xml.unittest.XPathTest
Expand Down Expand Up @@ -56,16 +56,11 @@ protected function loadXML($xml) {
}

/**
* Constructor. Accepts the following types as argument:
* <ul>
* <li>A string containing the XML</li>
* <li>A DomDocument object (as returned by domxml_open_mem, e.g.)</li>
* <li>An xml.Tree object</li>
* </ul>
* Constructor
*
* @param var arg
* @throws lang.IllegalArgumentException
* @throws xml.XMLFormatException in case the argument is a string and not valid XML
* @param string|xml.Tree|php.DomDocument $arg
* @throws lang.IllegalArgumentException
* @throws xml.XMLFormatException in case the argument is a string and not valid XML
*/
public function __construct($arg) {
if ($arg instanceof \DOMDocument) {
Expand All @@ -77,7 +72,7 @@ public function __construct($arg) {
} else if (is_string($arg)) {
$this->context= new \DOMXPath($this->loadXML($arg));
} else {
throw new \lang\IllegalArgumentException('Unsupported parameter type '.\xp::typeOf($arg));
throw new IllegalArgumentException('Unsupported parameter type '.typeof($arg)->getName());
}
}

Expand Down

0 comments on commit fd4a4ff

Please sign in to comment.