Lowercase or CamelCase namespaces?

These are only examples. They’re not even recommendations - standard does not say anything about case of namespaces.

I said they are examples and I didnt say they are recommendations. But to me, the point is that, for some reason, they preffer to use StudlyCaps and they show that in all namespaces of all PSRs. Is not that the place where php devs are looking for examples and recommendations of standards? I think so.

This is example of consistency. Treating this as an recommendation is just overinterpretation.

I am wondering why not consistency examples in lowercase or camelCase. Other vendors probably looked at those consistency examples and realized that all they need is exactly “consistency”, even although it was not a recommendation (till now).

Furthermore, if PHP-FIG would decide to make a recommendation about this in some moment, it is easy to see what would be the more consistent choice they would pick.

Here’s preliminary decision:

Not set in stone yet.

4 Likes

If we’re going with yiisoft, I’d rather use YiiSoft if that’s okay with you.

Doesn’t it require the package names to be yii-soft/xxx?

True that :smirk:

They didn’t explained. Maybe there was not reason (they flipped a coin) or reason is no longer valid.

Why Yiisoft/DI and Yiisoft/Db/MySQL instead of Yiisoft/Di and Yiisoft/Db/Mysql?

Because it makes sense not to lowercase in some cases such as MySQL.

For me, it does not make sense at all. It just adds another weird rule which is hard to follow. Now you need to think twice what case you should use for this word in a namespace (Is it acronym? Or maybe just weird variation like MySQL or SQLite)? It is all much simpler with strict pascal/camel case, when the case of words is ignored and uppercase letters are used only to indicate word separators. It is also consistent with convention used so far for class names (MysqlMutex instead of MySQLMutex)

2 Likes

After some practical application I tend to agree.

5 Likes

Hi everyone!

Well, I’m pretty late to add something valuable to this duscussion, but I still want to share my point of view, because I didn’t see this argument in messages above.

Personally I vote for PascalCase, because of:

  • It’s common, and in case of using third-party packages “use” section looks more convenient. It’s like a standard now, yes. And that has already been pointed here.
  • And also, it’s about how do you look at this:
    • on the one hand, we start from CLASS naming, like this: This\Is\My\Very\Concrete\Class - so, it’s more for detailed class name
    • on the other hand, we start from DIRECTORY naming: here is my “services” folder, which contains several classes (that’s why it’s plural!) including my ConcreteService class, so it’s services\ConcreteService

That’s why I’m also against plural form for PascalCase namespaces and singular form for camelCase ones.