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

Magic functions starting with "get_" are not working as intended #46

Open
JJJ opened this issue May 6, 2020 · 0 comments · May be fixed by #47
Open

Magic functions starting with "get_" are not working as intended #46

JJJ opened this issue May 6, 2020 · 0 comments · May be fixed by #47
Milestone

Comments

@JJJ
Copy link
Collaborator

JJJ commented May 6, 2020

Originally, part of what I'd wanted Berlin to be able to do, was allow for object variables to be retrieved from methods inside the calling class, like this very bad example below:

Say you want $this->thing but you always want it formatted a certain way. In theory, you could just add this method and it would always get returned formatted as you wanted it:

public function get_thing() {
    return sanitize_key( $this->thing );
}

Unfortunately, the magic getter isn't actually working because all of the class definitions currently require - as a best practice - that their default object variables be defined. This causes PHP to always skip the magic getter and use the property that is defined.

The bug here, is that you should be able to override properties simply but you can't, even though there is code inside of Base::__get() that tries to support it.

You also cannot work around it by omitting object properties, because they are required as part of the way that Berlin expects for classes to be written.

@JJJ JJJ added this to the 1.1.0 milestone May 6, 2020
@JJJ JJJ linked a pull request May 6, 2020 that will close this issue
@JJJ JJJ modified the milestones: 1.1.0, 2.0.0 Feb 23, 2021
@JJJ JJJ modified the milestones: 2.0.0, 2.1.0, Ongoing Jul 15, 2021
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

Successfully merging a pull request may close this issue.

1 participant