【问题标题】:What's the name of this in PHP? [duplicate]这个在 PHP 中叫什么名字? [复制]
【发布时间】:2019-06-26 10:18:54
【问题描述】:

我遇到了以下方法签名:

public function register(ServiceProviderInterface $provider, array $values = []){}

我不明白ServiceProviderInterface $provider 的部分。有人可以解释一下它的作用吗?

【问题讨论】:

  • 作为第一个参数 ($provider) 传递给函数的变量必须是类 ServiceProviderInterface 的对象实例。 php.net/manual/en/…

标签: php oop arguments type-declaration


【解决方案1】:

$provider 之前的文本指定参数应该是什么。在这种情况下,它应该是ServiceProviderInterface 的一个实例。在此处阅读有关类型声明的更多信息:

http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration

【讨论】:

    猜你喜欢
    • 2019-05-24
    • 1970-01-01
    • 2011-06-18
    • 2012-07-25
    • 2020-06-21
    • 2018-11-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多