douti0467 2012-02-04 22:08
浏览 97
已采纳

抽象类中PHP方法的文档

Is it possible to make a method documentation on the abstract method and whoever extends it inhered the documentation also? Example:

<?php
abstract class Math{
    /**
     * Method that receive two values and return the result of some operation.
     * @param $a Number
     * @param $b Number
     */
    abstract public function values($a, $b);
}
?>

<?php
class Sum extends Math{
    /**
     * @return $a+$b;
     */
    public function values($a, $b){
        return $a+$b;
    }
}
?>

<?php
class Divide extends Math{
    /**
     * @return $a/$b;
     * @throws Exception.
     */
    public function values($a, $b){
        if($b != 0){
            return $a/$b;
        }else{
            throw new Exception("Impossible to divide by 0.");
        }
    }
}
?>

How do I put all those informations about the method together? Currently, I work with Netbeans 7.1. Is it a IDE issue? Or is it just not how this works?

<?php
// Estabele conexão com o MySQL
$connect = mysql_connect('localhost', 'root', '123456') or die('A conexão falhou.');
// Seleciona o banco de dados
$database = mysql_select_db('monografia', $connect) or die('Falha ao tentar selecionar banco de dados.');

if ($database)
    echo 'Conectado atraves do driver nativo.';

?>

<br />

<?php
class Conexao {
    protected $conexao;
    public function Conexao() {
        $this->conexao = new MySQLi('localhost', 'root', '123456', 'monografia', 3306);
        if (!$this->conexao->connect_error)
            echo 'Conectado atraves da extensao MySQLi.';
    }
}
new Conexao();

?>

<br />

<?php
class ConexaoPDO {
    protected $pdo;    
    public function ConexaoPDO() {
        try {
            $this->pdo = new PDO('mysql:host=localhost:3306;dbname=monografia', 'root', '123456', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
            echo 'Conectado atraves do PDO.';
        } catch(PDOException $e) {
            echo $e->getMessage();
        }
    }
}

new ConexaoPDO();
?>
  • 写回答

2条回答 默认 最新

  • douzao5487 2012-02-04 22:40
    关注

    I suggest you look at @inheritDoc tag.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?