Skip to content

Commit 7c75f79

Browse files
authored
Merge pull request #4 from mrsuh/dev
$parent_properties
2 parents ee95e27 + cc347ef commit 7c75f79

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Document/Document.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public function getId()
1818
* @param $id
1919
* @return $this
2020
*/
21-
public function setId(string $id)
21+
public function setId($id)
2222
{
23-
$this->id = $id;
23+
$this->id = (string)$id;
2424

2525
return $this;
2626
}

src/DocumentMapper/DataMapper.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ private function mapObj(string $class_name, array $data)
133133
{
134134
$obj = $this->instantiator->instantiate($class_name);
135135
$reflect = new \ReflectionClass($obj);
136-
$properties = array_merge($reflect->getProperties(), $reflect->getParentClass()->getProperties());
136+
$parent_properties = null !== $reflect->getParentClass() ? $reflect->getParentClass()->getProperties() : [];
137+
$properties = array_merge($reflect->getProperties(), $parent_properties);
137138

138139
foreach($properties as $prop) {
139140

@@ -186,7 +187,8 @@ private function objToArray(Document $obj)
186187
{
187188
$data = [];
188189
$reflect = new \ReflectionClass($obj);
189-
$properties = array_merge($reflect->getProperties(), $reflect->getParentClass()->getProperties());
190+
$parent_properties = null !== $reflect->getParentClass() ? $reflect->getParentClass()->getProperties() : [];
191+
$properties = array_merge($reflect->getProperties(), $parent_properties);
190192

191193
foreach ($properties as $prop) {
192194

0 commit comments

Comments
 (0)