谁能给我解释一下。只是在其中一个 laravel 包中遇到它
public function users(): MorphToMany
{
return $this->morphedByMany(
getModelForGuard($this->attributes['guard_name']),
'model',
config('permission.table_names.model_has_permissions'),
'permission_id',
'model_id'
);
}
我知道上面是一个方法,但我不明白的是 : MorphToMany
在方法名称旁边有什么意思?
最佳答案
那是一个 Return type declaration :
...return type declarations specify the type of the value that will be returned from a function.
另一个例子:
function arraysSum(array ...$arrays): array
{
return array_map(function(array $array): int {
return array_sum($array);
}, $arrays);
}
请注意,这是 PHP 7 中的新功能
关于php - 我不明白是 `: MorphToMany` 行。在方法名称旁边加上那个是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51159321/