Skip to content

Commit db39fd7

Browse files
authored
Fixed the incorrect type hint for CreateStruct::$mainLocationId (#648)
For more details see #648 Key changes: * Fixed the incorrect type hint for `CreateStruct::$mainLocationId` * Ensured values assigned to `CreateStruct::$mainLocationId` are of the correct type * Fixed PHPDoc of the related `Location\Gateway::create` method * [PHPStan] Regenerated baseline after the changes
1 parent 79649c3 commit db39fd7

File tree

6 files changed

+6
-24
lines changed

6 files changed

+6
-24
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19674,12 +19674,6 @@ parameters:
1967419674
count: 1
1967519675
path: src/lib/Persistence/Legacy/Content/Language/MaskGenerator.php
1967619676

19677-
-
19678-
message: '#^Method Ibexa\\Core\\Persistence\\Legacy\\Content\\Location\\Gateway\:\:create\(\) has parameter \$parentNode with no value type specified in iterable type array\.$#'
19679-
identifier: missingType.iterableValue
19680-
count: 1
19681-
path: src/lib/Persistence/Legacy/Content/Location/Gateway.php
19682-
1968319677
-
1968419678
message: '#^Method Ibexa\\Core\\Persistence\\Legacy\\Content\\Location\\Gateway\:\:getBasicNodeData\(\) return type has no value type specified in iterable type array\.$#'
1968519679
identifier: missingType.iterableValue
@@ -19788,12 +19782,6 @@ parameters:
1978819782
count: 1
1978919783
path: src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php
1979019784

19791-
-
19792-
message: '#^Method Ibexa\\Core\\Persistence\\Legacy\\Content\\Location\\Gateway\\DoctrineDatabase\:\:create\(\) has parameter \$parentNode with no value type specified in iterable type array\.$#'
19793-
identifier: missingType.iterableValue
19794-
count: 1
19795-
path: src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php
19796-
1979719785
-
1979819786
message: '#^Method Ibexa\\Core\\Persistence\\Legacy\\Content\\Location\\Gateway\\DoctrineDatabase\:\:createNodeQueryBuilder\(\) has parameter \$columns with no value type specified in iterable type array\.$#'
1979919787
identifier: missingType.iterableValue
@@ -19956,12 +19944,6 @@ parameters:
1995619944
count: 8
1995719945
path: src/lib/Persistence/Legacy/Content/Location/Gateway/ExceptionConversion.php
1995819946

19959-
-
19960-
message: '#^Method Ibexa\\Core\\Persistence\\Legacy\\Content\\Location\\Gateway\\ExceptionConversion\:\:create\(\) has parameter \$parentNode with no value type specified in iterable type array\.$#'
19961-
identifier: missingType.iterableValue
19962-
count: 1
19963-
path: src/lib/Persistence/Legacy/Content/Location/Gateway/ExceptionConversion.php
19964-
1996519947
-
1996619948
message: '#^Method Ibexa\\Core\\Persistence\\Legacy\\Content\\Location\\Gateway\\ExceptionConversion\:\:getBasicNodeData\(\) return type has no value type specified in iterable type array\.$#'
1996719949
identifier: missingType.iterableValue

src/contracts/Persistence/Content/Location/CreateStruct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class CreateStruct extends ValueObject
8383
* This is allowed to be set to true, this will mean this should become main location
8484
* (@todo Find a better way to deal with being able to create the main location)
8585
*
86-
* @var mixed|true
86+
* @var int|true
8787
*/
8888
public $mainLocationId = true;
8989

src/lib/Persistence/Legacy/Content/Location/Gateway.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ abstract public function setNodeUnhidden(string $pathString): void;
209209
abstract public function swap(int $locationId1, int $locationId2): bool;
210210

211211
/**
212-
* Creates a new location in given $parentNode.
212+
* Creates a new location in the given `$parentNode`.
213213
*
214-
* @param array $parentNode parent node raw data
214+
* @param array<string, mixed> $parentNode parent node raw data
215215
*/
216216
abstract public function create(CreateStruct $createStruct, array $parentNode): Location;
217217

src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ public function create(CreateStruct $createStruct, array $parentNode): Location
778778
{
779779
$location = $this->insertLocationIntoContentTree($createStruct, $parentNode);
780780

781-
$mainLocationId = $createStruct->mainLocationId === true ? $location->id : $createStruct->mainLocationId;
781+
$mainLocationId = $createStruct->mainLocationId === true ? $location->id : (int)$createStruct->mainLocationId;
782782
$location->pathString = $parentNode['path_string'] . $location->id . '/';
783783
$query = $this->connection->createQueryBuilder();
784784
$query

src/lib/Persistence/Legacy/Content/Location/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public function copySubtree($sourceId, $destinationParentId, $newOwnerId = null)
285285

286286
// Use content main location if already set, otherwise create location as main
287287
if (isset($mainLocations[$child['contentobject_id']])) {
288-
$createStruct->mainLocationId = $locationMap[$mainLocations[$child['contentobject_id']]]['id'];
288+
$createStruct->mainLocationId = (int)$locationMap[$mainLocations[$child['contentobject_id']]]['id'];
289289
} else {
290290
$createStruct->mainLocationId = true;
291291
$mainLocations[$child['contentobject_id']] = $child['node_id'];

src/lib/Persistence/Legacy/Content/Location/Mapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function getLocationCreateStruct(array $data)
8989
$struct->contentVersion = $data['contentobject_version'];
9090
$struct->hidden = $data['is_hidden'];
9191
$struct->invisible = $data['is_invisible'];
92-
$struct->mainLocationId = $data['main_node_id'];
92+
$struct->mainLocationId = (int)$data['main_node_id'];
9393
$struct->parentId = $data['parent_node_id'];
9494
$struct->pathIdentificationString = $data['path_identification_string'];
9595
$struct->priority = $data['priority'];

0 commit comments

Comments
 (0)