How to pass an argument to a function object of a class inside its private method?

I created a CRUD model for the database table in the form of Active Record. If the validation and saving of some fields in the models execute additional operations. The class was quite large. To make the architecture of the code more understandable, I have divided some of the fields into groups and made their logic in a separate submodel, but the field left in the main model. I was going to start the class validate_all(), and call submodel1->validate () submodel2->validate().

But! To save validation errors in the main model, and overwrite the fields for the main model subclass requires access to the object of the main model. But I can't pass to the function the value of $this. For example, I call a function validate_all() main class, and in it I need to call the function validate_meta child class. And this method needs to have access to the instance of the parent class. How to organize it?

I must say that I would not like to split up a table for a subdatasheet. Must exist a pattern that will allow the subclass to access the class. While comes to mind only to send a reference to an object from outside:

$item = new Item();
$item->obj = $item;

It is inconvenient and not at all sure this will work
April 19th 20 at 12:11
1 answer
April 19th 20 at 12:13
What little I understand... But if you want to use, say so yourself, the class object in the method this object, then $this, I think, is the most, if I understand correctly.
Thank you. He didn't check, I got to googling and read that this option is not working. Now checked. Works as need - Alice.Ebert commented on April 19th 20 at 12:16

Find more questions by tags Patterns of designingOOPPHP