對 brcontainer 的 polyfill 做了一些小修正,以非阻塞的方式防止非物件錯誤,並更正了條件檢查 "file_exists" 而不是正確的 "function_exists" 的問題
if ( !function_exists( 'is_iterable' ) )
{
function is_iterable( $obj )
{
return is_array( $obj ) || ( is_object( $obj ) && ( $obj instanceof \Traversable ) );
}
}
原來的答案無法正確解析,因為它查找的是檔案而不是函式,而且如果提供不可迭代的非物件值(例如 false),則提供的方法會出錯。