Shader.PropertyToID() - How does it work?

I’ve just started working with shaders more and discovered Shader.PropertyToID(). It works just fine for me but I don’t understand how it works.

So you pass in the name of name of the property you want and it gives you a number ID for that property. That’s simple enough, but how does it know which shader I want the property from? How can it know when you don’t give it a reference to the shader you want? What if there are multiple shaders with properties that share the same name? How would it know which property I want then?

I’ve been looking everywhere for how and why this works but to no avail. Some insight into this would be greatly appreciated.

I think it’s just some kind of hash. So the same property name will always return the same hash for any shader.
That also why if you change the shader of a material, if the old and new one have the same properties, it will retain their values.