相关疑难解决方法(0)

PHP类型提示原始值?

我想知道是否可以键入提示方法以期望原始类型?

像这样的东西:

public function someMethod(string $str)
                         //^^^^^^
Run Code Online (Sandbox Code Playgroud)

要么:

private function anotherMethod(int $num)
                             //^^^
Run Code Online (Sandbox Code Playgroud)

你会这样:

private function otherMethod(Person $rambo)
                           //^^^^^^
Run Code Online (Sandbox Code Playgroud)

这可能在PHP吗?

php type-hinting primitive-types

72
推荐指数
4
解决办法
4万
查看次数

标签 统计

php ×1

primitive-types ×1

type-hinting ×1