Skip to content
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.

Code completion support for magic property 'get' methods #387

Open
nevadascout opened this issue Sep 12, 2018 · 0 comments
Open

Code completion support for magic property 'get' methods #387

nevadascout opened this issue Sep 12, 2018 · 0 comments

Comments

@nevadascout
Copy link
Member

Handle magic get methods as shown:

    private $prop = 'test';
    protected $_getters = [];

    public function __construct() {
        $this->_getters = ['prop'];
    }

    public function &__get($fieldName)
    {
        if (method_exists($this, "__get_$fieldName")) {
            $return = $this->{"__get_$fieldName[1]"}();
        } elseif (in_array($fieldName, $this->_getters)) {
            $return = $this->$fieldName;
        }

        return $return;
    }
}

$a = new Test();
// should show a code completion suggestion here, even though the property is private
echo $a->prop;
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant