Shouldn't you check if `$params` is an array?