"Maximum execution time of 30 seconds exceeded" in hasEvenNumberOfParentheses Function

Hello everyone,

I'm encountering an issue in a Laravel project (Laravel version 10.45.1, PHP version 8.2.15, Filament version 3.2.37) and am hoping someone might be able to offer some assistance. I'm receiving the following error when executing a specific function in my code:

Fatal error: Maximum execution time of 30 seconds exceeded

The error occurs in the following function:

protected static function hasEvenNumberOfParentheses(string $expression)
{
    $tokens = token_get_all('<?php '.$expression);
    // Additional function logic...
}


The function hasEvenNumberOfParentheses is intended to check if a given expression has an even number of parentheses. The error seems to be triggered by the call to token_get_all('<?php '.$expression);, suggesting that parsing the expression takes too long.

Does anyone have any insights on how to resolve this issue?
Any help or suggestions would be greatly appreciated!

Thank you in advance!
Was this page helpful?