rfc:attribute_amendments

Differences

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

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
rfc:attribute_amendments [2020/05/20 16:23] – created beberleirfc:attribute_amendments [2020/06/04 09:11] beberlei
Line 12: Line 12:
  
 ===== Rename PhpAttribute class to Attribute ===== ===== Rename PhpAttribute class to Attribute =====
 +
 +<nowiki>Important Context: Since the acceptence of Attributes, the PhpCompilerAttribute and PhpAttribute classes were unified to be only PhpAttribute. This was needed because the previous approach of disallowing the use of <<PhpCompilerAttribute>> in userland would break "stub" generation that static analysis and IDEs rely on to fill their type database of internal functions/classes. Without it there was no functionality left in PhpCompilerAttribute to preserve.</nowiki>
  
 The original RFC introduced a //PhpAttribute// class to be added to new The original RFC introduced a //PhpAttribute// class to be added to new
 userland attributes. This name was inspired by //PhpToken// and to potentially userland attributes. This name was inspired by //PhpToken// and to potentially
 avoid breaking existing userland codebases with a class called //Attribute//. avoid breaking existing userland codebases with a class called //Attribute//.
-However the //Php// prefix in this case makes little sense for the attribute class.+However the //Php// prefix makes no sense for the attribute class compared to //PhpToken//.
  
 In absence of a namespace policy, the global namespace is PHPs namespace. The In absence of a namespace policy, the global namespace is PHPs namespace. The
-documentation states as much.+documentation states as much and the vote on https://wiki.php.net/rfc/php-namespace-in-core confirmed this.
  
-We propose to rename //PhpAttribute// to //Attribute//.+Therefore we propose to rename //PhpAttribute// to be just //Attribute// and in addition 
 +recommend that all internal/compiler attributes should be placed under the global namespace as well.
  
-Should [[https://wiki.php.net/rfc/php-namespace-in-core|PHP Namespace]] in core get accepted before 8.0then the class will be moved to //PHP\Attribute//.+Extensions providing non-core attributes should consider using their own namespace, but this RFC makes no recommendation or rule about this.
  
 ===== Group statement for Attributes ===== ===== Group statement for Attributes =====
Line 54: Line 57:
 } }
 </code> </code>
 +
 +In line with many other recent RFCs, trailing commas will also be possible in an attribute group declarations:
 +
 +<code php>
 +    <<
 +      Attr1("foo"),
 +      Attr2("bar"),
 +    >>
 +    public function test()
 +    {
 +    }
 +</code>
 +
  
 ===== Validate Attribute Target Declarations ===== ===== Validate Attribute Target Declarations =====
Line 169: Line 185:
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
  
-No breaks.+Introducing a class //Attribute// into the global namespace is certainly going to break at least a handful of applications using this class name
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
rfc/attribute_amendments.txt · Last modified: 2020/06/29 09:07 by beberlei