$value) { // Skip empty values if (empty($value)) { continue; } // Find expected data type $expected_data_type = strtolower(\CRM_Utils_Type::typeToString($allowed_attributes[$key])); // It could be so easy... // Validate data type if (!\CRM_Utils_Type::validatePhpType($value, $expected_data_type)) { $given_type = gettype($value); throw new \Exception( "Data type of attribute '$key' is $given_type, but $expected_data_type was expected." ); } } }