Hans Moog wrote:
When it would be:
==
function xpath(DomDocument $arg) {
return new DomXPath($arg);
}
function xpath(XmlTree $arg) {
return new DomXPath($this->loadXML($arg->getSource())));
}
function xpath(string $arg) {
return new DomXPath($this->loadXML($arg));
}
==
function xpathFromDom($arg) {
return new DomXPath($arg);
}
function xpathFromTree($arg) {
return new DomXPath($this->loadXML($arg->getSource())));
}
function xpathFromString($arg) {
return new DomXPath($this->loadXML($arg));
}
Works perfectly well. And you don't even need to document them because
the names speak for themselves. A much simpler (and clearer) solution IMHO.
If you want an OO way I'd prefer something like
$xpath = $obj->getXPath();
to
$xpath = $this->xpath($obj);
anyway. This doesn't work with basic types like strings but having a
special case there is not a problem IMHO as using those two
interchangeably will lead to other problems anyway.
- Chris
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php