I came across some weird behavior today around creating an object from the return value of a getter method.
Firstly I tried this
$productMapper = new $this->getDbMapper();
Which gives me an undefined property: $getDbMapper error.
From what it looks like, it’s trying to access $getDbMapper as class property and then using the () for the class instantiation rather than as the method (?).
I also have this issue in a another section of code with where the class takes a constructor argument.
Would this be a good time to look at some kind of factory pattern over the top or am I just missing something?
I found a fix, which I’m not particularly happy with