Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Psr 4 case folding #216

Merged
merged 4 commits into from

2 participants

@Crell
Collaborator

Add requirements around case handling. Also fix various minor formatting/spelling issues.

@philsturgeon philsturgeon merged commit 966ffb9 into from
@Crell Crell deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 24, 2013
  1. @Crell

    Fix spelling error.

    Crell authored
  2. @Crell

    Remove trailing whitespace.

    Crell authored
  3. @Crell

    More spelling fixes.

    Crell authored
  4. @Crell
This page is out of date. Refresh to see the latest.
Showing with 23 additions and 13 deletions.
  1. +23 −13 proposed/psr-4-autoloader/psr-4-autoloader.md
View
36 proposed/psr-4-autoloader/psr-4-autoloader.md
@@ -37,7 +37,7 @@ name and structure classes to be autoloaded using the described technique.
but will not include the leading namespace separator. Given a _fully
qualified class name_ of `\Acme\Log\Writer\FileWriter`, the _autoloadable
class name_ is `Acme\Log\Writer\FileWriter`.
-
+
- **namespace part**: The individual non-terminating parts of an _autoloadable
class name_. Given an _autoloadable class name_ of
`Acme\Log\Writer\FileWriter`, the _namespace parts_ are `Acme`, `Log`, and
@@ -68,7 +68,7 @@ name and structure classes to be autoloaded using the described technique.
prefix_. Given a file system _scheme_ and a _namespace prefix_ of
`Acme\Log\`, a _resource base_ could be `/path/to/acme-log/src/`. A _resource
base_ will include a _scheme_-appropriate trailing separator, and could
- include a _scheme_-appropriate leading separator. For example, in a file
+ include a _scheme_-appropriate leading separator. For example, in a file
system _scheme_, that separator could be "\" or "/".
- **resource path**: A path in the _scheme_ representing a _resource_ defining
@@ -79,8 +79,8 @@ name and structure classes to be autoloaded using the described technique.
_resource path_ will be `/path/to/acme-log/src/Writer/FileWriter.php`. The
_resource path_ is not certain to exist in the _scheme_.
-- **conforming autoloader**: PHP autoloader code that implements follows these
- definitions and attempts to inlcude the correct _resource path_ based on
+- **conforming autoloader**: PHP autoloader code that implements follows these
+ definitions and attempts to include the correct _resource path_ based on
a valid _fully qualified class name_.
@@ -101,7 +101,7 @@ MUST structure their classes using these same principles.
### 3.2. Requirements
-This is a collection of rules which explain how the _FQCN_ can be
+This is a collection of rules which explain how the _FQCN_ can be
converted into a _resource path_.
1. Each _autoloadable class name_ MUST begin with a _namespace part_, which
@@ -112,12 +112,12 @@ _class part_.
sometimes called a "vendor name", MUST be unique to the developer or
project. This is to prevent conflicts between different libraries,
components, modules, etc.
-
+
b. It is RECOMMENDED (but not required) that the _autoloadable class name_
include a second _namespace part_, sometimes called a "package name", to
identify its place within the "vendor name".
- > **Example:** The _autoloadable class name_ which contains a "vendor
+ > **Example:** The _autoloadable class name_ which contains a "vendor
name" and other _namespace parts_ - including potentially a "package name",
could follow this structure `\<Vendor Name>\(<Namespace Parts>\)*<Class Part>`.
@@ -139,10 +139,10 @@ following steps to locate and eventually include the correct _resource_:
2. For every combination of _namespace prefix_ and _resource base_ found,
take the _relative class name_ replace every _namespace separator_ in
- it with a _scheme_-appropriate separator. Append the ".php" suffix, and
- append the result to the _resource base_. The result will be refered to
+ it with a _scheme_-appropriate separator. Append the ".php" suffix, and
+ append the result to the _resource base_. The result will be referred to
as _resource path_.
-
+
3. If any of the _resource paths_ obtained this way exists in the _scheme_,
then include or require exactly one of them.
@@ -164,13 +164,23 @@ multiple _resource bases_ corresponding to a _namespace prefix_ is not
within the scope of this specification. Refer to the documentation of
the _conforming autoloader_ for more information.
+4. A _conforming autoloader_ MUST treat a _fully qualified class name_,
+_resource base_, and _resource path_ as case-sensitive. Developers who wish
+their classes to be autoloadable MUST match case between an
+_autoloadable class name_ and the intended corresponding file. Furthermore,
+developers MUST NOT define _autoloadable class names_ that differ only in case.
+Although PHP does not enforce case on class names many file systems are
+case-sensitive, and allowing case-insensitive autoloading could lead to
+inconsistent results depending on the file system in question.
+
+
## 5. Examples
-The following examples MUST NOT be regarded as part of the specification.
+The following examples MUST NOT be regarded as part of the specification.
### 5.1. Example Technique
-The aim of this "Example Technique" is to highlight how an autoloader could
+The aim of this "Example Technique" is to highlight how an autoloader could
transform a _autoloadable class name_ into a _resource path_.
Given a UNIX-like file system _scheme_, a _fully qualified class name_ of
@@ -207,7 +217,7 @@ a class file will be placed:
2. Pick one or more _resource bases_ for the file locations.
3. Remove the _namespace prefix_ from the _autoloadable class name_.
-
+
4. The remaining _namespace parts_ become subdirectories under one of the
_resource bases_.
Something went wrong with that request. Please try again.