rfc:propertygetsetsyntax-v1.2

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:propertygetsetsyntax-v1.2 [2013/01/15 01:56]
cpriest Updated Reflection Changes
rfc:propertygetsetsyntax-v1.2 [2017/09/22 13:28] (current)
Line 2: Line 2:
   * Version: 1.2   * Version: 1.2
   * Created: 2012-12-29   * Created: 2012-12-29
-  * Author: Clint Priest <phpdev at zerocue dot com>+  * Updated: 2013-01-17 
 +  * Author: Clint Priest <cpriest at php dot net>
   * Contributors: Nikita Popov   * Contributors: Nikita Popov
-  * Status: Ready for Review & Discussion or Vote+  * Status: Declined, Vote Failed
  
 ==== Fork ==== ==== Fork ====
Line 340: Line 341:
   * unset called from illegal context: Recursion warning is emitted, unset is ignored.   * unset called from illegal context: Recursion warning is emitted, unset is ignored.
  
 +==== Abstract Accessors ====
 +Individual accessors may be defined abstract which will cause the class to be abstract and require any extending classes to define a body for the abstract accessors.
 +
 +<code php>
 +class Foo {
 +    public $bar {
 +        abstract get;
 +    }
 +}
 +
 +class SubFoo extends Foo {
 +}
 +
 +/* Fatal error: Class Foo contains 2 abstract accessors and must be declared
 +      abstract or implement the remaining accessors (Foo::$bar->get, Foo::$bar->isset) in ... */
 +</code>
 +
 +Just like abstract functions, it is illegal to declare an accessor abstract and to provide a body:
 +<code php>
 +class Foo {
 +    public $bar {
 +        abstract get { return 'test'; }
 +    }
 +}
 +
 +/* Fatal error: Abstract function Foo::$bar->get() cannot contain body in ... */
 +</code>
 +
 +You may also declare an entire property as abstract such as:
 +
 +<code php>
 +class Foo {
 +    abstract public $bar {
 +        get;
 +    }
 +}
 +
 +/* This marks all declared accessors as abstract, as well as the class.  An extending class 
 +   would need to provide a body for any declared accessors */
 +</code>
  
 ==== Final Properties ==== ==== Final Properties ====
Line 405: Line 446:
          
     public $dataArray {     public $dataArray {
-        &get { return $this->_dataArray; }+        &get()       { return $this->_dataArray; } 
 +        set(&$value) { $this->_dataArray = $value; }
     }     }
 } }
Line 421: Line 463:
   * $foobar->baz = $x with $bar being object or empty or non-object value   * $foobar->baz = $x with $bar being object or empty or non-object value
   * $foo->bar{$x} = “foo” (string offsets)   * $foo->bar{$x} = “foo” (string offsets)
-  * $foo->bar = &bar->baz; (setting either side affects the other) 
  
  
Line 508: Line 549:
 ===== Reflection ===== ===== Reflection =====
  
-==== Changes ==== 
- 
-  * ReflectionClass::getProperties() will now return an array of ReflectionProperty and ReflectionPropertyAccessor classes. 
-  * ReflectionClass::getProperty() will also return an appropriate class based on being a property or a property with accessors. 
  
 ==== ReflectionProperty changes ==== ==== ReflectionProperty changes ====
Line 531: Line 568:
  
 Implementation Details Document: https://wiki.php.net/rfc/propertygetsetsyntax-implementation-details Implementation Details Document: https://wiki.php.net/rfc/propertygetsetsyntax-implementation-details
 +
 +===== Impact on APC and other Zend extensions =====
 +
 +In addition to the "implementation details document" linked in the previous section this section outlines the impact the accessors implementation has on APC and other Zend extensions.
 +
 +Most Zend extensions should not be affected by this change. Accessors are normal ''zend_op_array''s, they are called as any other function and have a meaningful name. As such extensions like XDebug should not need any adjustments to support accessors.
 +
 +One extension that will require minor changes is APC. APC has to copy all ''zend_op_array''s and ''zend_property_info''s because they may be modified at runtime. Due to this proposal additional ''op_array''s may be located in  ''property_info->accs'' and need to be copied too. Here are the code snippets that need to be inserted in APC to do this: https://gist.github.com/4615156 (full code with the changes: https://gist.github.com/4597660). Other extensions that do something similar will require updates along the same lines.
 +
 +Thus the impact of the change on Zend exts is rather small.
  
 ===== Tests ===== ===== Tests =====
-  * 2012-12-30 : 67 tests at this time+  * 2012-12-30: 67 tests at this time 
 +  * 2013-01-17: 83 tests at this time 
 + 
 +===== Voting ===== 
 + 
 +Voting ends not before Wednesday, January 23rd 2013. The PHP language is expanded, so a 2/3 majority is required. 
 + 
 +<doodle title="Accept PHP Accessors for 5.5?" auth="cpriest" voteType="single" closed="true"> 
 +   * Yes 
 +   * No 
 +</doodle>
  
 ===== Change Log ===== ===== Change Log =====
rfc/propertygetsetsyntax-v1.2.1358214966.txt.gz · Last modified: 2017/09/22 13:28 (external edit)