scratch – Blame information for rev 87

Subversion Repositories:
Rev:
Rev Author Line No. Line
87 office 1 <?php
2 /*
3 * One important design goal was the principle of the least surprise.
4 * As PHP is a fully dynamic language with nearly no type-safety, it is common to shoot yourself into the foot because of accidentally mixing up incompatible types.
5 * We protect you from these programing errors by asserting that every callback functions you supply to the library must return a correctly typed value.
6 * In addition, every supported aggregate function will throw an exception if you are accidentally mixing up incompatible types.
7 *
8 * This means that we made this library totally predictable in what it does, and verified that every function has its defined exceptions
9 * which are thrown when certain operations fail, or if certain types are not correct.
10 *
11 */
12 echo "<pre>";
13  
14 require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload
15  
16 use Fusonic\Linq\Linq;
17  
18 /* Throws an UnexpectedValueException if the
19 provided callback function does not return a boolean */
20 Linq::from(array("1", "1"))
21 ->where(function($x) { return "NOT A BOOLEAN"; });
22  
23  
24 /* Throws an UnexpectedValueException if one of the values
25 is not convertible to a numeric value:*/
26 Linq::from(array(1, 2, "Not a numeric value"))
27 ->sum();