rfc:php_namespace_policy

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rfc:php_namespace_policy [2020/07/16 20:58]
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),​ Larry Garfield (larry@garfieldtech.com)   * Author: Mark Randall (marandall@php.net),​ Larry Garfield (larry@garfieldtech.com)
-  * Status: ​Under Discussion+  * Status: ​Declined
   * First Published at: https://​wiki.php.net/​rfc/​php_namespace_policy   * First Published at: https://​wiki.php.net/​rfc/​php_namespace_policy
  
Line 36: Line 36:
   - 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.   - 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.
   - Any namespaced code provided by PHP-SRC will use a distinct component namespace. ​ That is, no PHP\Foo class may be defined, but a PHP\Foo\Bar class may be.   - Any namespaced code provided by PHP-SRC will use a distinct component namespace. ​ That is, no PHP\Foo class may be defined, but a PHP\Foo\Bar class may be.
-  - Component namespaces should be singular. ​ That is, \PHP\Attribute,​ not \PHP\Attributes. 
   - Component or sub-component namespaces MUST use CamelCase naming conventions.   - Component or sub-component namespaces MUST use CamelCase naming conventions.
   - Only classes and other autoloadable symbols (as specified above) may be namespaced. ​ Constants should be associated to a class within the namespace as appropriate.   - Only classes and other autoloadable symbols (as specified above) may be namespaced. ​ Constants should be associated to a class within the namespace as appropriate.
Line 46: Line 45:
 A page will be established on the PHP Wiki (this site) to index all explicitly specified component namespaces for both \PHP and \Ext. 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. +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 "​claimed"​ by the RFC that first uses it. Once claimed, that component namespace may only be used only by that RFC or future RFCs that extend that one in a natural way.  For example, once it's established that \PHP\Attribute\ is the namespace for attributes, additional attribute classes may be defined there but no non-attribute-related classes may be.  Once the RFC is approved, the namespace should be added to the index. + 
-  - A \Ext component namespace is "​claimed"​ in one of three ways: +A \PHP component namespace is "​claimed"​ by the RFC that first uses it. Once claimed, that component namespace may only be used only by that RFC or future RFCs that extend that one in a natural way.  For example, once it's established that \PHP\Attribute\ is the namespace for attributes, additional attribute classes may be defined there but no non-attribute-related classes may be.  Once the RFC is approved, the namespace should be added to the index. 
-  ​-   - An RFC that creates or migrates a bundled extension. + 
-  ​-   - A PECL module author may post to the Internals maliing list stating an intent to "​claim"​ an \Ext component namespace for a package. ​ If there is no negative response within a week, the author may update the index accordingly. ​ If there is, the author may post an RFC with vote to claim the component. +An \Ext component namespace is "​claimed"​ in one of three ways: 
-  -   - A PECL module may automatically claim a namespace based on its package name.  For example, a "​yoursql"​ database driver in PECL would implicitly claim the \Ext\YourSQL namespace.+ 
 +  - An RFC that creates or migrates a bundled extension. 
 +  - A PECL module author may post to the Internals maliing list stating an intent to "​claim"​ an \Ext component namespace for a package. ​ If there is no negative response within a week, the author may update the index accordingly. ​ If there is, the author may post an RFC with vote to claim the component. 
 +  - PECL module may automatically claim a namespace based on its package name.  For example, a "​yoursql"​ database driver in PECL would implicitly claim the \Ext\YourSQL namespace.
   - In case of conflict, an RFC-claimed component name has priority over an explicitly-claimed component name over an implicitly-claimed component name.   - In case of conflict, an RFC-claimed component name has priority over an explicitly-claimed component name over an implicitly-claimed component name.
  
Line 89: Line 91:
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
-PHP 8.0+PHP 8.0 (doesn'​t really have an impact until 8.1, however)
  
 ===== Vote ===== ===== Vote =====
-Yes / No  
  
-"​Should PHP adopt these guidelines for future RFC authors to guide when and how to use the \PHP namespace ​for userland-accessible classes and similar?"​+Voting opened 2020-07-26 and closes 2020-08-09. 
 + 
 +Yes / No vote, requiring 2/3 to pass. 
 + 
 +"​Should PHP adopt these guidelines for future RFC authors to guide when and how to use the \PHP and \Ext namespaces ​for userland-accessible classes and similar?"​ 
 + 
 + 
 +<doodle title="​Adopt this policy for future symbols defined by php-src and extension code?" auth="​crell"​ voteType="​single"​ closed="​true">​ 
 +   * Yes 
 +   * No 
 +</​doodle>​
  
 ===== Prior Art ==== ===== Prior Art ====
 https://​wiki.php.net/​rfc/​namespaces-in-core (withdrawn) https://​wiki.php.net/​rfc/​namespaces-in-core (withdrawn)
  
rfc/php_namespace_policy.1594933124.txt.gz · Last modified: 2020/07/16 20:58 by crell