Search code examples
phpstandardspsr-0

Why are underscores converted to directory separators in PSR-0?


I'm trying to figure out why would underscores in class names be converted to directory separators in PSR-0? I'm sure there is a reason for it, but I can't think of why.

If I have a class named my_class_name in the namespace \namespace\subnamespace Wouldn't that then convert to \namespace\subnamespace\my\class\name when what I want is \namespace\subnamespace\my_class_name? I understand if my class system is built around this it would work, but if I wanted directory separators I would have just used a backslash instead of an underscore.


Solution

  • Because history. It was common prior to PHP gaining namespace support for projects to use underscore-separated bits for a sort of poor man's namespacing. There was enough of that still going on at the time PSR-0 was created to make it a practical decision.