Subversion Repositories Applications.framework

Rev

Details | Last modification | View Log | RSS feed

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