A nine-year-old boy has been rescued after being locked in his father's van since 2024, a French prosecutor said.