3

I have a problem, where I have two third party libraries classes that I have to extend and use together. But both have the same naming convention and two class name end up having the same name.

Since I cannot extend two classes, I don't know how to fix them, how to create a wrapper against one. I cannot use PHP Namespaces as the PHP version is just 5.2.10 and not 5.3.

What options I have?

2
  • are they both autoloaded or include'd? Commented Oct 26, 2010 at 11:59
  • Yes, I have to use both of them, I need to sync two 3rd party libraries. One is redmine and the other is based on cake. Commented Oct 26, 2010 at 12:06

3 Answers 3

1

I think you can implement rpc like interface, for one class. For other you can extend and use. http://en.wikipedia.org/wiki/Remote_procedure_call

Sign up to request clarification or add additional context in comments.

Comments

1

That's the trouble when you don't have namespaces.

The only option you have is to go through the code of one or the other, and change all the class names. Perhaps add a prefix to both of them that makes it clear which one is which.

Comments

1

This is exactly the problem that PHP namespaces are intended to solve. There is no clean way to do this pre-5.3. The best you can do is to rename one or both and go through the libraries correcting the calls. This is a pain, but, as they are separate libraries, this shouldn't be too difficult.

My other suggestion would be to make sure that installing 5.3 really is impossible. It is by far the best solution to your problem.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.