This idea is, if you have a result from a join operation, then you can define the structure and operations on the captured entities using something like
$rules = array( 'columns for \Test\User u1 prefixed by u_',
'columns for \Test\Post p1 prefixed by p_',
'columns for \Test\Country c1 prefixed by c_',
'add p1 to u1 using addPost',
'add u1 to p1 using setUser',
'add c1 to u1 using setCountry',
'primary key for \Test\User is id',
'primary key for \Test\Post is pid',
'return u1',
);
It will capture the data for each entity from the columns, do the operations to wire them up, and when all rows for one entity is processed, yields the fully hydrated entity to the calling code.Please let me you your feed back on the idea and if possible, please take a look at the code and let me know if you find any room for improvement.