You should probably check that `$this->serviceLocator` is indeed an instance before calling `get()` on it. You could do it in the initial conditional:
```php
if ($element instanceof InputFilter && $this->serviceLocator instanceof ServiceLocatorInterface) {
    /* ... */
}
```