Skip to content

Commit 5a33288

Browse files
committed
is_scalar check before using $type as array key
1 parent f5a7d38 commit 5a33288

5 files changed

+5
-5
lines changed

src/Transformer/Helpers/RecursiveDeleteHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static function deleteProperties(array &$mappings, array &$array, $typeKe
8787
private static function deleteMatchedClassProperties(array &$mappings, array &$array, $typeKey, array &$newArray)
8888
{
8989
$type = $array[Serializer::CLASS_IDENTIFIER_KEY];
90-
if ($type === $typeKey) {
90+
if (is_scalar($type) && $type === $typeKey) {
9191
$deletions = $mappings[$typeKey]->getHiddenProperties();
9292
if (!empty($deletions)) {
9393
self::deleteNextLevelProperties($mappings, $array, $typeKey, $deletions, $newArray);

src/Transformer/Helpers/RecursiveFilterHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private static function deleteMatchedClassNotInFilterProperties(
5252
$type,
5353
array &$newArray
5454
) {
55-
if ($type === $typeKey) {
55+
if (is_scalar($type) && $type === $typeKey) {
5656
$keepKeys = $mappings[$typeKey]->getFilterKeys();
5757
$idProperties = $mappings[$typeKey]->getIdProperties();
5858

src/Transformer/Helpers/RecursiveFormatterHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static function getIdProperties(array &$mappings, $type)
6060
{
6161
$idProperties = [];
6262

63-
if (!empty($mappings[$type])) {
63+
if (is_scalar($type) && !empty($mappings[$type])) {
6464
$idProperties = $mappings[$type]->getIdProperties();
6565
}
6666

src/Transformer/Helpers/RecursiveRenamerHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static function renameKeyValue(array &$mappings, array &$array, $typeKey)
6969
*/
7070
private static function renameMatchedClassKeys(array &$mappings, array &$array, $typeKey, $type, array &$newArray)
7171
{
72-
if ($type === $typeKey) {
72+
if (is_scalar($type) && $type === $typeKey) {
7373
$replacements = $mappings[$typeKey]->getAliasedProperties();
7474
if (!empty($replacements)) {
7575
self::renameKeys($mappings, $array, $typeKey, $replacements, $newArray);

src/Transformer/Transformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public function setNextUrl($nextUrl)
266266
*/
267267
protected function getResponseAdditionalLinks(array $copy, $type)
268268
{
269-
if (!empty($this->mappings[$type])) {
269+
if (is_scalar($type) && !empty($this->mappings[$type])) {
270270
$otherUrls = $this->mappings[$type]->getUrls();
271271
list($idValues, $idProperties) = RecursiveFormatterHelper::getIdPropertyAndValues(
272272
$this->mappings,

0 commit comments

Comments
 (0)