Simplifying sourcecode by using type hints

at 2007-02-26 in RFCsAnnouncements by friebe (0 comments)

With the implementation of RFC #0100 (IllegalArgumentException for Type hints) I started migrating code which was manually checking arguments being instances of a certain class to type hints:

For example, this piece of sourcecode from the xml.Node class:

  public function addChild($child) {
if
(!is('Node', $child)) {
throw
new IllegalArgumentException(
'Parameter child must be an xml.Node (given: '.xp::typeOf($child).')'
);
}
// ...
}
was changed to:
  public function addChild(Node $child) {
// ...
}
which will result in the same behaviour.



Subscribe

You can subscribe to the XP framework's news by using RSS syndication.


Categories

News
General
PHP5
Announcements
RFCs
Further reading
Examples
Editorial
EASC
Experiments
Unittests
Databases
5.8-SERIES
Unicode
Language
5.9-SERIES

Related

Find related articles by a search for «Simplifying».