Improved exception message while trying to access an attribute from an empty array

Rebased #1439 in master and updated twig extension
you don't need to put the imploded array keys here, as there is no keys