~ubuntu-branches/ubuntu/saucy/php-codesniffer/saucy

« back to all changes in this revision

Viewing changes to PHP_CodeSniffer-1.1.0/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentThrowTagUnitTest.inc

  • Committer: Package Import Robot
  • Author(s): Thomas Goirand
  • Date: 2012-05-31 16:37:24 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120531163724-u6aiaubu8ks5dh5z
Tags: 1.3.4-0.1
* Non-maintainer upload.
* New upstream release (Closes: #599617, #634825).
* Swtiched debian/copyright to format 1.0 (rewrite was needed anyway, as the
upstream license changed).
* Switched package to pkg-php-tools and debhelper 8 sequencer.
* Now running unit tests at build time (so depends on phpunit (>= 3.6)).
* Section is now PHP.
* Added missing Build-Depends-Indep: php-pear.
* Added missing ${misc:Depends}.
* Added Vcs fields.
* Added homepage field.
* Reviewed short and long description.
* Added dependency on php-timer.
* Standards-Version: is now 3.9.3 (lots of changes, see above...).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
class FunctionCommentThrowTagUnitTest
3
 
{
4
 
 
5
 
 
6
 
    /**
7
 
     * Missing throw tag.
8
 
     *
9
 
     */
10
 
    public function missingThrowTag()
11
 
    {
12
 
        throw new PHP_Exception('Error');
13
 
 
14
 
    }//end missingThrowTag()
15
 
 
16
 
 
17
 
    /**
18
 
     * Tag and token number mismatch.
19
 
     *
20
 
     * @throws PHP_Exception1
21
 
     */
22
 
    public function oneMoreThrowsTagNeeded()
23
 
    {
24
 
        throw new PHP_Exception1('Error');
25
 
        throw new PHP_Exception2('Error');
26
 
 
27
 
    }//end oneMoreThrowsTagNeeded()
28
 
 
29
 
 
30
 
    /**
31
 
     * Tag and token number mismatch.
32
 
     *
33
 
     * @throws PHP_Exception1
34
 
     * @throws PHP_Exception2
35
 
     */
36
 
    public function oneLessThrowsTagNeeded()
37
 
    {
38
 
        throw new PHP_Exception1('Error');
39
 
 
40
 
    }//end oneLessThrowsTagNeeded()
41
 
 
42
 
 
43
 
    /**
44
 
     * Wrong exception type name.
45
 
     *
46
 
     * @throws PHP_Wrong_Exception
47
 
     */
48
 
    public function wrongExceptionName()
49
 
    {
50
 
        throw new PHP_Correct_Exception('Error');
51
 
 
52
 
    }//end wrongExceptionName()
53
 
 
54
 
 
55
 
    /**
56
 
     * Wrong exception type name.
57
 
     *
58
 
     * @throws PHP_Correct_Exception1
59
 
     * @throws PHP_Wrong_Exception2
60
 
     * @throws PHP_Wrong_Exception3
61
 
     */
62
 
    public function moreWrongExceptionName()
63
 
    {
64
 
        throw new PHP_Correct_Exception1('Error');
65
 
        throw new PHP_Correct_Exception2('Error');
66
 
        throw new PHP_Correct_Exception3('Error');
67
 
 
68
 
    }//end moreWrongExceptionName()
69
 
 
70
 
 
71
 
    /**
72
 
     * Wrong exception type name.
73
 
     *
74
 
     * @throws PHP_Correct_Exception
75
 
     */
76
 
    public function sameExceptionName()
77
 
    {
78
 
        throw new PHP_Correct_Exception('Error');
79
 
        throw new PHP_Correct_Exception('Error');
80
 
 
81
 
    }//end sameExceptionName()
82
 
 
83
 
 
84
 
    /**
85
 
     * This is a valid chunk.
86
 
     *
87
 
     * @throws PHP_Exception1
88
 
     * @throws PHP_Exception2
89
 
     */
90
 
    public function thisShouldWorkOK()
91
 
    {
92
 
        throw new PHP_Exception2('Error');
93
 
        throw new PHP_Exception1('Error');
94
 
        throw new PHP_Exception2('Error');
95
 
        throw new PHP_Exception1('Error');
96
 
        throw new PHP_Exception2('Error');
97
 
 
98
 
    }//end thisShouldWorkOK()
99
 
 
100
 
 
101
 
    /**
102
 
     * This is not OK, missing 2 @throws tag.
103
 
     *
104
 
     * @throws PHP_Exception1
105
 
     * @throws PHP_Exception2
106
 
     */
107
 
    public function notOK()
108
 
    {
109
 
        throw new PHP_Missing_Exception1('Error');
110
 
        throw new PHP_Exception2('Error');
111
 
        throw new PHP_Missing_Exception2('Error');
112
 
        throw new PHP_Missing_Exception2('Error');
113
 
        throw new PHP_Exception1('Error');
114
 
        throw new PHP_Exception2('Error');
115
 
        throw new PHP_Missing_Exception1('Error');
116
 
 
117
 
    }//end notOK()
118
 
 
119
 
 
120
 
    /**
121
 
     * Needs at least 1 throws tag, even though we
122
 
     * don't know what it is.
123
 
     */
124
 
    public function notOKVariable()
125
 
    {
126
 
        try {
127
 
            // Do something.
128
 
        } catch (PHP_Exception2 $e) {
129
 
            logError();
130
 
            throw $e;
131
 
        }
132
 
 
133
 
    }//end notOKVariable()
134
 
 
135
 
 
136
 
    /**
137
 
     * Needs at least 1 throws tag, even though we
138
 
     * don't know what it is.
139
 
     *
140
 
     * @throws PHP_Exception1
141
 
     */
142
 
    public function okVariable()
143
 
    {
144
 
        throw new PHP_Exception1('Error');
145
 
 
146
 
        try {
147
 
            // Do something.
148
 
        } catch (PHP_Exception1 $e) {
149
 
            logError();
150
 
            throw $e;
151
 
        }
152
 
 
153
 
    }//end okVariable()
154
 
 
155
 
 
156
 
    /**
157
 
     * Needs 1 @throws tag.
158
 
     *
159
 
     * @throws Exception Unknown exception type.
160
 
     */
161
 
    function okVariable()
162
 
    {
163
 
        throw $e;
164
 
 
165
 
    }//end okVariable()
166
 
 
167
 
 
168
 
}//end class
169
 
?>