mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
feature: allow specifying memory limit (#3947)
This commit is contained in:
parent
278addd93d
commit
ec7876b8d6
@ -315,6 +315,9 @@ Basic configuration:
|
||||
--use-ini-defaults
|
||||
Use PHP-provided ini defaults for memory and error display
|
||||
|
||||
--memory-limit=LIMIT
|
||||
Use a specific memory limit. Cannot be combined with --use-ini-defaults
|
||||
|
||||
--disable-extension=[extension]
|
||||
Used to disable certain extensions while Psalm is running.
|
||||
|
||||
|
@ -12,6 +12,7 @@ require_once('command_functions.php');
|
||||
require_once __DIR__ . '/Psalm/Internal/exception_handler.php';
|
||||
|
||||
use Psalm\ErrorBaseline;
|
||||
use Psalm\Exception\ConfigException;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\Provider;
|
||||
use Psalm\Config;
|
||||
@ -24,6 +25,7 @@ use Psalm\Progress\VoidProgress;
|
||||
use function array_slice;
|
||||
use function getopt;
|
||||
use function implode;
|
||||
use function is_scalar;
|
||||
use function array_map;
|
||||
use function substr;
|
||||
use function preg_replace;
|
||||
@ -92,6 +94,7 @@ $valid_long_options = [
|
||||
'help',
|
||||
'ignore-baseline',
|
||||
'init',
|
||||
'memory-limit:',
|
||||
'monochrome',
|
||||
'no-cache',
|
||||
'no-reflection-cache',
|
||||
@ -189,7 +192,18 @@ array_map(
|
||||
if (!array_key_exists('use-ini-defaults', $options)) {
|
||||
ini_set('display_errors', 'stderr');
|
||||
ini_set('display_startup_errors', '1');
|
||||
ini_set('memory_limit', (string) (8 * 1024 * 1024 * 1024));
|
||||
|
||||
$memoryLimit = (8 * 1024 * 1024 * 1024);
|
||||
|
||||
if (array_key_exists('memory-limit', $options)) {
|
||||
$memoryLimit = $options['memory-limit'];
|
||||
|
||||
if (!is_scalar($memoryLimit)) {
|
||||
throw new ConfigException('Invalid memory limit specified.');
|
||||
}
|
||||
}
|
||||
|
||||
ini_set('memory_limit', (string) $memoryLimit);
|
||||
}
|
||||
|
||||
if (array_key_exists('help', $options)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user