What best practices should be followed when declaring and using static methods within PHP classes, especially when dealing with recursive functions?

When declaring and using static methods within PHP classes, especially when dealing with recursive functions, it is important to ensure that the static method is self-contained and does not rely on any instance properties or methods. This is because static methods do not have access to the $this variable. Additionally, when dealing with recursive functions, make sure to properly handle the base case to prevent infinite recursion.

class MyClass {
    public static function recursiveFunction($n) {
        // Base case
        if ($n <= 0) {
            return 0;
        }
        
        // Recursive call
        return $n + self::recursiveFunction($n - 1);
    }
}

// Usage
echo MyClass::recursiveFunction(5); // Output: 15