PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

Catch and show informative error message for out of memory errors

Open jrfnl opened this issue 3 years ago • 1 comments

Depending on the size of a code base, the amount of sniffs run and the memory_limit set for PHP, PHPCS can run out of memory.

Depending on the point at which it runs out of memory, it may show the PHP native "out of memory" error or it may exit without any further information (seen that a number of times as well).

Catching out of memory errors and displaying a user-friendly error message isn't straight-forward, as one can't allocate anymore memory in PHP by that time.

However, my friend @schlessera has worked out a way to do it for another CLI tool and shared the code with me.

@gsherwood Would you be interested in me implementing a user friendly error message for out of memory errors for PHPCS ?

jrfnl avatar Jun 24 '22 13:06 jrfnl

I'm not against adding this kind of protection for OOM errors. I haven't seen PHPCS run out of memory without an error, but I'm sure it happens.

gsherwood avatar Jun 27 '22 22:06 gsherwood