8000 Small improvements · symfony/symfony@8f13c51 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f13c51

Browse files
Small improvements
1 parent 68582dd commit 8f13c51

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

src/Symfony/Component/Messenger/Tests/Transport/Enhancers/MemoryLimitReceiverTest.php

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,20 @@ public function testReceiverStopsWhenMemoryLimitExceeded($memoryUsage, $memoryLi
4343

4444
public function memoryProvider()
4545
{
46-
return array(
47-
array(2048, 1024, true),
48-
array(1024, 1024, true),
49-
array(1024, 2048, false),
50-
array(129 * 1024, '128K', true),
51-
array(128 * 1024, '128K', true),
52-
array(127 * 1024, '128K', false),
53-
array(65 * 1024 * 1024, '64M', true),
54-
array(64 * 1024 * 1024, '64M', true),
55-
array(63 * 1024 * 1024, '64M', false),
56-
array(2 * 1024 * 1024 * 1024, '1G', true),
57-
array(1 * 1024 * 1024 * 1024, '1G', true),
58-
array(10 * 1024 * 1024, '1G', false),
59-
array(1 * 1024 * 1024 * 1024, '1M', true),
60-
array(1 * 1024 * 1024 * 1024, 10000 '1K', true),
61-
);
46+
yield array(2048, 1024, true);
47+
yield array(1024, 1024, true);
48+
yield array(1024, 2048, false);
49+
yield array(129 * 1024, '128K', true);
50+
yield array(128 * 1024, '128K', true);
51+
yield array(127 * 1024, '128K', false);
52+
yield array(65 * 1024 * 1024, '64M', true);
53+
yield array(64 * 1024 * 1024, '64M', true);
54+
yield array(63 * 1024 * 1024, '64M', false);
55+
yield array(2 * 1024 * 1024 * 1024, '1G', true);
56+
yield array(1 * 1024 * 1024 * 1024, '1G', true);
57+
yield array(10 * 1024 * 1024, '1G', false);
58+
yield array(1 * 1024 * 1024 * 1024, '1M', true);
59+
yield array(1 * 1024 * 1024 * 1024, '1K', true);
6260
}
6361

6462
/**
@@ -73,12 +71,10 @@ public function testReceiverThrowsExceptionWithInvalidMemoryLimit($memoryLimit)
7371

7472
public function invalidMemoryLimitProvider()
7573
{
76-
return array(
77-
array('without_digit'), // string without digit
78-
array('1024X'), // bad unit
79-
array('128m'), // lowercase unit
80-
array('128 M'), // string with space
81-
);
74+
yield array('without_digit'); // string without digit
75+
yield array('1024X'); // bad unit
76+
yield array('128m'); // lowercase unit
77+
yield array('128 M'); // string with space
8278
}
8379
}
8480

src/Symfony/Component/Messenger/Transport/Enhancers/MemoryLimitReceiver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(ReceiverInterface $decoratedReceiver, string $memory
2626
{
2727
$this->decoratedReceiver = $decoratedReceiver;
2828
$this->memoryLimit = $this->convertToOctets($memoryLimit);
29-
$this->memoryResolver = $memoryResolver ?? function () {
29+
$this->memoryResolver = $memoryResolver ?: function () {
3030
return \memory_get_usage();
3131
};
3232
}
@@ -62,6 +62,6 @@ private function convertToOctets(string $size): int
6262
throw new \InvalidArgumentException('Invalid memory limit given.');
6363
}
6464

65-
return (int) $size;
65+
return $size;
6666
}
6767
}

0 commit comments

Comments
 (0)
0