Function __global->check_for_infinite_loop

Definitions

sources/global3.php

  • Use this function to count iterations for potential infinite loops.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: bool

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$codename ID_TEXT No No required parameter N/A N/A A codename to use for this check, such as a function name
$args array No No required parameter N/A N/A An array of arguments to determine if this is a unique call, usually parameters passed to the function (func_get_args)
$allowed_iterations integer No No 10 N/A N/A The number of times we are allowed to call this with the same $codename and $args before this is considered an infinite loop
$actually_exit boolean No No True N/A N/A Whether we want to bail on critical error if an infinite loop occurs

Returns

  • Whether an infinite loop is occurring
  • Type: boolean
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Use this function to count iterations for potential infinite loops.
 *
 * @param  ID_TEXT $codename A codename to use for this check, such as a function name
 * @param  array $args An array of arguments to determine if this is a unique call, usually parameters passed to the function (func_get_args)
 * @param  integer $allowed_iterations The number of times we are allowed to call this with the same $codename and $args before this is considered an infinite loop
 * @param  boolean $actually_exit Whether we want to bail on critical error if an infinite loop occurs
 * @return boolean Whether an infinite loop is occurring
 */

function check_for_infinite_loop(string $codename, array $args, int $allowed_iterations = 10, bool $actually_exit = true) : bool