namespace prefix: One or more contiguous leading namespace parts with namespace separators. Given an autoloadable class name of Acme\Log\Writer\FileWriter
, a namespace prefix may be Acme\
, Acme\Log\
, or Acme\Log\Writer\
. A namespace prefix will include a trailing namespace separator, but will not include a leading namespace separator.
The following examples MUST NOT be regarded as part of the specification.
On Tuesday, October 22, 2013 12:59:39 PM UTC-5, Amy Stephen wrote:
Wherever possible, it would be best IMO, to use established official terms. In the case of namespaces, the PSR should link to and discuss namespacing using official terms.Further, if there is a condition where a new term might be beneficial, it would be preferable, IMO, to issue a PR on the PHP documentation (or however one recommends such changes) to introduce the term and its associated definition so that all terms in a PSR are a part of the documentation.
- A "namespace prefix" in the PSR sense is called a namespace.
- Often a namespace will also be called an identifier.
- What is sometimes called a "slash" in the PSR sense is called a namespace separator.
- A qualified name has at least one namespace separator, ex. Foo\Bar
- A fully qualified name has a leading namespace separator. ex \Foo\Bar
- A class is referred to as a qualified or unqualified class name, dependent upon whether or not the leading namespace separator exists.
Not only will such an approach reduce unnecessary debate but it encourages using the official documentation and has immediate meaning for those who understand PHP.
Note: IMO, there is no reason for a PSR to refer to, discuss, or address a fully qualified class name since that value is never passed into a class loader. It's only relevant to PHP and resolved before the class loader is ever involved.
A few things to be changed:"resource"We want to return to the "file" and "directory", and no longer talk about resources.If this is not flexible enough, we could use the definitions section to clarify that our understanding of "file" and "directory" extends beyond the everyday meaning.It is better to lose a bit of edge case flexibility than alienating 90% of the readers with unnecessarily abstract language."namespace prefix"The definition and usage of this depends on a class. Instead, we want a relationship of namespace prefixes with directories that is _independent_ of a class.We could do this either by extending the definition of "namespace prefix" to explain its standalone meaning, or introduce a new term.I had "terminated namespace name" once, which I explained as namespace name with appended namespace separator.We could say a namespace prefix, if not in the context of a specific class, means a string that could be a prefix of a class and ends with "\\".Autoloader details?The main issue here has been solved, by saying "... so that the following autoloader steps WOULD do the job".I still think we could do without the steps and say this in another way. Not because of logic and semantic problems, but to get to a more elegant way to say it.Unlike with the previous doc, this is now realistic to propose and discuss as a PR, instead of as a separate proposal.