Photoelectric sensor with time of flight measurement