Skip to content

Commit f45da16

Browse files
author
omasn
committed
instantiateObject with empty data
1 parent e5bf3db commit f45da16

3 files changed

Lines changed: 3 additions & 5 deletions

File tree

src/ObjectHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function instantiateObject(
7979
return new $class();
8080
}
8181

82-
if ([] === $data || !ArrayHelper::isAssoc($data)) {
82+
if ([] !== $data && !ArrayHelper::isAssoc($data)) {
8383
throw new RuntimeException('invalid data');
8484
}
8585

src/ObjectHandlerInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Omasn\ObjectHandler\Exception\HandlerException;
88
use Omasn\ObjectHandler\Exception\ObjectHandlerException;
9+
use Omasn\ObjectHandler\Exception\RequireArgumentException;
910
use Omasn\ObjectHandler\Exception\ViolationListException;
1011
use Omasn\ObjectHandler\Extractor\DefaultValueExtractorInterface;
1112
use ReflectionException;
@@ -45,6 +46,7 @@ public function handle(
4546
* @throws HandlerException
4647
* @throws ReflectionException
4748
* @throws ViolationListException
49+
* @throws RequireArgumentException
4850
*/
4951
public function instantiateObject(
5052
string $class,

src/Tests/Integration/NewInstance/BaseFunctionalTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ public function testInvalidData(): void
101101
$objectHandler = new ObjectHandler($this->getPropertyInfo());
102102
$objectHandler->addHandleType(new HandleIntType());
103103

104-
$data1 = [];
105-
$this->expectException(\RuntimeException::class);
106-
$objectHandler->instantiateObject(ArrayTest1::class, $data1);
107-
108104
$data2 = ['not assoc'];
109105
$this->expectException(\RuntimeException::class);
110106
$objectHandler->instantiateObject(ArrayTest1::class, $data2);

0 commit comments

Comments
 (0)