~ubuntu-branches/ubuntu/quantal/php5/quantal

« back to all changes in this revision

Viewing changes to tests/classes/type_hinting_003.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2009-07-01 09:12:10 UTC
  • mto: (0.9.1) (1.1.17 upstream)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20090701091210-go0h6506p62on17r
Tags: upstream-5.3.0
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
ZE2 class type hinting with arrays
 
3
--FILE--
 
4
<?php
 
5
 
 
6
class Test
 
7
{
 
8
        static function f1(array $ar)
 
9
        {
 
10
                echo __METHOD__ . "()\n";
 
11
                var_dump($ar);
 
12
        }
 
13
 
 
14
        static function f2(array $ar = NULL)
 
15
        {
 
16
                echo __METHOD__ . "()\n";
 
17
                var_dump($ar);
 
18
        }
 
19
 
 
20
        static function f3(array $ar = array())
 
21
        {
 
22
                echo __METHOD__ . "()\n";
 
23
                var_dump($ar);
 
24
        }
 
25
 
 
26
        static function f4(array $ar = array(25))
 
27
        {
 
28
                echo __METHOD__ . "()\n";
 
29
                var_dump($ar);
 
30
        }
 
31
}
 
32
 
 
33
Test::f1(array(42));
 
34
Test::f2(NULL);
 
35
Test::f2();
 
36
Test::f3();
 
37
Test::f4();
 
38
Test::f1(1);
 
39
 
 
40
?>
 
41
--EXPECTF--
 
42
Test::f1()
 
43
array(1) {
 
44
  [0]=>
 
45
  int(42)
 
46
}
 
47
Test::f2()
 
48
NULL
 
49
Test::f2()
 
50
NULL
 
51
Test::f3()
 
52
array(0) {
 
53
}
 
54
Test::f4()
 
55
array(1) {
 
56
  [0]=>
 
57
  int(25)
 
58
}
 
59
 
 
60
Catchable fatal error: Argument 1 passed to Test::f1() must be an array, integer given, called in %stype_hinting_003.php on line %d and defined in %stype_hinting_003.php on line %d