My theory is that most of the Swift code in the public domain, is basically demo code. Short, idealized, code samples to demonstrate issues and solutions; much like you would see in StackOverflow.
PHP has huge, entire frameworks and systems, refined over years.
There is also a lot of low quality PHP code out there, and a lot of legacy code in a language that I am told (I have not used if for years myself though) has changed a lot.