Cakephp 3 - limit () and contained model

I have two models, named Post and Comment, which are linked by Post hasMany Comment and Comment belongsTo Post.
I want to fetch all posts with the first five comments each. I would use this code:

$this->Posts->find(‘all’)
->contain([
‘Comments’ => function($q) {
return $q
->order(‘created ASC’)
->limit(5);
}
]);

This works incorrectly with the limit(5). Please help to solve this.

I’m facing the same problem.
Did you find something that could help ?

Please refer this https://github.com/cakephp/cakephp/issues/8060