1--TEST--
2SPL: Countable::count() with wrong return types and exception.
3--FILE--
4<?php
5
6Class returnNull implements Countable {
7    function count() {
8    }
9}
10
11Class returnString implements Countable {
12    function count() {
13        return "hello";
14    }
15}
16
17Class returnObject implements Countable {
18    function count() {
19        return new returnObject;
20    }
21}
22
23Class returnArray implements Countable {
24    function count() {
25        return array(1,2,3);
26    }
27}
28
29Class throwException implements Countable {
30    function count() {
31        throw new Exception('Thrown from count');
32    }
33}
34
35
36echo "Count returns null:\n";
37var_dump(count(new returnNull));
38
39echo "Count returns a string:\n";
40var_dump(count(new returnString));
41
42echo "Count returns an object:\n";
43var_dump(count(new returnObject));
44
45echo "Count returns an array:\n";
46var_dump(count(new returnArray));
47
48echo "Count throws an exception:\n";
49try {
50    echo count(new throwException);
51} catch (Exception $e) {
52    echo $e->getMessage();
53}
54
55?>
56--EXPECTF--
57Count returns null:
58int(0)
59Count returns a string:
60int(0)
61Count returns an object:
62
63Warning: Object of class returnObject could not be converted to int in %s on line %d
64int(1)
65Count returns an array:
66int(1)
67Count throws an exception:
68Thrown from count
69