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

Make methods that use settings non-static #412

Open
tomalec opened this issue Mar 28, 2024 · 0 comments
Open

Make methods that use settings non-static #412

tomalec opened this issue Mar 28, 2024 · 0 comments
Labels
priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. type: enhancement The issue is a request for an enhancement.

Comments

@tomalec
Copy link
Member

tomalec commented Mar 28, 2024

User developer story

As discussed in #398 (comment)

We use a lot of static functions that are not 100% "static," IMO.
PHP spec

Declaring class properties or methods as static makes them accessible without needing an instantiation of the class.

So we could change self::get( * ) to $this->get() or even $this->settings[ * ] (IMHO, get just blurs the picture here w/o much benefit).

Is your feature request related to a problem?

It's not a big problem. This is a singleton, so the line between class and instance is blurred anyway. However, the static could mislead developers by suggesting no instance needs to be created to use them, which is not true.

How to reproduce the problem

Use WC_Google_Gtag_JS::get without creating the instance first.

Describe the solution you'd like

  1. Turn settings to be instance propery
  2. Turn all methods that use settings directly or indirectly to be non-static
  3. Remove get function, as currently it limits the data types to be used as settings to string which may be problematic in the future

Describe alternatives you've considered

Do only 1-2 above.

Technical

Figma link

Acceptance criteria

Unknowns

  • There may be some limitations, logic, or convention put around settings and get in the WC Core class WC_Integration

Out of bounds/rabbit holes

Event tracking

@tomalec tomalec added type: enhancement The issue is a request for an enhancement. priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. labels Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

No branches or pull requests

1 participant