Physics2D.BoxCast
Physics2D.BoxCastAll
Physics2D.BoxCastNonAlloc
these are all broken, that never takes distance parameter into account.
Consider the following code
var size = new Vector2(1,1)
var angle = 0f;
var distance = 5f;
Physics2D.BoxCastAll(origin, size, angle, Vector2.down, distance, layers);
this code will fail to detect anything within the 5 distance, and will only detect something touching that 1 x 1 size
in contrary to this code
var size = new Vector2(1,1)
var angle = 0f;
var distance = 5f;
Physics2D.CapsuleCastAll(origin, size, CapsuleDirection2D.Vertical, angle, Vector2.down, distance, layers);
the capsule cast version works properly and correctly detects everything in 5 distance away