The ball is out of play when play has been stopped by the referee. Therefore, a goal cannot be awarded if the
#referee whistles before the ball has wholly passed over the goal line.
For this reason, when the ball is in (or near) the penalty area, the referee should be very careful when deciding whether to stop play or allow it to continue, as the attacking team may later have an opportunity to score a goal.
Once the whistle is blown, play is stopped, so the referee cannot apply advantage, regardless of whether the whistle had any impact on the attacking/defending players.