protected function findEndStandardBlock($name, $lineNumber, $maxLine, $targetStepsInto = 0)
    {
        $stepsInto = 0;

        for ($i = $lineNumber; $i <= $maxLine; $i++) {
            if ($this->lineTypes['end' . $name][$i] && $i > $lineNumber) {
                $stepsInto--;

                if ($stepsInto === $targetStepsInto) {
                    return $i;
                }
            }

            if ($this->lineTypes['start' . $name][$i]) {
                $stepsInto++;
            }
        }

        throw new \RuntimeException('Cannot find the end of the ' . $name . ' block starting in line ' . $lineNumber . ' (' . $this->indenterMachine->getLine($lineNumber) . ')');
    }
protected function findEndStandardBlock($name, $lineNumber, $maxLine, $targetStepsInto = 0)
    {
        $stepsInto = 0;

        for ($i = $lineNumber; $i <= $maxLine; $i++) {
            if ($this->lineTypes['end' . $name][$i] && $i > $lineNumber) {
                $stepsInto--;

                if ($stepsInto === $targetStepsInto) {
                    return $i;
                }
            }

            if ($this->lineTypes['start' . $name][$i]) {
                $stepsInto++;
            }
        }

        throw new \RuntimeException('Cannot find the end of the ' . $name . ' block starting in line ' . $lineNumber . ' (' . $this->indenterMachine->getLine($lineNumber) . ')');
    }
protected function findEndStandardBlock ( $ name , $ lineNumber , $ maxLine , $ targetStepsInto = 0 ) { $ stepsInto = 0 ; for ( $ i = $ lineNumber ; $ i <= $ maxLine ; $ i ++ ) { if ( $ this -> lineTypes [ 'end' . $ name ] [ $ i ] && $ i > $ lineNumber ) { $ stepsInto -- ; if ( $ stepsInto === $ targetStepsInto ) { return $ i ; } } if ( $ this -> lineTypes [ 'start' . $ name ] [ $ i ] ) { $ stepsInto ++ ; } } throw new \ RuntimeException ( 'Cannot find the end of the ' . $ name . ' block starting in line ' . $ lineNumber . ' (' . $ this -> indenterMachine -> getLine ( $ lineNumber ) . ')' ) ; }
Generic algorithm to find the end of a block

@param string $name            Name of the block
@param int    $lineNumber      Starting line
@param int    $maxLine         Max line
@param int    $targetStepsInto Targets steps into the source code, used as a stop criteria

@return int

@throws \RuntimeException
Generic algorithm to find the end of a block