@@ -265,7 +265,7 @@ public function __get($name) {
265265 if ($ this ->method !== strtoupper ($ name )) {
266266 throw new \LogicException (sprintf ('%s cannot be accessed in a %s request. ' , $ name , $ this ->method ));
267267 }
268- return $ this ->getContent ();
268+ return $ this ->getContent (false );
269269 case 'files ' :
270270 case 'server ' :
271271 case 'env ' :
@@ -277,7 +277,7 @@ public function __get($name) {
277277 : null ;
278278 case 'parameters ' :
279279 case 'params ' :
280- return $ this ->getContent ();
280+ return $ this ->getContent (true );
281281 default ;
282282 return isset ($ this [$ name ])
283283 ? $ this [$ name ]
@@ -400,20 +400,23 @@ public function getCookie(string $key) {
400400 * Returns the request body content.
401401 *
402402 * If the HTTP request method is PUT or POST and the body
403- * not application/x-www-form-urlencoded or application/json a stream
404- * resource is returned, otherwise an array.
403+ * not application/x-www-form-urlencoded or application/json
404+ * and $onlyParameters is false
405+ * a stream resource is returned, otherwise an array.
405406 *
407+ * @param bool $onlyParameters true if only parsed parameters array needed
406408 * @return array|string|resource The request body content or a resource to read the body stream.
407409 *
408410 * @throws \LogicException
409411 */
410- protected function getContent () {
412+ protected function getContent (bool $ onlyParameters ) {
411413 // If the content can't be parsed into an array then return a stream resource.
412414 if (($ this ->method === 'PUT ' || $ this ->method === 'POST ' )
413415 && $ this ->getHeader ('Content-Length ' ) !== '0 '
414416 && $ this ->getHeader ('Content-Length ' ) !== ''
415417 && strpos ($ this ->getHeader ('Content-Type ' ), 'application/x-www-form-urlencoded ' ) === false
416418 && strpos ($ this ->getHeader ('Content-Type ' ), 'application/json ' ) === false
419+ && !$ onlyParameters
417420 ) {
418421 if ($ this ->content === false ) {
419422 throw new \LogicException (
0 commit comments