I've been working lately on a custom framework, so before posting my concern I will explain the way I organized the framework.
There is a main class, from which all other classes are extended. All the other classes are interconnected between them with a a variable which has the name of the class. Easier said, I have the MAIN class. I also have the classes THEME, URI, INIT.
After the framework has initialized, if I get the MAIN instance and assign it to a variable, lets say $main, and I can use the other classes like this:
$main->theme;
$main->uri;
$main->init;
I can even use $main->theme->uri->theme->init if I want :D, but no way $main->theme->theme.
Also, from inside the classes (other than MAIN), I can access the other classes like $this->init, $this->theme, etc.
The properties that point to those classes are references.
Now my concern, when I print_r the $main variable, I get a lot of RECURSION elements. The framework loads fast, and the memory consumption is 28MB, but still I get that recursion. Does it mean that the way I organized my framework is wrong, or it's just the print_r function that sees pointers pointing to same classes, and avoids infinite recursion?
Ok, here's a print_r of the TF_TFUSE class (the main one i was talking about). Here only two other classes have been implemented (too reduce output).
TF_TFUSE Object
(
[framework_version] => 2.1
[load] => TF_LOAD Object
(
[_the_class_name] => LOAD
[framework_version] => 2.1
[buffer] => TF_BUFFER Object
(
[_filters:protected] => Array
(
)
[_buffer:protected] =>
[_the_class_name] => BUFFER
[_is_end:protected] =>
[framework_version] => 2.1
[load] => TF_LOAD Object
*RECURSION*
)
)
[buffer] => TF_BUFFER Object
(
[_filters:protected] => Array
(
)
[_buffer:protected] =>
[_the_class_name] => BUFFER
[_is_end:protected] =>
[framework_version] => 2.1
[load] => TF_LOAD Object
(
[_the_class_name] => LOAD
[framework_version] => 2.1
[buffer] => TF_BUFFER Object
*RECURSION*
)
)
)