Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Accessors shadowing properties #11

cpriest opened this Issue · 5 comments

2 participants


Code needs to be changed such that accessors shadow properties, unless accessed within a guard state which could only occur from within the already executing accessor.

When accessed when a guard is active, then the property should be returned.


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.

class TimePeriod {
    private $Seconds;

    public $Seconds {
        get() { return $this->Seconds; /* Accesses the private $Seconds directly */ }
        set($x) { $this->Seconds = $x; /* Accesses the private $Seconds directly */ }

$o = new TimePeriod();
$o->Seconds = 45;  /* Calls set accessor */
echo $o->Seconds;  /* Calls get accessor */

Run into an issue w/ moving the accessor_info structure into the property structure. With interfaces you can't define a property without it generating a violation error. So if we want to continue down this path we will have to over-ride the interface checking code to ignore property_info which has an ai pointer. Then this may lead to other future problems because now interfaces will technically have property_info structures... thoughts?


With accessors we begin to allow defining properties via interfaces, don't we? So the property_info should be present in some way (just more restricted), shouldn't it? I don't really know how the interfaces are currently handled, so I can't say for certain, but at least it sounds reasonable :)


Yeah right now any property_info showing up in an interface causes it to throw an error because you can't have properties in interfaces. I'll just need to modify the error check that it ignores a property_info if it's an accessor.


Fixed by b04e5b0

@cpriest cpriest closed this
@cpriest cpriest referenced this issue from a commit
cpriest Changed zend_accessor_info to be a member of zend_property_info rather
than it's own set of hash pairs.  This greatly simplified things and
eliminated a hash lookup for every property access.  Also reduced memory
footprint as a separate copy of doc_comments did not need to be

Fixed #11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.