I need to check if variable is of specified scalar type - but I cannot use general function like is_scalar - because this would accept also those types (that type) I don't want to accept.
It is possible to check types step by step:
- with in-built functions like
is_string
- with separate comparation of value given by
gettype
but it is a bit incomfortable because it would give a very long code.
So, I prepared following (relatively short - if you ignore external parts) code:
!in_array(gettype($Item), MarC::Show_Options_Scalars())
where
function Show_Options_Scalars()
represents allowed accepted scalar types.
That one prepares array of allowed types - from constants written in interface. That is why I wrote that own validation is relatively short if you ignore external parts.
And still I am not sure if multitype validation could be done better - it means if can I validate variable type by else better way. That external code is not reason why search for better multitype validation.