Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想做这样的事情:
class CCC {} function abc(array of CCC $variable)
这在php中可能吗?
不。
您需要手动检查:
function foo(array $arr) { if (array_filter($arr, function ($i) { return !($i instanceof CCC); })) { throw new InvalidArgumentException('Array must contain instances of CCC'); } ... }