How to loop values on Custom properties
Setter / Getter and modulus.

Zoomed in test. Can see 4 pop up when holding mouse down and sliding, but the setter turns 4 to 0
Internal &quot;get/set&quot; function of property?
How can I change IntProperty default value stored within PropertyGroup?
Is There a Way to Change a Prop with an Update Def without Calling the Update Def?
If we set up an int property with a getter and setter can assure it remains in a certain range.  For this case have set the min to 0 and max to 4, but if the property is set to 4 it reverts to zero, using the modulus operator
value = value % 4  

ie the integer remainder when divided by four.  This is stored in the file as a custom property emulating how properties work.
Set the default value in the getter, I've used 0
Test Code.
import bpy

from bpy.props import IntProperty

def get_int(self):
    return self.get(&quot;test&quot;, 0)

def set_int(self, value):
    self[&quot;test&quot;] = value % 4

bpy.types.Object.test = IntProperty(
    min=0,
    max=4,
    get=get_int,
    set=set_int,
    )
    
def draw(self, context):
    layout = self.layout
    ob = context.object
    layout.prop(ob, &quot;test&quot;)

# tacked onto object props transform panel to test.    
bpy.types.OBJECT_PT_transform.prepend(draw)