Skip to content

Commit 6749326

Browse files
committed
Merge branch '3.x' into 4.x
2 parents 6538aaf + 883a948 commit 6749326

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/Runner.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,12 +872,12 @@ private function registerOutOfMemoryShutdownMessage(string $command)
872872
// Allocate all needed memory beforehand as much as possible.
873873
$errorMsg = PHP_EOL . 'The PHP_CodeSniffer "%1$s" command ran out of memory.' . PHP_EOL;
874874
$errorMsg .= 'Either raise the "memory_limit" of PHP in the php.ini file or raise the memory limit at runtime' . PHP_EOL;
875-
$errorMsg .= 'using `%1$s -d memory_limit=512M` (replace 512M with the desired memory limit).' . PHP_EOL;
875+
$errorMsg .= 'using "%1$s -d memory_limit=512M" (replace 512M with the desired memory limit).' . PHP_EOL;
876876
$errorMsg = sprintf($errorMsg, $command);
877877
$memoryError = 'Allowed memory size of';
878878
$errorArray = [
879879
'type' => 42,
880-
'message' => 'Some random dummy string to take up memory and take up some more memory and some more',
880+
'message' => 'Some random dummy string to take up memory and take up some more memory and some more and more and more and more',
881881
'file' => 'Another random string, which would be a filename this time. Should be relatively long to allow for deeply nested files',
882882
'line' => 31427,
883883
];

tests/EndToEnd/outofmemory_test.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
function tear_down() {
4+
rm -f tests/EndToEnd/Fixtures/*.fixed
5+
}
6+
7+
function test_phpcs_out_of_memory_error_handling() {
8+
OUTPUT="$( { bin/phpcs -d memory_limit=4M --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/; } 2>&1)"
9+
assert_exit_code 255
10+
11+
assert_contains "The PHP_CodeSniffer \"phpcs\" command ran out of memory." "$OUTPUT"
12+
assert_contains "Either raise the \"memory_limit\" of PHP in the php.ini file or raise the memory limit at runtime" "$OUTPUT"
13+
assert_contains "using \"phpcs -d memory_limit=512M\" (replace 512M with the desired memory limit)." "$OUTPUT"
14+
}
15+
16+
function test_phpcbf_out_of_memory_error_handling() {
17+
OUTPUT="$( { bin/phpcbf -d memory_limit=4M --standard=tests/EndToEnd/Fixtures/endtoend.xml.dist tests/EndToEnd/Fixtures/ --suffix=.fixed; } 2>&1)"
18+
assert_exit_code 255
19+
20+
assert_contains "The PHP_CodeSniffer \"phpcbf\" command ran out of memory." "$OUTPUT"
21+
assert_contains "Either raise the \"memory_limit\" of PHP in the php.ini file or raise the memory limit at runtime" "$OUTPUT"
22+
assert_contains "using \"phpcbf -d memory_limit=512M\" (replace 512M with the desired memory limit)." "$OUTPUT"
23+
}

0 commit comments

Comments
 (0)