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
When opening the plugin's code in my IDE (Cursor), I expect not to see error flags about classes that are not found.
Current Behavior
The class MA_Wpengine_Integration is flagged with an error in the method flushWPECache because the class \WpeCommon does not exist on the project. The flag is correct since that class is only defined when that 3rd party plugin is installed, but we have options to keep its functionality and still avoid those flags.
Possible Solution
Refactor the method flushWPECache using method_exists instead of function_exists and using call_user_func instead of mentioning the class name directly. Something like the following snippet
if (method_exists('WpeCommon', 'purge_memcached')) {
call_user_func(['WpeCommon', 'purge_memcached']);
}
Using that snippet, we mention the class name as a string, not triggering the errors, considering it will only be called if the class is also defined.
The text was updated successfully, but these errors were encountered:
I've found a similar issue on src/core/Classes/Utils.php:
Undefined function et_get_theme_version
Use call_user_func on that function.
Undefined constant ELEMENTOR_PRO_VERSION
Use constant('ELEMENTOR_PRO_VERSION') instead of the constant directly.
Undefined constant WPSEO_VERSION
Also use constant(.....
andergmartins
changed the title
Refactor method MA_Wpengine_Integration::flushWPECache to fix error flags in the IDE
Fix errors found by static code analysis to remove error flags raised by the IDE
Dec 2, 2024
Expected Behavior
When opening the plugin's code in my IDE (Cursor), I expect not to see error flags about classes that are not found.
Current Behavior
The class
MA_Wpengine_Integration
is flagged with an error in the methodflushWPECache
because the class\WpeCommon
does not exist on the project. The flag is correct since that class is only defined when that 3rd party plugin is installed, but we have options to keep its functionality and still avoid those flags.Possible Solution
Refactor the method
flushWPECache
usingmethod_exists
instead offunction_exists
and usingcall_user_func
instead of mentioning the class name directly. Something like the following snippetUsing that snippet, we mention the class name as a string, not triggering the errors, considering it will only be called if the class is also defined.
The text was updated successfully, but these errors were encountered: