S
S
Sergey Rogozhkin2015-05-11 12:36:26
PHP
Sergey Rogozhkin, 2015-05-11 12:36:26

PHP, to inherit an object during execution, is it possible?

Situation: you must first declare class A, then include a number of files in which library class B is declared (part of the paths is calculated in class A), then make sure that during execution it turns out A extends B. If I immediately write extends B, then an error will fly out, t .to. required files not found.
I understand that the question is strange and is actually the result of an incorrect architecture, but for a number of reasons in the old application I cannot use autoload and composer in this place. Instead of inheritance, I used the use of a class as an object variable, but with inheritance it would have turned out more beautiful and without unnecessary wrappers. The question is more of an academic interest in the non-standard features of the language. Is there a way to dynamically assign a parent to an object?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
6
65536, 2015-05-11
@65536

part of paths is calculated in class A
paths should be calculated in your autoload files
https://php.net/manual/en/function.spl-autoload-re...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question