Fix PHP Fatal from unchecked getStorage()

Additionally implemented a slightly more optimized approach.

See #812