You can simplify this whole snippet to:

```php
$entity = current($qb->getRootEntities());
$metadata = $qb->getEntityManager()->getClassMetadata($entity);
$parameterType = 'integer' === $metadata->getTypeOfField($identifier) ? Connection::PARAM_INT_ARRAY : Connection::PARAM_STR_ARRAY;
```