You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are roughly 4 types of functions in functions.php:
Old style database reading functions with old school $guid and/or $connection2 (\PDO) as parameter.
HTML element rendering.
Utility functions for formatting (e.g. email body sanitation) or other helper functions (e.g. resolving client IP address).
Shortcut for accessing core service feature (e.g. __(), __n(), __m()).
The first type of function cause usage of all the global $guid and $connection2, which is an anti-pattern when transiting to service container architecture.
Proposed Solution
The first type should be rewritten into Gateway service method (or, in some case, rewritten as service provider).
The second type should be rewritten into Form component or other Outputable class.
The thrid type can be rewritten as static methods of some utility classes.
The forth type can be left as-is for now.
In the rewrite, all obsoleted functions should not be removed for now. Instead, they are to be marked deprecated in their phpdocs doc-block. Modern IDE (e.g. VSCode) will identify the deprecated function calls and warn developers.
Problem
There are roughly 4 types of functions in functions.php:
$guid
and/or$connection2
(\PDO) as parameter.The first type of function cause usage of all the global
$guid
and$connection2
, which is an anti-pattern when transiting to service container architecture.Proposed Solution
In the rewrite, all obsoleted functions should not be removed for now. Instead, they are to be marked deprecated in their phpdocs doc-block. Modern IDE (e.g. VSCode) will identify the deprecated function calls and warn developers.
Alternatives
Leaving things as-is.
Additional Context
Functions to refactor:
__
(should be left alone)__n
(should be left alone)__m
(should be left alone)The text was updated successfully, but these errors were encountered: