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

« back to all changes in this revision

Viewing changes to PHP_CodeSniffer-1.3.4/CodeSniffer/CommentParser/ClassCommentParser.php

  • 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
/**
 
3
 * Parses Class doc comments.
 
4
 *
 
5
 * PHP version 5
 
6
 *
 
7
 * @category  PHP
 
8
 * @package   PHP_CodeSniffer
 
9
 * @author    Greg Sherwood <gsherwood@squiz.net>
 
10
 * @author    Marc McIntyre <mmcintyre@squiz.net>
 
11
 * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600)
 
12
 * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
 
13
 * @link      http://pear.php.net/package/PHP_CodeSniffer
 
14
 */
 
15
 
 
16
if (class_exists('PHP_CodeSniffer_CommentParser_AbstractParser', true) === false) {
 
17
    $error = 'Class PHP_CodeSniffer_CommentParser_AbstractParser not found';
 
18
    throw new PHP_CodeSniffer_Exception($error);
 
19
}
 
20
 
 
21
/**
 
22
 * Parses Class doc comments.
 
23
 *
 
24
 * @category  PHP
 
25
 * @package   PHP_CodeSniffer
 
26
 * @author    Greg Sherwood <gsherwood@squiz.net>
 
27
 * @author    Marc McIntyre <mmcintyre@squiz.net>
 
28
 * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600)
 
29
 * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
 
30
 * @version   Release: 1.3.4
 
31
 * @link      http://pear.php.net/package/PHP_CodeSniffer
 
32
 */
 
33
class PHP_CodeSniffer_CommentParser_ClassCommentParser extends PHP_CodeSniffer_CommentParser_AbstractParser
 
34
{
 
35
 
 
36
    /**
 
37
     * The package element of this class.
 
38
     *
 
39
     * @var SingleElement
 
40
     */
 
41
    private $_package = null;
 
42
 
 
43
    /**
 
44
     * The subpackage element of this class.
 
45
     *
 
46
     * @var SingleElement
 
47
     */
 
48
    private $_subpackage = null;
 
49
 
 
50
    /**
 
51
     * The version element of this class.
 
52
     *
 
53
     * @var SingleElement
 
54
     */
 
55
    private $_version = null;
 
56
 
 
57
    /**
 
58
     * The category element of this class.
 
59
     *
 
60
     * @var SingleElement
 
61
     */
 
62
    private $_category = null;
 
63
 
 
64
    /**
 
65
     * The copyright elements of this class.
 
66
     *
 
67
     * @var array(SingleElement)
 
68
     */
 
69
    private $_copyrights = array();
 
70
 
 
71
    /**
 
72
     * The licence element of this class.
 
73
     *
 
74
     * @var PairElement
 
75
     */
 
76
    private $_license = null;
 
77
 
 
78
    /**
 
79
     * The author elements of this class.
 
80
     *
 
81
     * @var array(SingleElement)
 
82
     */
 
83
    private $_authors = array();
 
84
 
 
85
 
 
86
    /**
 
87
     * Returns the allowed tags withing a class comment.
 
88
     *
 
89
     * @return array(string => int)
 
90
     */
 
91
    protected function getAllowedTags()
 
92
    {
 
93
        return array(
 
94
                'category'   => false,
 
95
                'package'    => true,
 
96
                'subpackage' => true,
 
97
                'author'     => false,
 
98
                'copyright'  => true,
 
99
                'license'    => false,
 
100
                'version'    => true,
 
101
               );
 
102
 
 
103
    }//end getAllowedTags()
 
104
 
 
105
 
 
106
    /**
 
107
     * Parses the license tag of this class comment.
 
108
     *
 
109
     * @param array $tokens The tokens that comprise this tag.
 
110
     *
 
111
     * @return PHP_CodeSniffer_CommentParser_PairElement
 
112
     */
 
113
    protected function parseLicense($tokens)
 
114
    {
 
115
        $this->_license = new PHP_CodeSniffer_CommentParser_PairElement(
 
116
            $this->previousElement,
 
117
            $tokens,
 
118
            'license',
 
119
            $this->phpcsFile
 
120
        );
 
121
 
 
122
        return $this->_license;
 
123
 
 
124
    }//end parseLicense()
 
125
 
 
126
 
 
127
    /**
 
128
     * Parses the copyright tags of this class comment.
 
129
     *
 
130
     * @param array $tokens The tokens that comprise this tag.
 
131
     *
 
132
     * @return PHP_CodeSniffer_CommentParser_SingleElement
 
133
     */
 
134
    protected function parseCopyright($tokens)
 
135
    {
 
136
        $copyright = new PHP_CodeSniffer_CommentParser_SingleElement(
 
137
            $this->previousElement,
 
138
            $tokens,
 
139
            'copyright',
 
140
            $this->phpcsFile
 
141
        );
 
142
 
 
143
        $this->_copyrights[] = $copyright;
 
144
        return $copyright;
 
145
 
 
146
    }//end parseCopyright()
 
147
 
 
148
 
 
149
    /**
 
150
     * Parses the category tag of this class comment.
 
151
     *
 
152
     * @param array $tokens The tokens that comprise this tag.
 
153
     *
 
154
     * @return PHP_CodeSniffer_CommentParser_SingleElement
 
155
     */
 
156
    protected function parseCategory($tokens)
 
157
    {
 
158
        $this->_category = new PHP_CodeSniffer_CommentParser_SingleElement(
 
159
            $this->previousElement,
 
160
            $tokens,
 
161
            'category',
 
162
            $this->phpcsFile
 
163
        );
 
164
 
 
165
        return $this->_category;
 
166
 
 
167
    }//end parseCategory()
 
168
 
 
169
 
 
170
    /**
 
171
     * Parses the author tag of this class comment.
 
172
     *
 
173
     * @param array $tokens The tokens that comprise this tag.
 
174
     *
 
175
     * @return array(PHP_CodeSniffer_CommentParser_SingleElement)
 
176
     */
 
177
    protected function parseAuthor($tokens)
 
178
    {
 
179
        $author = new PHP_CodeSniffer_CommentParser_SingleElement(
 
180
            $this->previousElement,
 
181
            $tokens,
 
182
            'author',
 
183
            $this->phpcsFile
 
184
        );
 
185
 
 
186
        $this->_authors[] = $author;
 
187
        return $author;
 
188
 
 
189
    }//end parseAuthor()
 
190
 
 
191
 
 
192
    /**
 
193
     * Parses the version tag of this class comment.
 
194
     *
 
195
     * @param array $tokens The tokens that comprise this tag.
 
196
     *
 
197
     * @return PHP_CodeSniffer_CommentParser_SingleElement
 
198
     */
 
199
    protected function parseVersion($tokens)
 
200
    {
 
201
        $this->_version = new PHP_CodeSniffer_CommentParser_SingleElement(
 
202
            $this->previousElement,
 
203
            $tokens,
 
204
            'version',
 
205
            $this->phpcsFile
 
206
        );
 
207
 
 
208
        return $this->_version;
 
209
 
 
210
    }//end parseVersion()
 
211
 
 
212
 
 
213
    /**
 
214
     * Parses the package tag found in this test.
 
215
     *
 
216
     * @param array $tokens The tokens that comprise this var.
 
217
     *
 
218
     * @return PHP_CodeSniffer_CommentParser_SingleElement
 
219
     */
 
220
    protected function parsePackage($tokens)
 
221
    {
 
222
        $this->_package = new PHP_CodeSniffer_CommentParser_SingleElement(
 
223
            $this->previousElement,
 
224
            $tokens,
 
225
            'package',
 
226
            $this->phpcsFile
 
227
        );
 
228
 
 
229
        return $this->_package;
 
230
 
 
231
    }//end parsePackage()
 
232
 
 
233
 
 
234
    /**
 
235
     * Parses the package tag found in this test.
 
236
     *
 
237
     * @param array $tokens The tokens that comprise this var.
 
238
     *
 
239
     * @return PHP_CodeSniffer_CommentParser_SingleElement
 
240
     */
 
241
    protected function parseSubpackage($tokens)
 
242
    {
 
243
        $this->_subpackage = new PHP_CodeSniffer_CommentParser_SingleElement(
 
244
            $this->previousElement,
 
245
            $tokens,
 
246
            'subpackage',
 
247
            $this->phpcsFile
 
248
        );
 
249
 
 
250
        return $this->_subpackage;
 
251
 
 
252
    }//end parseSubpackage()
 
253
 
 
254
 
 
255
    /**
 
256
     * Returns the authors of this class comment.
 
257
     *
 
258
     * @return array(PHP_CodeSniffer_CommentParser_SingleElement)
 
259
     */
 
260
    public function getAuthors()
 
261
    {
 
262
        return $this->_authors;
 
263
 
 
264
    }//end getAuthors()
 
265
 
 
266
 
 
267
    /**
 
268
     * Returns the version of this class comment.
 
269
     *
 
270
     * @return PHP_CodeSniffer_CommentParser_SingleElement
 
271
     */
 
272
    public function getVersion()
 
273
    {
 
274
        return $this->_version;
 
275
 
 
276
    }//end getVersion()
 
277
 
 
278
 
 
279
    /**
 
280
     * Returns the license of this class comment.
 
281
     *
 
282
     * @return PHP_CodeSniffer_CommentParser_PairElement
 
283
     */
 
284
    public function getLicense()
 
285
    {
 
286
        return $this->_license;
 
287
 
 
288
    }//end getLicense()
 
289
 
 
290
 
 
291
    /**
 
292
     * Returns the copyrights of this class comment.
 
293
     *
 
294
     * @return PHP_CodeSniffer_CommentParser_SingleElement
 
295
     */
 
296
    public function getCopyrights()
 
297
    {
 
298
        return $this->_copyrights;
 
299
 
 
300
    }//end getCopyrights()
 
301
 
 
302
 
 
303
    /**
 
304
     * Returns the category of this class comment.
 
305
     *
 
306
     * @return PHP_CodeSniffer_CommentParser_SingleElement
 
307
     */
 
308
    public function getCategory()
 
309
    {
 
310
        return $this->_category;
 
311
 
 
312
    }//end getCategory()
 
313
 
 
314
 
 
315
    /**
 
316
     * Returns the package that this class belongs to.
 
317
     *
 
318
     * @return PHP_CodeSniffer_CommentParser_SingleElement
 
319
     */
 
320
    public function getPackage()
 
321
    {
 
322
        return $this->_package;
 
323
 
 
324
    }//end getPackage()
 
325
 
 
326
 
 
327
    /**
 
328
     * Returns the subpackage that this class belongs to.
 
329
     *
 
330
     * @return PHP_CodeSniffer_CommentParser_SingleElement
 
331
     */
 
332
    public function getSubpackage()
 
333
    {
 
334
        return $this->_subpackage;
 
335
 
 
336
    }//end getSubpackage()
 
337
 
 
338
 
 
339
}//end class
 
340
 
 
341
?>