Skip to content

Commit

Permalink
TASK: Assert that getRootGeneralizations is never empty as part of …
Browse files Browse the repository at this point in the history
…the interface

This removes manual assertions on the calling site which are never expected.
  • Loading branch information
mhsdesign committed May 13, 2024
1 parent 47ad799 commit 3febbd6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ public function getWeightedDimensionSpacePointByHash(string $hash): ?WeightedDim
/**
* Returns the root generalizations indexed by hash
*
* @return array<string,DimensionSpacePoint>
* Even in a zero-dimensional content repository the array will have at least one entry
* of an empty dimension space point {@see DimensionSpacePoint::createWithoutDimensions()}
*
* @return non-empty-array<string,DimensionSpacePoint>
*/
public function getRootGeneralizations(): array
{
Expand All @@ -127,7 +130,13 @@ public function getRootGeneralizations(): array
$rootGeneralizations[$dimensionSpacePointHash] = $weightedDimensionSpacePoint->dimensionSpacePoint;
}
}

if (empty($rootGeneralizations)) {
// safeguard, should not happen here:
throw new \RuntimeException(
'The dimension space is empty, please check your configuration.',
1710613747
);
}
return $rootGeneralizations;
}

Expand Down
6 changes: 0 additions & 6 deletions Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ public function createSiteNodeIfNotExists(Site $site, string $nodeTypeName): voi
}

$rootDimensionSpacePoints = $this->interDimensionalVariationGraph->getRootGeneralizations();
if (empty($rootDimensionSpacePoints)) {
throw new \InvalidArgumentException(
'The dimension space is empty, please check your configuration.',
1651957153
);
}
$arbitraryRootDimensionSpacePoint = array_shift($rootDimensionSpacePoints);

$siteNodeAggregateId = NodeAggregateId::create();
Expand Down
6 changes: 0 additions & 6 deletions Neos.Neos/Classes/View/FusionExceptionViewInternals.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ public function __construct(
public function getArbitraryDimensionSpacePoint(): DimensionSpacePoint
{
$rootDimensionSpacePoints = $this->interDimensionalVariationGraph->getRootGeneralizations();
if (empty($rootDimensionSpacePoints)) {
throw new \InvalidArgumentException(
'The dimension space is empty, please check your configuration.',
1651957153
);
}
$arbitraryRootDimensionSpacePoint = array_shift($rootDimensionSpacePoints);
return $arbitraryRootDimensionSpacePoint;
}
Expand Down

0 comments on commit 3febbd6

Please sign in to comment.