diff --git a/spec/Articus/PathHandler/Attribute/TransferSpec.php b/spec/Articus/PathHandler/Attribute/TransferSpec.php index 9b33f21..41fd9af 100644 --- a/spec/Articus/PathHandler/Attribute/TransferSpec.php +++ b/spec/Articus/PathHandler/Attribute/TransferSpec.php @@ -55,25 +55,6 @@ public function it_transfers_data_from_parsed_body(DTService $dt, Request $in, R $this->__invoke($in)->shouldBe($out); } - public function it_throws_on_data_transfer_from_invalid_parsed_body(DTService $dt, Request $in, Invokable $instanciator, \stdClass $object) - { - $source = PH\Attribute\Transfer::SOURCE_POST; - $type = \stdClass::class; - $subset = ''; - $objectAttr = 'object'; - $instanciatorArgAttrs = []; - $errorAttr = null; - - $data = 123; - - $in->getParsedBody()->shouldBeCalledOnce()->willReturn($data); - - $dt->transferToTypedData($data, $object, $subset)->shouldNotBeCalled(); - - $this->beConstructedWith($dt, $source, $type, $subset, $objectAttr, $instanciator, $instanciatorArgAttrs, $errorAttr); - $this->shouldThrow(PH\Exception\BadRequest::class)->during('__invoke', [$in]); - } - public function it_transfers_data_from_headers(DTService $dt, Request $in, Request $out, Invokable $instanciator, \stdClass $object) { $source = PH\Attribute\Transfer::SOURCE_HEADER; diff --git a/src/Articus/PathHandler/Attribute/Transfer.php b/src/Articus/PathHandler/Attribute/Transfer.php index cfefe01..4fba012 100644 --- a/src/Articus/PathHandler/Attribute/Transfer.php +++ b/src/Articus/PathHandler/Attribute/Transfer.php @@ -120,10 +120,9 @@ public function __invoke(Request $request): Request /** * @param Request $request - * @return array - * @throws Exception\BadRequest + * @return mixed */ - protected function getData(Request $request): array + protected function getData(Request $request) { $data = null; switch ($this->source) @@ -133,10 +132,6 @@ protected function getData(Request $request): array break; case self::SOURCE_POST: $data = $request->getParsedBody(); - if (!\is_array($data)) - { - throw new Exception\BadRequest('Unexpected content'); - } break; case self::SOURCE_ROUTE: $routeResult = $request->getAttribute(RouteResult::class);