How do popular PHP frameworks and libraries handle comments in their codebase, considering potential performance implications?

When handling comments in PHP code, popular frameworks and libraries typically strip out comments during the build process to improve performance. This ensures that comments do not affect the runtime performance of the application. One way to achieve this is by using a build tool or script to remove comments before deploying the code.

// This code snippet demonstrates how to remove comments from PHP code using a build script.

$sourceCode = file_get_contents('source.php');
$cleanedCode = preg_replace('!/\*.*?\*/!s', '', $sourceCode); // Remove block comments
$cleanedCode = preg_replace('/\s*\/\/.*$/m', '', $cleanedCode); // Remove line comments

file_put_contents('cleaned_source.php', $cleanedCode);