English 中文(简体)
如何在PHPDoc表明这一论点是选择性的?
原标题:How to mark that an argument is optional in PHPDoc?

我来谈谈这一提出任择论点的构造。 这方面的主要问题是可使用性。 采用我的框架的开发商将立即赶上头痛,因为他不知道他是否能够提供论据、什么论点,或者他完全可以提出。 结论: 它只是cks。 但是,如果某个人拥有像Netbeans所安装的那种合理的电离层电离层电离层电离层,PHPDoc可能帮助很小的轨道;

因此:

class ChildClass extends ParentClass {
    public function __construct() {
    $tplFile = func_get_arg(0);
    if (!isset($tpl)) {
        $tpl =  index ;
    }
    parent::__construct($tpl);
    }
}

我怎么能在这里用PHPDoc表示可以提供一种任择性的[数额]论点?

最佳回答

1. 宣布参数,并预先确定:

public function __construct($my_argument = 0) 

我的IDE(phpEd, 即 phpDoc敏感性)正确解释。 phpDoc还应将参数纳入:

show ([$my_argument])
问题回答

也可以使用reflection par





相关问题
Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

JSON with classes?

Is there a standardized way to store classes in JSON, and then converting them back into classes again from a string? For example, I might have an array of objects of type Questions. I d like to ...

Object-Oriented Perl constructor syntax and named parameters

I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...

Passing another class amongst instances

I was wondering what is the best practice re. passing (another class) amongst two instances of the same class (lets call this Primary ). So, essentially in the constructor for the first, i can ...

Where can I find object-oriented Perl tutorials? [closed]

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...

热门标签