phpDoc和通过“->"完成的代码NetBeans 8.0中的T_OBJECT_OPERATOR [英] phpDoc and Code Completion via '->' T_OBJECT_OPERATOR in NetBeans 8.0

查看:128
本文介绍了phpDoc和通过“->"完成的代码NetBeans 8.0中的T_OBJECT_OPERATOR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用T_OBJECT_OPERATOR加载的phpDoc块如何在无需预先设置变量的情况下发生代码补全?

How can code completion occur with phpDoc blocks loaded using the T_OBJECT_OPERATOR without having to preset the variables as is shown is the source below?

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

The only class that matters is the parentExample as it set's the needed $cc that does offer a working solution but it is not desired to preset variables in this manner.

示例代码显示了不希望的解决方案和多次无效的尝试.

The example code shows the undesired solution and multiple non-working attempts.

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

As code completion is based on previously set information, preferred to use the full example script not just pieces. Also, as it does relate to phpDocumentor basic phpDoc blocks were included as well. It is desired that these docBlocks get loaded as part of the code completion not just named objects.

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

推荐答案

我想目前不可能...

I guess It is not possible at this time...

这篇关于phpDoc和通过“-&gt;"完成的代码NetBeans 8.0中的T_OBJECT_OPERATOR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆