PHP 8.2 — Remove conditional memory_reset_peak_usage() call
Problem Description
In the file src/Http/HttpRequestHandler.php there is a conditional call to the memory_reset_peak_usage() function, which checks the PHP version before calling it:
if (PHP_VERSION_ID >= 80200) {
\memory_reset_peak_usage();
}
Since the project is dropping support for PHP 8.1 and now requires PHP 8.2+, this condition is unnecessary and can be removed.
Location
/home/decodo/work/workerman-bundle/src/Http/HttpRequestHandler.php lines 49-51
Analysis
Current code (lines 47-51):
public function __invoke(TcpConnection $connection, Request $request): void
{
if (PHP_VERSION_ID >= 80200) {
\memory_reset_peak_usage();
}
// ...
}
The memory_reset_peak_usage() function was introduced in PHP 8.2 and is used to reset peak memory usage. The condition PHP_VERSION_ID >= 80200 was necessary when the project supported PHP 8.1, but is now redundant.
Proposed Solution
Remove the if condition and call the function directly:
public function __invoke(TcpConnection $connection, Request $request): void
{
\memory_reset_peak_usage();
// ...
}
Change:
- Remove lines 49-51 (the
if block)
- Leave only the call
\memory_reset_peak_usage(); on line 49
Priority
🔵 MINOR — code cleanup. This change does not affect functionality, but simplifies the code and removes an unnecessary condition that will always be satisfied in the new PHP 8.2+ environment.
Tests
After making changes:
- Run
vendor/bin/phpunit to ensure the HTTP handler works correctly
- Check if there are any memory-related errors in the logs
- Verify operation during HTTP request handling
PHP 8.2 — Remove conditional memory_reset_peak_usage() call
Problem Description
In the file
src/Http/HttpRequestHandler.phpthere is a conditional call to thememory_reset_peak_usage()function, which checks the PHP version before calling it:Since the project is dropping support for PHP 8.1 and now requires PHP 8.2+, this condition is unnecessary and can be removed.
Location
/home/decodo/work/workerman-bundle/src/Http/HttpRequestHandler.phplines 49-51Analysis
Current code (lines 47-51):
The
memory_reset_peak_usage()function was introduced in PHP 8.2 and is used to reset peak memory usage. The conditionPHP_VERSION_ID >= 80200was necessary when the project supported PHP 8.1, but is now redundant.Proposed Solution
Remove the
ifcondition and call the function directly:Change:
ifblock)\memory_reset_peak_usage();on line 49Priority
🔵 MINOR — code cleanup. This change does not affect functionality, but simplifies the code and removes an unnecessary condition that will always be satisfied in the new PHP 8.2+ environment.
Tests
After making changes:
vendor/bin/phpunitto ensure the HTTP handler works correctly