-1

I have two classes that depend on each other.

class ClassA extends SomeClass
{
    public function __construct(ClassB $classB) {
        $this->classB = $classB;
    }
}

class ClassB extends SomeOtherClass
{
    public function __construct(ClassA $classA) {
        $this->classA = $classA;
    }
}

How can I avoid an endless loop as they're constructed?

Script47
  • 14,230
  • 4
  • 45
  • 66
americanknight
  • 689
  • 3
  • 18
  • 37

1 Answers1

1

There won't be any loop. Neither of them instantiate a new object in their constructors.

Aurelien
  • 1,497
  • 7
  • 15