在 NetBeans 8.0 中通过"->"T_OBJECT_OPERATOR进行 phpDoc 和代码完成



使用T_OBJECT_OPERATOR加载phpDoc块时,如何在不必预设变量的情况下完成代码,如下源代码所示?

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

示例代码显示了不需要的解决方案和多次不起作用的尝试。

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

<?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>';

我想现在不可能。。。

相关内容

  • 没有找到相关文章

最新更新