The mass of solid is equal to diversion of mass flux, and if you consider the sum, which is equal to zero, is basically a mass balance of solid.
If you use the material derivative it gives this expression for porosity variation.