source: classes/phing/tasks/ext/phpdoc/PhingPhpDocumentorErrorTracker.php @ ed3ff78

Last change on this file since ed3ff78 was ed3ff78, checked in by Michiel Rook <mrook@…>, 3 years ago

Documentation fixes

  • Property mode set to 100644
File size: 3.2 KB
Line 
1<?php
2/**
3 * $Id$
4 *
5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 *
17 * This software consists of voluntary contributions made by many individuals
18 * and is licensed under the LGPL. For more information please see
19 * <http://phing.info>.
20 */
21
22/**
23 * Phing subclass of the ErrorTracker class provided with PhpDocumentor to work around limitations in PhpDocumentor API.
24 *
25 * This class is necessary because PhpDocumentor does directly output errors and
26 * warnings occured during testing for undocumented elements to stdout.
27 * This class is injected globally to force PhpDocumentor to use phing's logging
28 * mechanism.
29 *
30 * Obviously this is far from ideal, but there's also no solution given the inflexibility of the
31 * PhpDocumentor design.
32 *
33 * @author Timo A. Hummel <privat@timohummel.com> @author felicitus
34 * @version $Id$
35 * @package phing.tasks.ext.phpdoc
36 */ 
37class PhingPhpDocumentorErrorTracker extends ErrorTracker {
38       
39        /*
40         * @var object  Reference to the task we're called with
41         */
42        private $task;
43       
44        /**
45         * Outputs a warning. This is an almost 1:1 copy from PhpDocumentor,
46         * we're just processing the warning text and send it to phing's logger.
47         *
48         * @param $num integer  Number of parameters
49         * @return nothing
50         */
51        function addWarning ($num) {
52        $a = array('', '', '', '');
53        if (func_num_args()>1) {
54            for ($i=1;$i<func_num_args();$i++) {
55                $a[$i - 1] = func_get_arg($i);
56            }
57        }
58       
59       $message = sprintf($GLOBALS['phpDocumentor_warning_descrip'][$num], $a[0], $a[1], $a[2], $a[3]);
60       $this->task->log($message, Project::MSG_WARN);
61               
62        }
63       
64        /**
65         * Outputs an error. This is an almost 1:1 copy from PhpDocumentor,
66         * we're just processing the error text and send it to phing's logger.
67         *
68         * @param $num integer  Number of parameters
69         * @return nothing
70         */
71       
72        function addError ($num) {
73        $a = array('', '', '', '');
74        if (func_num_args()>1) {
75            for ($i=1;$i<func_num_args();$i++) {
76                $a[$i - 1] = func_get_arg($i);
77            }
78        }
79       
80       $message = sprintf($GLOBALS['phpDocumentor_error_descrip'][$num], $a[0], $a[1], $a[2], $a[3]);
81       $this->task->log($message, Project::MSG_ERR);
82               
83        }
84       
85        /**
86         * Sets the task we're working with. This is necessary since we need to be
87         * able to call the method "log".
88         *
89         * @param object $task  The task we're working with
90         * @return nothing
91         */
92        public function setTask ($task) {
93                $this->task = $task;
94        }
95       
96}
Note: See TracBrowser for help on using the repository browser.