$item may be null, that must be handled gracefully! Either return null or throw an exception. In both cases, the caller must handle the error case and call $this->dieUsage as appropriate (or better, use the new ApiErrorReporter facility).