The way that most photographers calculate the depth of field for a particular situation is to use a depth of field calculator such as dofmaster.com. You feed in the type of camera, the focal length, the aperture (f-number) and the subject distance and it gives you the depth of field and the hyperfocal distance. However, it becomes very tedious if you have to recalculate the depth of field every time you change the aperture or zoom the lens or move the camera a bit closer or a bit further away. That is where these simple rules of thumb can be very helpful.
When taking a portrait, suppose you decide you want to use a longer focal length to get a different perspective. You move back to keep your subject the same size in the frame. In these circumstances Rule 1 tells you that the depth of field remains approximately the same.
Rule 1
If the subject remains the same size in the frame, then the depth of field remains approximately the same as you change the focal length and subject distance, but keep the f-number unchanged.
Rule 2
If you keep the focal length and the subject distance fixed and only change the aperture (f-number), then the depth of field is approximately proportional to the f-number.
For example, in going from f/4 to f/8, the depth of field approximately doubles.
Rule 3
If you keep the focal length and the aperture (f-number) fixed and only change the subject distance, then the depth of field changes approximately in proportion to the square of the distance.
For example, for a subject 2 metres from the camera there will be approximately 4 times as much depth of field as for a subject 1 metre from the camera.
Limitations
These rules work for any type of camera, including phone cameras. In other words, they work for any size of sensor, but you must keep to one sensor size. The rules do not work when you switch from one sensor size to another.
In most circumstances these rules work very well. However, they break down if the the subject distance gets close to the hyperfocal distance or greater (when the depth of field is infinite). In practice, the rules work best for subject distances that are less than one third of the hyperfocal distance.
They may also break down if the subject is very close to the camera (for macro photography).