at 2009-07-12
in Further reading
by friebe
(0 comments)
In the recently ongoing type-hints discussion on the PHP internals mailinglist (see also the PHP Wiki), an interesting proposal was made. It suggests using functions to verify argument types instead of introducing a type checking mechanism which is not strict enough for some, not flexible enough for others and too magic for yet another group.
<?php function array_of_numeric($x) { foreach ($x as $val) { if (!is_numeric($val)) return FALSE; } return TRUE; } class Arrays { public static function sum(array_of_numeric $a) { return array_sum($a); } } ?> See also here, here and here.
|
Subscribe
You can subscribe to the XP framework's news by using RSS syndication.
CategoriesNews General PHP5 Announcements RFCs Further reading Examples Editorial EASC Experiments Unittests Databases 5.8-SERIES
RelatedFind related articles by a search for «Type».
|