== Why is this an issue?

In PHP, nested functions are functions, which are defined inside other functions.
They have access to the variables of the enclosing functions.
Once the parent function declares the nested function, the nested function becomes available to the global scope.

Code that uses nested functions can become difficult to read, refactor and to maintain and should therefore be avoided.

=== Noncompliant code example

With the default threshold of 3 level:

[source,php]
----
function f () {
  function f_inner () {
    function f_inner_inner() { 
      function f_inner_inner_inner() { // Noncompliant
      }
    }
  }
}
----

== Resources

=== Documentation

* https://www.php.net/manual/en/functions.user-defined.php[PHP Manual - User defined functions]

ifdef::env-github,rspecator-view[]

'''

== Implementation Specification

(visible only on this page)

=== Message

Refactor this code to not nest functions more than {n} levels deep.


=== Parameters

.max
****

----
3
----

Maximum allowed number of nested functions
****


endif::env-github,rspecator-view[]
