~ubuntu-branches/ubuntu/wily/php-codesniffer/wily

« back to all changes in this revision

Viewing changes to PHP_CodeSniffer-1.5.3/CodeSniffer/Standards/PSR2/Tests/ControlStructures/SwitchDeclarationUnitTest.inc

  • Committer: Package Import Robot
  • Author(s): David Prévot
  • Date: 2014-07-21 14:42:41 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20140721144241-g4orlcuk4jzn9mhs
Tags: 1.5.3-1
* Team upload
* Focus on stable release
* Update copyright
* Bump standards version to 3.9.5
* Update Homepage
* Use ${phppear:…} instead of hardcoding them
* Run tests in dh_auto_test
* Update patch with gbp pq
* Simplify configuration installation
* Edit package.xml to move script
* Add DEP-8 tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
switch ($expr) {
 
3
    case 0:
 
4
        echo 'First case, with a break';
 
5
        break;
 
6
    case 1:
 
7
        echo 'Second case, which falls through';
 
8
        // no break
 
9
    case 2:
 
10
    case 3:
 
11
    case 4:
 
12
        echo 'Third case, return instead of break';
 
13
        return;
 
14
    default:
 
15
        echo 'Default case';
 
16
        break;
 
17
}
 
18
 
 
19
switch ($expr) {
 
20
    case 0:
 
21
        echo 'First case,';
 
22
 
 
23
    case 1 :
 
24
        echo 'Second case';
 
25
        // no break
 
26
case 2:
 
27
    case 3:
 
28
        echo 'Third case';
 
29
    return;
 
30
 
 
31
    default:
 
32
        echo 'Default case';
 
33
    break;
 
34
}
 
35
 
 
36
switch ($foo) {
 
37
    case 'Foo': {
 
38
        echo 'foo';
 
39
        break;
 
40
        }
 
41
}
 
42
 
 
43
while ($i < 10) {
 
44
    switch ($foo) {
 
45
        case '1':
 
46
        case '2':
 
47
            ++$i;
 
48
            continue 2;
 
49
        case '3':
 
50
            return $i;
 
51
    }
 
52
}
 
53
 
 
54
switch (true) {
 
55
    case is_resource($value):
 
56
        throw new Exception('foo');
 
57
    case is_object($value):
 
58
        return 'object';
 
59
}
 
60
 
 
61
switch (0) {
 
62
    case 0:
 
63
        switch (1) {
 
64
            case 1:
 
65
                echo 'a';
 
66
                break;
 
67
        }
 
68
        break;
 
69
}
 
70
 
 
71
switch ($foo) {
 
72
    case Foo::ONE:
 
73
    case Foo::TWO:
 
74
    case Foo::Class:
 
75
        break;
 
76
}
 
77
 
 
78
switch (true) {
 
79
    case $value instanceof StdClass:
 
80
        return 1;
 
81
    case strpos('_', get_class($value)) !== false:
 
82
        break;
 
83
}
 
84
 
 
85
switch (true) {
 
86
    case $value instanceof StdClass:
 
87
        if ($value) {
 
88
            return null;
 
89
        }
 
90
}
 
91
?>