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