How in the world could he say such a thing?
I found the answer in your first paragraph.
Rabbi Yehuda Halevi in his 12th century classic...
Spanish rabbinism from the dark ages up through the englightenment is some extremely weird stuff. It embraces mysticism and gematria and astrology and all sorts of stuff and attempts to brute-force syllogize them together. You can find that some rabbi there said... well, virtually anything you care to look for.