Hi,
[...]
Later we added type hints to help code readability.
Let me jump at this:
==
function xpath($arg) {
if ($arg instanceof DomDocument) {
return new DomXPath($arg);
} else if ($arg instanceof XmlTree) {
return new DomXPath($this->loadXML($arg->getSource()));
} else if (is_string($arg)) {
return new DomXPath($this->loadXML($arg));
} else {
throw new IllegalArgumentException('Unsupported argument type');
}
}
== vs. ==
function xpath(DomDocument $arg) {
return new DomXPath($arg);
}
function xpath(XmlTree $arg) {
return new DomXPath($this->loadXML($arg->getSource())));
}
function xpath($arg) { // Untyped = default
if (!is_string($arg)) {
throw new IllegalArgumentException('Unsupported argument type');
}
return new DomXPath($this->loadXML($arg));
}
==
If we consider the readability argument only: Which one of the above more
readable? You decide:)
- Timm
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php