AppName in dependency injection

So I read Dependency injection — Nextcloud latest Developer Manual latest documentation and it lists AppName as one of the predefined core services. But it also states in a note box that:

$AppName is resolved because the container registered a parameter under the key ‘AppName’ which will return the app id. The lookup is case sensitive so while $AppName will work correctly, using $appName as a constructor parameter will fail.

Now, if one pokes around in the Nextcloud apps’ source code, there is uncountable numbers of occurrences of string $appName in various constructors, as opposed to string $AppName as the documentation seems to suggest one should be using (and also saying is the only thing that works).

So, why does string $appName seemingly work just fine, despite the documentation saying this should not be the case? And also, why is string $appName used instead of the apparently correct string $AppName? Is it for some reason recommended to use string $appName instead of string $AppName?

On a related note, I might as well ask; Is there any reason to use one of the above methods to get the app ID into e.g. a controller, instead of just importing the app’s Application class and referencing Application::APP_ID? I don’t really see the point of adding cruft to the constructors and a property to the class, instead of just having one single import and then getting access to the app ID right away.

tl;dr use $appName.

1 Like

Spot on answer to the first set of questions :+1: Regarding why people we using the camel case one instead of the pascal case one everywhere, I guess it’s just because what came natural to them and it worked (in contrast to what the documentation said should work).

The other question is still unclear though; Is there any reason to use one of the above methods to get the app ID into e.g. a controller, instead of just importing the app’s Application class and referencing Application::APP_ID ? I don’t really see the point of adding cruft to the constructors and a property to the class, instead of just having one single import and then getting access to the app ID right away.