I have a 3rd party class which I need to modify one of its methods. I don't want to make any changes to the 3rd party so I have extended it.
class NewClass extends ThirdPartyClass {}
The classname ThirdPartyClass
is used throughout my code and by some other 3rd party classes so a i would like to keep that class name.
A solution to this would be to add a namespace to the class.
namespace thirdparty;
class ThirdPartyClass {}
And then extend it
class ThirdPartyClass extends \thirdparty\ThirdPartyClass
But like I said I don't want to make any modifications to and third party classes.
The class was included like so.
require_once('thirdparty/3rdpartyclass.php');
I have tried the following
namespace thirdparty;
require_once('thirdparty/3rdpartyclass.php');
namespace thirdparty;
include_once('thirdparty/3rdpartyclass.php');
Any recommendations on how to use the same class name for my new class ?
EDIT
This works but its not the same as using require_once
eval('namespace thirdparty;?>' . file_get_contents('thirdparty/3rdpartyclass.php'));
This question has nothing to do with PHP namespace removal / mapping and rewriting identifiers and the answer is in no way helpful.