-Clint

On Oct 13, 2012, at 4:21 PM, "Amaury Bouchard" 
<ama...@amaury.net<mailto:ama...@amaury.net>> wrote:

2012/10/13 Clint Priest <cpri...@zerocue.com<mailto:cpri...@zerocue.com>>
Interfaces are used to define what methods must be present, properties are not 
allowed.

Yes, so no one should be correct, right?
I mean, yes the first declaration implies some code; but for the interface, 
it's still a property definition.

You’re mixing concepts here, it’s an accessor definition, not a property 
definition.  property != accessor, an accessor just happens to look and act 
like a property (which is the point of accessors).

Interfaces define methods, not properties. Fine.
But is an accessor (as defined in the RFC) a method? Or should we consider that 
an accessor definition is valid inside an interface? I would say no, because it 
will be used as a property: outside of the object that implements the accessor, 
nobody know if it's an attribute or an accessor function.

It's the whole point of the RFC (apart from the asymetric visibility, but you 
know my point of view).


So, for me, this code should be incorrect:
  interface Fooable {
    public $abc { get; set; }
  }

Because if an object implements the interface:
  class Fooer implements Fooable {
    public $abc {
      get { /* what you want */ }
      set { /* what you want too */ }
    }
  }

How this code will be used? Like that:
  $foo = new Fooer();
  $foo->abc = 3;
  print($foo->abc);

Everybody will agree with me that $abc is used like a property, not as a 
method. So the language should enforce that.
There is a real issue here; this is not a fad from me.

An accessor is a method and an interface which defines an accessor is 
indicating that the accessor must be implemented by any using the interface.

See: http://msdn.microsoft.com/en-US/library/64syzecx(v=vs.80).aspx

Also, "used like a property" does not mean it is a property, it is a method 
call with the syntax of accessing a property, it is still a method call.

I believe __get() may be declared in an interface and if so, then accessors 
should be as well.

Reply via email to