Improve type checking code

The name zval_is_type needs a review; unsure what else to name it.