rfc:propertygetsetsyntax-as-implemented:change-requests

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:propertygetsetsyntax-as-implemented:change-requests [2012/11/19 03:23] – Crossed out todo items that are done. cpriestrfc:propertygetsetsyntax-as-implemented:change-requests [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 6: Line 6:
  
 ==== Syntax Change ==== ==== Syntax Change ====
-Change syntax to use public set($value) {}, public get(), etc. Along with that means no “magic” $value in the setter+<del>[[https://github.com/cpriest/php-src/issues/6|https://github.com/cpriest/php-src/issues/6]]</del> 
 + 
 +Allow syntax to use parenthesized syntax as well so that both a [TypeHint] and $value may be specified. 
 <code php> <code php>
 class TimePeriod { class TimePeriod {
Line 19: Line 22:
 } }
 </code> </code>
 +
 +The abbreviated syntax is also allowed as per 1.1 RFC.
  
 ==== read-only / write-only keywords ==== ==== read-only / write-only keywords ====
 +<del>[[https://github.com/cpriest/php-src/issues/7|https://github.com/cpriest/php-src/issues/7]]</del>
 +
 read-only / write-only keywords will be eliminated, the issue will be pushed to userland developers who can enforce the same by coding something like this: read-only / write-only keywords will be eliminated, the issue will be pushed to userland developers who can enforce the same by coding something like this:
  
Line 37: Line 44:
  
 ==== Automatically Implemented Accessors ==== ==== Automatically Implemented Accessors ====
 +[[https://github.com/cpriest/php-src/issues/5|https://github.com/cpriest/php-src/issues/5]]
 +
 v1.1 properties shadow (or over-ride) accessors, so if an accessor exists and a property is defined (only possible from within the accessors setter), then the property would shadow the accessor.  This was done to keep it consistent with what %%__get()%% does and also to support lazy loading. v1.1 properties shadow (or over-ride) accessors, so if an accessor exists and a property is defined (only possible from within the accessors setter), then the property would shadow the accessor.  This was done to keep it consistent with what %%__get()%% does and also to support lazy loading.
  
Line 68: Line 77:
  
 ==== Shadowing ==== ==== Shadowing ====
 +[[https://github.com/cpriest/php-src/issues/11|https://github.com/cpriest/php-src/issues/11]]
 +
 Accessors will shadow properties such that if a property named $foo is declared and an accessor for $foo is declared, the accessor will be used instead, only the accessor will have direct access to the underlying property. Accessors will shadow properties such that if a property named $foo is declared and an accessor for $foo is declared, the accessor will be used instead, only the accessor will have direct access to the underlying property.
  
Line 86: Line 97:
  
 ==== isset / unset / attempted writes when no setter / attempted reads when no getter ==== ==== isset / unset / attempted writes when no setter / attempted reads when no getter ====
 +[[https://github.com/cpriest/php-src/issues/12|https://github.com/cpriest/php-src/issues/12]]
  
 Invalid calls to isset/unset will fail silently and return false in the case of isset(), no warning/notice should be thrown. Invalid calls to isset/unset will fail silently and return false in the case of isset(), no warning/notice should be thrown.
Line 93: Line 105:
     private $Seconds;     private $Seconds;
  
-    prortected $Seconds {+    protected $Seconds {
         get() { return $this->Seconds; /* Accesses the private $Seconds directly */ }         get() { return $this->Seconds; /* Accesses the private $Seconds directly */ }
         set($x) { $this->Seconds = $x; /* Accesses the private $Seconds directly */ }         set($x) { $this->Seconds = $x; /* Accesses the private $Seconds directly */ }
Line 109: Line 121:
  
 ==== Interfaces ==== ==== Interfaces ====
 +[[https://github.com/cpriest/php-src/issues/13|https://github.com/cpriest/php-src/issues/13]]
  
 An implementing class may specify a property with an appropriate access level to satisfy an accessor declaration requirement of an interface. An implementing class may specify a property with an appropriate access level to satisfy an accessor declaration requirement of an interface.
Line 159: Line 172:
 Stas suggested that he could either help me to implement this more appropriately (such as changing the engine to make calls into zend_object_handler.c) so that these calls can be resolved dynamically, or that static accessors be shelved for a future version of accessors. Stas suggested that he could either help me to implement this more appropriately (such as changing the engine to make calls into zend_object_handler.c) so that these calls can be resolved dynamically, or that static accessors be shelved for a future version of accessors.
  
 +**Update 12/30/2012**: Too much engine work is necessary to implement static accessors, this is being pushed to a future RFC change.
 ===== TODO ===== ===== TODO =====
-  - Exceptions thrown from an accessor reveal underlying implementation details +  - <del>Exceptions thrown from an accessor reveal underlying implementation details</del> [[https://github.com/cpriest/php-src/issues/14|github#14]] 
-  - get_class_methods() - hide accessors or re-write to call into Reflection* code? +  - <del>get_class_methods() - hide accessors or re-write to call into Reflection* code?</del> [[https://github.com/cpriest/php-src/issues/15|github#15]] 
-  - Check debug_backtrace() output as well +  - <del>Check debug_backtrace() output as well</del> [[https://github.com/cpriest/php-src/issues/16|github#16]] 
-  - Add notes to RFC on shadowing behavior of properties and acessors+  - <del>Add notes to RFC on shadowing behavior of properties and acessors [[https://github.com/cpriest/php-src/issues/17|github#17]]</del>
   - <del>Fix automatically implemented isset to use !== rather than != (Thanks Stas!)</del>   - <del>Fix automatically implemented isset to use !== rather than != (Thanks Stas!)</del>
-  - Check that the following should work and write tests for them:+  - <del>Check that the following should work and write tests for them:</del> [[https://github.com/cpriest/php-src/issues/18|github#18]]
     - <del>$foo->bar[] = 1</del>     - <del>$foo->bar[] = 1</del>
     - <del>$foo->bar[123] = 4</del>     - <del>$foo->bar[123] = 4</del>
Line 172: Line 185:
     - <del>$foo->bar->baz = $x with $bar being object or empty or non-object value (proper error and no leaks -- Stas)</del>     - <del>$foo->bar->baz = $x with $bar being object or empty or non-object value (proper error and no leaks -- Stas)</del>
     - <del>$foo->bar{$x} = "foo" (string offsets), also checks that non-string vars work fine</del>     - <del>$foo->bar{$x} = "foo" (string offsets), also checks that non-string vars work fine</del>
-    - $foo->bar = &bar->baz, etc. with modifying both sides and checking everything works (including modifying via accessors -- Stas) +    - <del>$foo->bar = &bar->baz, etc. with modifying both sides and checking everything works (including modifying via accessors -- Stas)</del> 
-  - Expand on the "Error Messaging" with examples of what has been translated.+  - <del>Expand on the "Error Messaging" with examples of what has been translated. [[https://github.com/cpriest/php-src/issues/17|github#17]]</del>
   - <del>Move all accessor tests into Zend/tests/accessors</del>   - <del>Move all accessor tests into Zend/tests/accessors</del>
  
rfc/propertygetsetsyntax-as-implemented/change-requests.1353295395.txt.gz · Last modified: 2017/09/22 13:28 (external edit)