Something like this may work as well:

```php
$classOrServiceName = null === $classOrServiceName ? null : (array) $classOrServiceName;
```