Automattic / woocommerce-payments

Accept payments via credit card. Manage transactions within WordPress.
https://wordpress.org/plugins/woocommerce-payments/
Other
172 stars 69 forks source link

WooPay - remove hooks from constructors #7260

Open marcinbot opened 11 months ago

marcinbot commented 11 months ago

Description

See base PR: https://github.com/Automattic/woocommerce-payments/pull/7249

We need to move the hooks from all class constructors to init_hooks and then call that method whenever the class is instantiated (or whenever we need the hooks to be attached, separately from instantiation).

The goal of this is to remove the side effects from constructors and allow us to instantiate classes freely.

Acceptance criteria

CC @Automattic/axiom

zmaglica commented 11 months ago

This issue impacts WooPay, so assigning to team Heisenberg (based on team responsibilities Pc2DNy-3z-p2) @frosso . Assigning as part of Gamma Triage process PcreKM-yM-p2.

frosso commented 11 months ago

For added background, since I believe this affects us: p1696435983388759-slack-C0208C3BXHP

marcinbot commented 11 months ago

For added background, since I believe this affects us: p1696435983388759-slack-C0208C3BXHP

Possibly for the individual classes, yes. As per the Slack conversation, let's do what we can and where we can. Ultimately we want the exceptions list in the PHPCS config to be empty so we don't reintroduce this pattern.