.. _structures-possibleinfiniteloop: .. _possible-infinite-loop: Possible Infinite Loop ++++++++++++++++++++++ Loops on files that can't be open results in infinite loop. `fgets() `_, and functions like `fgetss() `_, `fgetcsv() `_, `fread() `_, return false when they finish reading, or can't access the file. In case the file is not accessible, comparing the `result `_ of the reading to something that is falsy, leads to a permanent valid condition. The execution will only finish when the ``max_execution_time`` is reached. It is recommended to check the file resources when they are opened, and always use === or !== to compare readings. `feof() `_ is also a reliable function here. .. code-block:: php Connex PHP features ------------------- + `loop `_ Suggestions ___________ * Add a check before using the result of the method. * Add a counter to break the loop after a limit of loops. Specs _____ +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Short name | Structures/PossibleInfiniteLoop | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Analyze `, :ref:`Changed Behavior ` | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 1.1.5 | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Severity | Critical | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+-------------------------------------------------------------------------------------------------------------------------+