The Wayback Machine - https://web.archive.org/web/20201130094020/https://github.com/AOP-PHP/AOP/issues/70
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hooking array elements writes ? #70

Open
baptistepillot opened this issue Aug 28, 2013 · 0 comments
Open

Hooking array elements writes ? #70

baptistepillot opened this issue Aug 28, 2013 · 0 comments

Comments

@baptistepillot
Copy link

@baptistepillot baptistepillot commented Aug 28, 2013

Would it be possible to have this (or some equivalent) working ?

class Classy
{
    /** @var string[] */
    public $prop = array();
}

aop_add_before("write in Classy->prop", function(AopJoinpoint $joinpoint) {
    echo "someone writes into " . $joinpoint->getPropertyName()
    . " keys " . print_r($joinpoint->getPropertyKeys(), true)
    . " value " . $joinpoint->getAssignedValue()
});

$object = new Classy();
$object->prop["michel"]["rouge"] = "is classy";

// Would display :
// someone writes into prop keys array(0 => michel, 1 => rouge) value is classy

I think I can survive without it, but if it can be done, this would be quite great !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.