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

"extending" with Decorator pattern - property values #23

Open
bkdotcom opened this issue Aug 26, 2022 · 0 comments
Open

"extending" with Decorator pattern - property values #23

bkdotcom opened this issue Aug 26, 2022 · 0 comments

Comments

@bkdotcom
Copy link

bkdotcom commented Aug 26, 2022

Attempting to create a decorator/wrapper that adds logging

<?php

class OAuthWrapper extends \OAuth
{
    public function __construct(\OAuth $oauth)
    {
        $oauth->enableDebug();
        $this->oauth = $oauth;
        $this->debug = &$this->oauth->debug;   // this line, it does nothing
        echo 'construct: ' . \json_encode($this->oauth->debug) . ' ' . \json_encode($this->debug) . "\n";
    }

    // ...
}

$oauth new \OAuth(self::$consumerKey, self::$consumerSecret);
@oauth2 = new \OAuthWrapper($oauth);

Outputs

construct: true false

I would expect "true true"

Why is this->debug false?

Is the OAuth extension implemented in such a way that this is not possible?

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

No branches or pull requests

1 participant