PHP: avoid crash incase NewEntity returns a NULL pointer