PHP - 安全地替换类

Suppose I have made a class:

class abc {
   function a() { .. }
}

In future, say for an updated, I made an updated version of this class, with all same functions plus some new functions and private variables:

class abc2 {
    function a() { .. }
}

Now, what I want is instead of updating my entire code to look for old class abc and replace it with abc2, is there any way that where ever, in my old code, an object of abc is called, it should return abc2. This way I won't have to update class name throughout all instances of abc in my code.

I know I can use extends keyword in class abc2, but I fear my private variables or function won't be accessible.

class abc extends abc2 {
// don't add any methods or whatever
}

class abc2 {
   function a() { .. }
}

This way all methods are the same for abc2 as for abc. As to the private issue, there is no easy way to solve that. Either you rewrite all of your code to fix the class or you make private methods protected. At least try to use this extend method and see if any conflicts occur, I certainly don't hope so.

A solution would have been to have namespaces where you would be able to re-code to use newnamespace\abc; instead of oldnamespace\abc; in your code. This would however also mean rewriting code.