Skip to content

Commit 3d5ea75

Browse files
committed
Opcode optimization
1 parent cc3b158 commit 3d5ea75

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Psr6Store.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function write(Request $request, Response $response)
201201
$response->headers->set('X-Content-Digest', $contentDigest);
202202

203203
if (!$response->headers->has('Transfer-Encoding')) {
204-
$response->headers->set('Content-Length', strlen($response->getContent()));
204+
$response->headers->set('Content-Length', \strlen($response->getContent()));
205205
}
206206
}
207207

@@ -394,7 +394,7 @@ public function getCacheKey(Request $request)
394394
{
395395
// Strip scheme to treat https and http the same
396396
$uri = $request->getUri();
397-
$uri = substr($uri, strlen($request->getScheme().'://'));
397+
$uri = substr($uri, \strlen($request->getScheme().'://'));
398398

399399
return 'md'.hash('sha256', $uri);
400400
}
@@ -407,7 +407,7 @@ public function getCacheKey(Request $request)
407407
*/
408408
public function getVaryKey(array $vary, HeaderBag $headerBag)
409409
{
410-
if (0 === count($vary)) {
410+
if (0 === \count($vary)) {
411411
return self::NON_VARYING_KEY;
412412
}
413413

@@ -473,7 +473,7 @@ private function saveDeferred($key, $data, $expiresAfter = null, $tags = [])
473473
$item->set($data);
474474
$item->expiresAfter($expiresAfter);
475475

476-
if (0 !== count($tags)) {
476+
if (0 !== \count($tags)) {
477477
$item->tag($tags);
478478
}
479479

tests/Psr6StoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function testWriteStoresTheResponseContent()
165165
$this->assertTrue($this->getCache()->hasItem($contentDigest), 'Response content is stored in cache.');
166166
$this->assertSame($response->getContent(), $this->getCache()->getItem($contentDigest)->get(), 'Response content is stored in cache.');
167167
$this->assertSame($contentDigest, $response->headers->get('X-Content-Digest'), 'Content digest is stored in the response header.');
168-
$this->assertSame(strlen($response->getContent()), $response->headers->get('Content-Length'), 'Response content length is updated.');
168+
$this->assertSame(\strlen($response->getContent()), $response->headers->get('Content-Length'), 'Response content length is updated.');
169169
}
170170

171171
public function testWriteDoesNotStoreTheResponseContentOfNonOriginalResponse()

0 commit comments

Comments
 (0)