public function checkStatement($source, $useClosure = true)
{
$reporting = error_reporting(E_ERROR | E_COMPILE_ERROR);
$error = null;
if ($useClosure) {
try {
$result = eval(sprintf('function(){%s;};return true;', $source));
} catch (ParseError $e) {
$result = false;
// @codeCoverageIgnoreStart
} catch (ParseException $e) {
$result = false;
} catch (Throwable $error) {
} catch (Exception $error) {
}
// @codeCoverageIgnoreEnd
} else {
try {
$result = eval(sprintf('%s;return true;', $source));
// @codeCoverageIgnoreStart
} catch (ParseError $e) {
$result = false;
} catch (ParseException $e) {
$result = false;
} catch (Throwable $error) {
} catch (Exception $error) {
}
// @codeCoverageIgnoreEnd
}
error_reporting($reporting);
if ($error) {
throw $error;
}
return true === $result;
}