Skip to content

Commit 6af5dcd

Browse files
authored
Fix function name collision
* Objects with properties `value` and a custom serializer for the property will generate a method `serializeValue` which will collide with the internal function `serializeValue` * Rename all functions starting with `get*` to avoid further collisions
1 parent ae6f3c6 commit 6af5dcd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Traits/SerializableTrait.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ public function toArray(array $except = [], int $depth = 512)
6767
continue;
6868
}
6969

70-
if ($customSerializer = $this->getCustomSerializerMethod($key)) {
70+
if ($customSerializer = $this->_getCustomSerializerMethod($key)) {
7171
$this->handleSerializedValue($modelData, $key, $this->{$customSerializer}(), $depth, $except);
7272
continue;
7373
}
7474

75-
$modelData[$key] = $this->serializeValue($this->$key, $depth, $except);
75+
$modelData[$key] = $this->_getSerializedValue($this->$key, $depth, $except);
7676
}
7777

7878
return $modelData;
@@ -83,15 +83,15 @@ private function handleSerializedValue(array &$data, $key, $serializedValue, int
8383
if ($serializedValue instanceof SerializedValue &&
8484
$serializedValue->getSerializationStrategy() === SerializedValue::STRATEGY_MERGE_VALUE
8585
) {
86-
$data = array_merge($data, $this->serializeValue($serializedValue->getSerializedValue(), $depth, $except));
86+
$data = array_merge($data, $this->_getSerializedValue($serializedValue->getSerializedValue(), $depth, $except));
8787

8888
return;
8989
}
9090

91-
$data[$key] = $this->serializeValue($serializedValue, $depth, $except);
91+
$data[$key] = $this->_getSerializedValue($serializedValue, $depth, $except);
9292
}
9393

94-
private function serializeValue($value, int $depth, array $except) {
94+
private function _getSerializedValue($value, int $depth, array $except) {
9595
if (is_array($value)) {
9696
$subData = [];
9797
foreach ($value as $subKey => $element) {
@@ -122,7 +122,7 @@ private function evaluateAttribute($attribute, int $depth, array $except)
122122
);
123123
}
124124

125-
private function getCustomSerializerMethod(string $property) {
125+
private function _getCustomSerializerMethod(string $property) {
126126
if (isset(self::$_customSerializer[$property])) {
127127
return self::$_customSerializer[$property];
128128
}

0 commit comments

Comments
 (0)