A teenager killed at least three people and injured eight in a school shooting in the Philippines after warning classmates beforehand.