Fill in the Minesweeper clues
MATL, 18 17 bytes

Thanks to @mbomb007 for a correction in the input of test case 6

32&gt;t3Y6Z+-6b(48+c


Input is a 2D char array, in the format

[' *   '; '*  * '; '  *  '; '    *']


Try it online!

Test cases: 1,
 2, 3, 4, 5, 6.

Explanation

32&gt;      % Input 2D char array implicitly. Transform it into a 2D logical
         % array with asterisk replaced by true and space by false
t        % Duplicate
3Y6      % Push [1 1 1; 1 0 1; 1 1 1]. This defines the neighbourhood
Z+       % 2D convolution, keeping size. Gives the number of neighbouring
         % mines for each position
-6       % Push -6
b        % Bubble up in stack
(        % Assign -6 to the entries indicated by the logical array, i.e.
         % to the positions that originally contained asterisks 
48+      % Add 48. This transforms each number of neighbouring mines
         % into its ASCII code, and -6 into 42 (ASCII code of asterisk)
c        % Convert to char. Display implicitly