rfc:php_namespace_policy
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:php_namespace_policy [2020/06/24 00:24] – Formatting crell | rfc:php_namespace_policy [2020/08/10 13:41] (current) – crell | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2020-04-15 | * Date: 2020-04-15 | ||
* Author: Mark Randall (marandall@php.net), | * Author: Mark Randall (marandall@php.net), | ||
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
Line 13: | Line 13: | ||
* Formally reserve the \PHP namespace for use by PHP-SRC. | * Formally reserve the \PHP namespace for use by PHP-SRC. | ||
+ | |||
+ | * Formally reserve the \Ext namespace for use by extensions, either PECL or in core. | ||
* Establish heuristics regarding when and how namespaced classes should be used. In practice there cannot be precise rules in advance for every case, but by offering a common heuristic we hope to eliminate //most// purely subjective debate in the future. | * Establish heuristics regarding when and how namespaced classes should be used. In practice there cannot be precise rules in advance for every case, but by offering a common heuristic we hope to eliminate //most// purely subjective debate in the future. | ||
Line 21: | Line 23: | ||
This RFC does NOT propose moving any existing code into the \PHP namespace at this time. That may be done by future RFCs if desired, under their own votes. | This RFC does NOT propose moving any existing code into the \PHP namespace at this time. That may be done by future RFCs if desired, under their own votes. | ||
- | ===== Namespace Policy | + | ===== Definitions |
+ | * **Vendor namespace**: | ||
+ | |||
+ | * **Component namespace**: | ||
+ | |||
+ | * **Class**: For the purpose of this document, " | ||
+ | |||
+ | ===== Namespace Policy ===== | ||
- | - The \PHP namespace is reserved for use by classes provided by PHP-SRC itself. | + | - The \PHP vendor |
- | - Any namespaced code provided by PHP-SRC will use a sub-namespace | + | - The \Ext vendor namespace is reserved for use by classes provided by a PHP extension, either bundled with PHP or hosted with PECL. While userland code that makes use of that namespace will technically run, any impact on such code by future RFCs will not be considered a backward compatibility break. |
- | - A component namespace is " | + | - Any namespaced code provided by PHP-SRC will use a distinct component |
+ | - Component or sub-component namespaces | ||
+ | - Only classes and other autoloadable symbols (as specified above) | ||
- Component namespaces MAY use sub-components (eg, \PHP\Foo\Bar\), | - Component namespaces MAY use sub-components (eg, \PHP\Foo\Bar\), | ||
- | - If a feature is removed from PHP-SRC (either to PECL or dropped entirely) its previously claimed component namespace remains reserved. | ||
- | - Only autoloadable symbols may be namespaced. | ||
- Classes or other symbols in a component namespace SHOULD NOT repeat the component namespace, unless the class name is extremely generic and easily misunderstood without context. | - Classes or other symbols in a component namespace SHOULD NOT repeat the component namespace, unless the class name is extremely generic and easily misunderstood without context. | ||
+ | |||
+ | ===== Namespace index ===== | ||
+ | |||
+ | A page will be established on the PHP Wiki (this site) to index all explicitly specified component namespaces for both \PHP and \Ext. | ||
+ | |||
+ | For \PHP, classes may be added or removed only via RFC. That may be an RFC to add a feature that uses the namespace or it may be an RFC to rename an existing class to conform to this RFC. | ||
+ | |||
+ | A \PHP component namespace is " | ||
+ | |||
+ | An \Ext component namespace is " | ||
+ | |||
+ | - An RFC that creates or migrates a bundled extension. | ||
+ | - A PECL module author may post to the Internals maliing list stating an intent to " | ||
+ | - PECL module may automatically claim a namespace based on its package name. For example, a " | ||
+ | - In case of conflict, an RFC-claimed component name has priority over an explicitly-claimed component name over an implicitly-claimed component name. | ||
===== Guidelines for namespace usage ===== | ===== Guidelines for namespace usage ===== | ||
Line 46: | Line 70: | ||
* **Guideline**: | * **Guideline**: | ||
- | Classes that provide useful general functionality but do not impact engine behavior | + | Classes that are part of an extension, disableable or not. |
- | * **Examples**: | + | * **Examples**: |
- | * **Guideline**: | + | * **Guideline**: |
- | + | ||
- | Classes that are part of a disable-able | + | |
- | * **Examples**: | + | |
- | * **Guideline**: | + | |
Cases where it is expected that the number of closely related classes is or is likely to become large | Cases where it is expected that the number of closely related classes is or is likely to become large | ||
Line 63: | Line 83: | ||
===== Upgrade path for existing classes ===== | ===== Upgrade path for existing classes ===== | ||
- | This RFC makes no change to existing classes, regardless of where they are defined. | + | This RFC makes no change to existing classes, regardless of where they are defined. |
1. Clearly specify what classes or interfaces will migrate to a component namespace, including whether or not their name will be changing in the process. | 1. Clearly specify what classes or interfaces will migrate to a component namespace, including whether or not their name will be changing in the process. | ||
Line 71: | Line 91: | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
- | PHP 8.0 | + | PHP 8.0 (doesn' |
===== Vote ===== | ===== Vote ===== | ||
- | Yes / No | ||
- | " | + | Voting opened 2020-07-26 and closes 2020-08-09. |
+ | |||
+ | Yes / No vote, requiring 2/3 to pass. | ||
+ | |||
+ | " | ||
+ | |||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== Prior Art ==== | ===== Prior Art ==== | ||
https:// | https:// | ||
rfc/php_namespace_policy.1592958289.txt.gz · Last modified: 2020/06/24 00:24 by crell