comparison vendor/symfony/http-foundation/StreamedResponse.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
15 * StreamedResponse represents a streamed HTTP response. 15 * StreamedResponse represents a streamed HTTP response.
16 * 16 *
17 * A StreamedResponse uses a callback for its content. 17 * A StreamedResponse uses a callback for its content.
18 * 18 *
19 * The callback should use the standard PHP functions like echo 19 * The callback should use the standard PHP functions like echo
20 * to stream the response back to the client. The flush() method 20 * to stream the response back to the client. The flush() function
21 * can also be used if needed. 21 * can also be used if needed.
22 * 22 *
23 * @see flush() 23 * @see flush()
24 * 24 *
25 * @author Fabien Potencier <fabien@symfony.com> 25 * @author Fabien Potencier <fabien@symfony.com>
33 /** 33 /**
34 * @param callable|null $callback A valid PHP callback or null to set it later 34 * @param callable|null $callback A valid PHP callback or null to set it later
35 * @param int $status The response status code 35 * @param int $status The response status code
36 * @param array $headers An array of response headers 36 * @param array $headers An array of response headers
37 */ 37 */
38 public function __construct(callable $callback = null, $status = 200, $headers = array()) 38 public function __construct(callable $callback = null, $status = 200, $headers = [])
39 { 39 {
40 parent::__construct(null, $status, $headers); 40 parent::__construct(null, $status, $headers);
41 41
42 if (null !== $callback) { 42 if (null !== $callback) {
43 $this->setCallback($callback); 43 $this->setCallback($callback);
53 * @param int $status The response status code 53 * @param int $status The response status code
54 * @param array $headers An array of response headers 54 * @param array $headers An array of response headers
55 * 55 *
56 * @return static 56 * @return static
57 */ 57 */
58 public static function create($callback = null, $status = 200, $headers = array()) 58 public static function create($callback = null, $status = 200, $headers = [])
59 { 59 {
60 return new static($callback, $status, $headers); 60 return new static($callback, $status, $headers);
61 } 61 }
62 62
63 /** 63 /**
109 109
110 if (null === $this->callback) { 110 if (null === $this->callback) {
111 throw new \LogicException('The Response callback must not be null.'); 111 throw new \LogicException('The Response callback must not be null.');
112 } 112 }
113 113
114 call_user_func($this->callback); 114 \call_user_func($this->callback);
115 115
116 return $this; 116 return $this;
117 } 117 }
118 118
119 /** 119 /**
127 { 127 {
128 if (null !== $content) { 128 if (null !== $content) {
129 throw new \LogicException('The content cannot be set on a StreamedResponse instance.'); 129 throw new \LogicException('The content cannot be set on a StreamedResponse instance.');
130 } 130 }
131 131
132 $this->streamed = true;
133
132 return $this; 134 return $this;
133 } 135 }
134 136
135 /** 137 /**
136 * {@inheritdoc} 138 * {@inheritdoc}