while waiting for the empty block to be merged: would it not be enough to say if ! $block instanceof BlockInterface? if $block is null this will work as well. i think this code is correct too, but more complicated than needed.