ActiveQuery with via and parameter

Is it possible to use the via relation with a parameter, it should look like so :

public function getActiveProductsCategoriesBrand($brand)
{
    return $this->hasMany(ProductCategory::className(), ['product' => 'id'])->via('activeProducts', function($query, $brand) {
        $query->andWhere(['product.brand' => $brand]);
    });
}

It is but you can only use this method to get modified query, not to hydrate the relation objects directly (when called as property).

The method in example isn’t working, I get an ArgumentCountError. Is there a way to pass extra parameter in the PHP callback signature or by any other method ?

Well, how do you call this method?

$model->getActiveProductsCategoriesBrand($brand->id)->all()

The problem is in my callback definition

function($query, $brand) {
     $query->andWhere(['product.brand' => $brand]);
});

And in the doc it says

A PHP callback for customizing the relation associated with the junction table. Its signature should be function($query), where $query is the query to be customized.