【问题标题】:phpDoc and Code Completion via '->' T_OBJECT_OPERATOR in NetBeans 8.0在 NetBeans 8.0 中通过“->”T_OBJECT_OPERATOR 完成 phpDoc 和代码完成
【发布时间】:2014-06-09 16:01:48
【问题描述】:

如何使用 T_OBJECT_OPERATOR 加载 phpDoc 块来完成代码,而无需像下面的源代码那样预设变量?

唯一重要的类是parentExample,因为它设置了所需的$cc,它确实提供了一个可行的解决方案,但不希望以这种方式预设变量。

示例代码显示了不受欢迎的解决方案和多次无效尝试。

由于代码完成是基于先前设置的信息,因此最好使用完整的示例脚本,而不仅仅是片段。此外,因为它确实与 phpDocumentor 相关,所以也包括基本的 phpDoc 块。希望这些 docBlocks 作为代码完成的一部分被加载,而不仅仅是命名对象。

<?php
/**
 * This is a parent class.
 * 
 * @package Examples/doubledVars
 */
class parentExample 
{   
    /* @var $a parentExample */
    public $a;

    /**
     * This is a var named b
     * @var $b parentExample
     */
    public $b;

    public $c;
    public $cc;
    // notice^ <------------------------------------------------------SEE ME

    /**
     * A basic contructor
     */
    public function __construct() 
    { 
        echo '::PE Class initiated::'; 

        $this -> a = 'we are value "a" in the parent class'; 
        $this -> b = 'we are value "b"  in the parent class'; 
        $this -> c = 'we are value "c"  in the parent class'; 
    }
} 

/**
 * This is an Example of doubling occuring due to failed to __construct()
 * 
 * @package Examples/doubledVars
 */
class doubledVars extends parentExample 
{   
    /**
     * Value is obtained via parent constuctor.
     * 
     * @return string assigned during construction of parent class.
     */
    public function getA() 
    { 
        return $this -> a; 
    } 
}

/**
 * This is an Example of no doubling occuring due to __construct()
 * 
 * @package Examples/doubledVars
 */
class noDouble extends parentExample 
{  
    /**
     * an empty constructor used to prevent doubling during construction.
     * child class makes use of parent constructor unless it has it's own.
     * or none exsist.
     */
    public function __construct() 
    { 

    } 

    /**
     * Empty string return
     * 
     * Shows an example of returning values set based on the constructor 
     * class. In this case there is no default values set at any point, but
     * rather value is assigned during the construction of a object.
     * 
     * @return string This string is empty
     */
    public function getB() 
    { 
        return $this -> b; 
    } 
} 

/**
 * This is an Example of no doubling occuring due to __construct()
 * @see noDouble
 * 
 * @package Examples/codeCompletion
 */
class codeCompletion extends parentExample 
{  
    /**
     * @see noDouble::__construct()
     */
    public function __construct() 
    { 
        //empty constructor prevents doubling
    }


    public function getC() 
    { 
        return $this -> c; 
    } 
}


/** @var $parentExampleDV parentExample */
$parentExampleDV = new parentExample;

// Tried this for Code completion, it did not work <------------------SEE ME
/** @var $doubledVars doubledVars */
$parentExampleDV->doubledVars = new doubledVars; 

/* output on next 'echo' will be as follows */
//::PE Class initiated::::PE Class initiated::we are in the parent class
echo '@@'.$parentExampleDV->doubledVars->getA().'@@';// NO CC <-------SEE ME

echo '<br><br>----------<br><br>';


/** @var $parentExampleDV parentExample */
$parentExampleND = new parentExample;

// Tried this for Code completion, it did not work <------------------SEE ME
/** @var $parentExample->noDouble noDouble */
$parentExampleND -> noDouble = new noDouble;

/* output on next 'echo' will be as follows */
//we are in the parent class
echo '!!'.$parentExampleND->noDouble->getB().'!!';// NO CC <----------SEE ME

echo '<br><br>----------<br><br>';

$parentExampleCC = new parentExample;

$parentExampleCC->cc = new codeCompletion;

echo '##'.$parentExampleCC->cc->getC().'##';//CC working <------------SEE ME

echo '<br><br>----------<br><br>';

【问题讨论】:

  • 公平评论问题在源代码中......我会更新,阅读全文时似乎不言自明。
  • 问题是什么?
  • 如何使用 T_OBJECT_OPERATOR 加载 phpDoc 块来完成代码,而无需像源代码所示那样预设变量...
  • 我想要代码完成而不预设值。例如,我在显示的源代码中展示了我想要的内容,将使用$parentExampleCC-&gt;cc-&gt; 生成代码完成
  • 这只是因为变量在 parentExample 类中预设为public $cc;

标签: php netbeans phpdoc


【解决方案1】:

我想目前是不可能的……

【讨论】:

    猜你喜欢
    • 2010-12-04
    • 2012-03-01
    • 2012-07-30
    • 1970-01-01
    • 2012-01-14
    • 2011-01-04
    • 1970-01-01
    • 2014-09-25
    相关资源
    最近更新 更多