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

« back to all changes in this revision

Viewing changes to PHP_CodeSniffer-1.0.1/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc

  • Committer: Bazaar Package Importer
  • Author(s): Jack Bates
  • Date: 2008-10-01 17:39:43 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20081001173943-2dy06n1e8zwyw1o8
Tags: 1.1.0-1
* New upstream release
* Acknowledge NMU, thanks Jan

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
class PHP_CodeSniffer_File
3
 
{
4
 
 
5
 
    /**
6
 
     * a simple function comment.
7
 
     *
8
 
     * long desc here
9
 
     *
10
 
     * @param bool   $stackPtr   The position in @ @unknown the stack of the token
11
 
     *                             that opened the scope
12
 
     * @param int    $detph    How many scope levels down we are.
13
 
     * @param string    $index    The index
14
 
     * @return
15
 
     * @throws
16
 
     */
17
 
    private function _functionCall($stackPtr, $depth=1, $index)
18
 
    {
19
 
        return $stackPtr;
20
 
 
21
 
    }//end _functionCall()
22
 
 
23
 
    //
24
 
    // Sample function comment
25
 
    //
26
 
    //
27
 
    //
28
 
    public function invalidCommentStyle()
29
 
    {
30
 
 
31
 
    }//end invalidCommentStyle()
32
 
 
33
 
 
34
 
    /**
35
 
     *
36
 
     * A simple function comment
37
 
     * Span multiple line
38
 
     *
39
 
     *
40
 
     * 0Long description with extra blank line before and after
41
 
     *
42
 
     *
43
 
     * @return void
44
 
     */
45
 
    public function extraDescriptionNewlines()
46
 
    {
47
 
        return true;
48
 
    }//end extraDescriptionNewlines()
49
 
 
50
 
 
51
 
    /**
52
 
     * -A simple function comment.
53
 
     * @return void
54
 
     */
55
 
    public function missingNewlinesBeforeTags()
56
 
    {
57
 
        return;
58
 
    }//end missingNewlinesBeforeTags()
59
 
 
60
 
 
61
 
    /**
62
 
     * Access tag should not be treated as a long description.
63
 
     *
64
 
     * @access public
65
 
     * @return void
66
 
     */
67
 
    public function accessTag()
68
 
    {
69
 
 
70
 
    }//end accessTag()
71
 
 
72
 
    /**
73
 
     * Constructor.
74
 
     *
75
 
     * No return tag
76
 
     */
77
 
    function PHP_CodeSniffer_File()
78
 
    {
79
 
        return;
80
 
    }
81
 
 
82
 
 
83
 
    /**
84
 
     * Destructor.
85
 
     *
86
 
     * No return tag too
87
 
     */
88
 
    function _PHP_CodeSniffer_File()
89
 
    {
90
 
        return;
91
 
    }
92
 
 
93
 
 
94
 
    /**
95
 
     * Destructor PHP5.
96
 
     */
97
 
    function __destruct()
98
 
    {
99
 
        return;
100
 
    }
101
 
 
102
 
 
103
 
    function missingComment()
104
 
    {
105
 
        return;
106
 
    }
107
 
 
108
 
 
109
 
    /**
110
 
     * no return tag.
111
 
     *
112
 
     */
113
 
    public function noReturn($one)
114
 
    {
115
 
 
116
 
    }//end noReturn()
117
 
 
118
 
 
119
 
    /**
120
 
     * Param not immediate.
121
 
     *
122
 
     * @return
123
 
     * @param   int   $threeSpaces
124
 
     * @param integer $superfluous
125
 
     * @param miss
126
 
     * @param
127
 
     */
128
 
    public function missingDescription($threeSpaces)
129
 
    {
130
 
 
131
 
    }//end missingDescroption()
132
 
 
133
 
 
134
 
    /**
135
 
     * Comments not capitalised.
136
 
     *
137
 
     * @param integer  $one    comment
138
 
     * @param array    $two    -comment
139
 
     * @param MyClas   $three  0comment
140
 
     *
141
 
     * @since
142
 
     * @return void
143
 
     */
144
 
    public function oneSpaceAfterLongestVar($one, $two, MyClass $three)
145
 
    {
146
 
 
147
 
    }//end oneSpaceAfterLongestVar()
148
 
 
149
 
 
150
 
}//end class
151
 
 
152
 
 
153
 
/**
154
 
 * A simple function comment.
155
 
 *
156
 
 * @param string $str The string passed in by reference
157
 
 *
158
 
 * @return void
159
 
 * @return
160
 
 * @since   %release_version%
161
 
 */
162
 
public function functionOutsideClass(&$str)
163
 
{
164
 
    return;
165
 
}//end functionOutsideClass()
166
 
 
167
 
 
168
 
function missingCommentOutsideClass()
169
 
{
170
 
    return;
171
 
}//end missingCommentOutsideClass()
172
 
 
173
 
 
174
 
?><?php
175
 
function tagBeforeComment()
176
 
{
177
 
    return;
178
 
}//end tagBeforeComment()
179
 
 
180
 
 
181
 
/**
182
 
 * no return tag.
183
 
 *
184
 
 * @see    FunctionCommentSniff.php
185
 
 * @since  unknown.release.date
186
 
 */
187
 
public function noReturnOutsideClass()
188
 
{
189
 
 
190
 
}//end noReturnOutsideClass()
191
 
 
192
 
 
193
 
/**
194
 
 * Missing param comment.
195
 
 *
196
 
 * @param integer $one comment
197
 
 *
198
 
 * @since  4.0.12
199
 
 * @since  4.0.12-rc1
200
 
 * @see     wrong indent
201
 
 * @see
202
 
 * @return void
203
 
 * @extra  Invalid tag
204
 
 * @throws UnknownException unknown
205
 
 */
206
 
public function missingTwoParamComment($one, $two, $three)
207
 
{
208
 
 
209
 
}//end missingTwoParamComment()
210
 
 
211
 
 
212
 
/**
213
 
 * Missing return type.
214
 
 *
215
 
 * @since  4.0.12
216
 
 * @throws ExceptionWithNoComment
217
 
 * @return
218
 
 */
219
 
public function missingReturnType()
220
 
{
221
 
 
222
 
}//end missingReturnType()
223
 
 
224
 
 
225
 
/**
226
 
 * Case-sensitive var type check with multiple return type.
227
 
 *
228
 
 * @param String  $a1 Comment here.
229
 
 * @param BoOL    $a2 Comment here.
230
 
 * @param INT     $a3 Comment here.
231
 
 * @param aRRay   $a4 Comment here.
232
 
 * @param real    $a5 Comment here.
233
 
 * @param double  $a6 Comment here.
234
 
 * @param Myclass $a7 Comment here.
235
 
 *
236
 
 * @since  4.0.12
237
 
 * @return int|object|double|float|array(int=>MyClass)
238
 
 */
239
 
public function caseSensitive($a1, $a2, $a3, arRay $a4, $a5, $a6, myclas $a7)
240
 
{
241
 
 
242
 
}//end caseSensitive()
243
 
 
244
 
 
245
 
/**
246
 
 * More type hint check for custom type and array.
247
 
 *
248
 
 * @param array   $a1 Comment here.
249
 
 * @param array   $a2 Comment here.
250
 
 * @param MyClass $a3 Comment here.
251
 
 * @param MyClass $a4 Comment here.
252
 
 *
253
 
 * @since  4.0.0
254
 
 * @return array(int => MyClass)
255
 
 */
256
 
public function typeHint(MyClass $a1, $a2, myclass $a3, $a4)
257
 
{
258
 
    return (3 => 'myclass obj');
259
 
 
260
 
}//end typeHint()
261
 
 
262
 
 
263
 
/**
264
 
 * Mixed variable type separated by a '|'.
265
 
 *
266
 
 * @param array|string $a1 Comment here.
267
 
 * @param mixed        $a2 Comment here.
268
 
 * @param string|array $a3 Comment here.
269
 
 * @param MyClass|int  $a4 Comment here.
270
 
 *
271
 
 * @since 4.0.0
272
 
 * @return bool
273
 
 */
274
 
public function mixedType($a1, $a2, $a3, $a4)
275
 
{
276
 
    return true;
277
 
 
278
 
}//end mixedType()
279
 
 
280
 
 
281
 
/**
282
 
 * Array type.
283
 
 *
284
 
 * @param array(MyClass)         $a1 OK.
285
 
 * @param array()                $a2 Invalid type.
286
 
 * @param array(                 $a3 Typo.
287
 
 * @param array(int)             $a4 Use 'array(integer)' instead.
288
 
 * @param array(int => integer)  $a5 Use 'array(integer => integer)' instead.
289
 
 * @param array(integer => bool) $a6 Use 'array(integer => boolean)' instead.
290
 
 * @param aRRay                  $a7 Use 'array' instead.
291
 
 * @param string                 $a8 String with unknown type hint.
292
 
 *
293
 
 * @since  4.0.0
294
 
 * @return int
295
 
 */
296
 
public function mixedArrayType($a1, $a2, array $a3, $a4, $a5, $a6, $a7, unknownTypeHint $a8)
297
 
{
298
 
    return 1;
299
 
 
300
 
}//end mixedArrayType()
301
 
 
302
 
 
303
 
/**
304
 
 */
305
 
function empty1()
306
 
{
307
 
}//end empty1()
308
 
 
309
 
 
310
 
/**
311
 
 *
312
 
 */
313
 
function empty2()
314
 
{
315
 
}//end empty2()
316
 
 
317
 
 
318
 
/**
319
 
 *
320
 
 *
321
 
 *
322
 
 */
323
 
function empty3()
324
 
{
325
 
}//end empty3
326
 
 
327
 
 
328
 
/**
329
 
 * @since  4.0.0
330
 
 * @return boolean
331
 
 */
332
 
public function missingShortDescriptionInFunctionComment()
333
 
{
334
 
    return true;
335
 
 
336
 
}//end missingShortDescriptionInFunctionComment()
337
 
 
338
 
 
339
 
class Another_Class
340
 
{
341
 
 
342
 
    /**
343
 
     * Destructor should not include a return tag.
344
 
     *
345
 
     * @since  4.0.0
346
 
     * @return void
347
 
     */
348
 
    function __destruct()
349
 
    {
350
 
        return;
351
 
    }
352
 
 
353
 
    /**
354
 
     * Constructor should not include a return tag.
355
 
     *
356
 
     * @return void
357
 
     */
358
 
    function __construct()
359
 
    {
360
 
        return;
361
 
    }
362
 
 
363
 
}//end class
364
 
 
365
 
 
366
 
/**
367
 
 * Comment param alignment test.
368
 
 *
369
 
 * @param string $varrr1 Comment1..
370
 
 * @param string  $vr2    Comment2.
371
 
 * @param string  $var3  Comment3..
372
 
 *
373
 
 * @since  4.0.0
374
 
 * @return void
375
 
 */
376
 
public static function paramAlign($varrr1, $vr2, $var3)
377
 
{
378
 
 
379
 
}//end paramAlign()
380
 
 
381
 
 
382
 
/**
383
 
 * Comment.
384
 
 *
385
 
 * @param string $id    Comment.
386
 
 * @param array $design Comment.
387
 
 *
388
 
 * @since  4.0.0
389
 
 * @return void
390
 
 */
391
 
public static function paint($id, array $design)
392
 
{
393
 
 
394
 
}//end paint()
395
 
 
396
 
 
397
 
/**
398
 
 * Adds specified class name to class attribute of this widget.
399
 
 *
400
 
 * @since  4.0.0
401
 
 * @return string
402
 
 */
403
 
public function myFunction()
404
 
{
405
 
    if ($condition === FALSE) {
406
 
        echo 'hi';
407
 
    }
408
 
 
409
 
}//end myFunction()
410
 
 
411
 
 
412
 
/**
413
 
 * Adds specified class name to class attribute of this widget.
414
 
 *
415
 
 * @since  4.0.0
416
 
 * @return string
417
 
 */
418
 
public function myFunction()
419
 
{
420
 
    if ($condition === FALSE) {
421
 
        echo 'hi';
422
 
        return;
423
 
    }
424
 
 
425
 
    return 'blah';
426
 
 
427
 
}//end myFunction()
428
 
 
429
 
 
430
 
/**
431
 
 * Adds specified class name to class attribute of this widget.
432
 
 *
433
 
 * @since  4.0.0
434
 
 * @return string
435
 
 */
436
 
public function myFunction()
437
 
{
438
 
    if ($condition === FALSE) {
439
 
        echo 'hi';
440
 
    }
441
 
 
442
 
    return 'blah';
443
 
 
444
 
}//end myFunction()
445
 
 
446
 
/**
447
 
 * Test function.
448
 
 *
449
 
 * @param string $arg1 An argument
450
 
 *
451
 
 * @access public
452
 
 * @return bool
453
 
 */
454
 
 
455
 
echo $blah;
456
 
 
457
 
function myFunction($arg1) {}
458
 
 
459
 
class MyClass() {
460
 
    /**
461
 
     * An abstract function.
462
 
     *
463
 
     * @since  4.0.0
464
 
     * @return array(string)
465
 
     */
466
 
    abstract final protected function myFunction();
467
 
}
468
 
?>