What are the challenges of debugging foreign code when using an indentation parser in PHP?

When debugging foreign code that uses indentation parsers in PHP, one of the main challenges is identifying and fixing syntax errors caused by inconsistent or incorrect indentation. To solve this issue, you can use a code formatter tool to automatically adjust the code's indentation to adhere to a consistent style before attempting to debug it further.

// Example of using a code formatter tool to fix inconsistent indentation in foreign code
$foreignCode = "
function foo() {
    if(true) {
    echo 'Hello, World!';
    }
}";

// Using PHP-CS-Fixer to format the code
$phpCsFixer = new PhpCsFixer\FixerFactory();
$fixer = $phpCsFixer->getFixer('indentation');
$fixedCode = $fixer->fix($foreignCode);

// Now $fixedCode contains the correctly indented code
echo $fixedCode;