')) { $targetTokens[] = T_ENUM; } if (!$startCounting && in_array($token[0], $targetTokens)) { $startCounting = true; } // use curly braces as a sign of depth if ($token[1] === '{') { if ($depth < $cutOffDepth) { $cleanContents .= $token[1]; } if ($startCounting) { ++$depth; } } elseif ($token[1] === '}') { if ($startCounting) { --$depth; // stop counting if we've just come out of the // class/interface/trait declaration if ($depth <= 0) { $startCounting = false; } } if ($depth < $cutOffDepth) { $cleanContents .= $token[1]; } } elseif ($depth < $cutOffDepth) { $cleanContents .= $token[1]; } } // return cleaned class return trim($cleanContents ?? ''); } }