0

使用 Laravel,我正在遍历一系列类并对每个类的实例子集进行操作。这些类以字符串形式提供,例如:

$c = '\App\Models\Book';

$c::each(function($i) {
    echo $i->title . PHP_EOL;
});

我将如何输入提示$i

4

1 回答 1

0

You can type it as object{title:string}, if you sure about title and wants to tell about it to paslm.

Also, maybe you may find useful conditional types - https://psalm.dev/docs/annotating_code/type_syntax/conditional_types/

于 2021-12-20T09:41:36.817 回答