@usedby标签如何在phpdoc中工作

时间:2011-03-02 13:06:34

标签: php documentation phpdoc

使用@usedby标签超链接不会出现在文档中。

Class Content
{
    /**
    * simple db class variable
    * @access public
    */
    var $_db=null; // db
    /**
    * s3 class instance
    */
    private $_s3=null; //  s3
    /**
    * application variable array for creating instance of each object 
    * @var array
    * @usedby Content::upload() this is compared 
    */
    public $application=array(
        'image'=>array(
                'createthumb'=>'createimagethumb'
                ),
        'audio'=>array(
                'createthumb'=>'createaudiothumb'
                ),
        'video'=>array(
                'createthumb'=>'createvideothumb'
                ),
        'link'=>array(
                'createthumb'=>'createlinkthumb'
                )
        );
/**
    * for uploading new content or you can say add new content :)
    *
    * @return json of new contents 
    **/
    function upload()
    {
        if ($_POST['gibname']=='' or $_POST['gibview']=='') {
            $msg=createmessage(false, 'Please enter gibname and gib view where you want to place content');
        }
        $maxFileSize = 100 * 1024 * 1024;   // Max file size 100 MB
        $thumb = $status =$imgWidth = $imgHeight = '';
        $headers = apache_request_headers();        // Get file size from Apache headers
        $fileSize=(int)$headers['Content-Length'];
        $fileType = (string)$headers['Content-Type']; // Get MIME type from Apache headers
        $clientfileType = $fileType;
        if (preg_match("/^multipart/", $fileType) ) $fileType = $_FILES['qqfile']['type'];
        if ($fileType=='application/octet-stream') $fileType="video/flv";
        if ($fileSize == 0) {
            return array('success'=>false, 'error'=>"File is empty.");
        }               
        if ($fileSize > $maxFileSize) {
            return array('success'=>false, 'error'=>"File is too large.");
        }
        $pathinfo = pathinfo($_REQUEST['qqfile']);        // Put data of pathinfo() array into $pathinfo    
        $filename = $pathinfo['filename'];// Get file name - eg: myphoto
        $ext = $pathinfo['extension'];        // Get extension - eg: .jpg
        if ($ext=='') $ext=substr(strrchr($_FILES['qqfile']['name'], '.'), 1);
        $originalName = $filename.'.'.$ext;
        $randName = uniqid();               // Generate unique id for the current object
        $fileTempName =  $randName . '.' . $ext;    // Unique file name with extension
        $fullTempName = "uploads/".$fileTempName;        // Set temp directory where files will be written temporarily        // Complete temp file name and path
        if (!preg_match("/^multipart/", $clientfileType)) { // Upload the file to temp directory on .net server
            $input = fopen("php://input", "r");
            $fp = fopen($fullTempName, "w");
            while ($data = fread($input, 1024)) {
                fwrite($fp,$data);
            }
            fclose($fp);
            fclose($input);         
        } else
            move_uploaded_file($_FILES["qqfile"]["tmp_name"], $fullTempName);
        $objecttype=mb_substr($fileType,0,-mb_strlen(strrchr($fileType,"/")));
        //for uploading of link url is neccesssary
        if ($_POST['url']!='' or $_POST['refername']!='') {
            $objecttype="link";
            $url=$_POST['url'];
            $filename=$_POST['filename'];
        } else {
            $url=CLOUDFRONT.$fileTempName;
            $filename=$fileTempName;
        }
        if (class_exists($objecttype) && $_POST['refername']=='') {
            $object=new $objecttype();
            $str=$this->application[$objecttype]['createthumb'];
            $thumb=$object->{$str}($fullTempName,$fileType);
            $thumbnail=$thumb['thumb'];
            $preview=$thumb['preview'];
            $imgWidth=$object->imagewidth;
            $imgHeight=$object->imageheight;
            $resize=$object->resize;
        }
}

虽然@usedby不是警告即将告知未知标签。 phpdocumentor版本是1.4.3 为什么它会说未知标签。

1 个答案:

答案 0 :(得分:3)

“@usedby”标签是 phpDocumentor在您的docblock中查找的代码文档标记。有一个“@uses”标记表示“此特定元素使用我在此标记中列出的那个”。 phpDocumentor会看到这个标签,在元素的doc上显示这个标签,建立到另一个元素的链接,在该文档中为其他元素添加@usedby标记。

简而言之,您将ThisElement的docblock中的@uses指向ThisElement指向ThatElement,而 phpDocumentor 将把@usedby放入ThatElement的文档中,从ThatElement指向ThisElement。