Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit058fb84

Browse files
DQNEOnicolas-grekas
authored andcommitted
streamed response should return $this
1 parent2fc9b57 commit058fb84

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

‎src/Symfony/Component/HttpFoundation/StreamedResponse.php‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ public function setCallback($callback)
8383
publicfunctionsendHeaders()
8484
{
8585
if ($this->headersSent) {
86-
return;
86+
return$this;
8787
}
8888

8989
$this->headersSent =true;
9090

91-
parent::sendHeaders();
91+
returnparent::sendHeaders();
9292
}
9393

9494
/**
@@ -99,7 +99,7 @@ public function sendHeaders()
9999
publicfunctionsendContent()
100100
{
101101
if ($this->streamed) {
102-
return;
102+
return$this;
103103
}
104104

105105
$this->streamed =true;
@@ -109,6 +109,8 @@ public function sendContent()
109109
}
110110

111111
call_user_func($this->callback);
112+
113+
return$this;
112114
}
113115

114116
/**

‎src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,15 @@ public function testCreate()
121121
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse',$response);
122122
$this->assertEquals(204,$response->getStatusCode());
123123
}
124+
125+
publicfunctiontestReturnThis()
126+
{
127+
$response =newStreamedResponse(function () {});
128+
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse',$response->sendContent());
129+
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse',$response->sendContent());
130+
131+
$response =newStreamedResponse(function () {});
132+
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse',$response->sendHeaders());
133+
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse',$response->sendHeaders());
134+
}
124135
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp