MarkBaker / PHPMatrix

PHP Class for handling Matrices
MIT License
1.42k stars 13 forks source link

Added function_exists checks to prevent collision on double loading. #14

Closed doekenorg closed 3 years ago

doekenorg commented 3 years ago

Hi,

Couldn't find a Contributing file, so hope this is ok.

I've added some function_exists checks around the function declarations. Reason for this is that multiple Wordpress plugins use your code with composer (including my own). When multiple plugins are activated using this code, the function gets redeclared which is impossible and an error is thrown.

This should circumvent the problem. Hope you are willing to merge. If you need me to do anything else, please let me know.

MarkBaker commented 3 years ago

This issue should really be resolved by the WP plugin developers using phpscoper to prevent double-loading when the same library is used in multiple-plugins; but I've succumbed to the inevitable :-( I've used __NAMESPACE__ rather than the explicitly hard-coded namespace/function name though