diff --git a/Neos.ContentRepository.BehavioralTests/Classes/PhpstanRules/InternalMethodsNotAllowedOutsideContentRepositoryRule.php b/Neos.ContentRepository.BehavioralTests/Classes/PhpstanRules/InternalMethodsNotAllowedOutsideContentRepositoryRule.php index 2450e0bfc3f..6fef56d6578 100644 --- a/Neos.ContentRepository.BehavioralTests/Classes/PhpstanRules/InternalMethodsNotAllowedOutsideContentRepositoryRule.php +++ b/Neos.ContentRepository.BehavioralTests/Classes/PhpstanRules/InternalMethodsNotAllowedOutsideContentRepositoryRule.php @@ -31,19 +31,29 @@ public function processNode(Node $node, Scope $scope): array { assert($node instanceof Node\Expr\CallLike); - if ($scope->getNamespace() && str_starts_with($scope->getNamespace(), 'Neos\ContentRepository\Core')) { - // Core is allowed to call all namespaces - // TODO !!! ONLY FROM WITHIN OWN PACKAGE!!!! + if ($scope->getNamespace() && + ( + str_starts_with($scope->getNamespace(), 'Neos\ContentRepository\Core') + || str_starts_with($scope->getNamespace(), 'Neos\ContentGraph\DoctrineDbalAdapter') + || str_starts_with($scope->getNamespace(), 'Neos\ContentRepository\BehavioralTests') + || str_starts_with($scope->getNamespace(), 'Neos\ContentRepository\Export') + || str_starts_with($scope->getNamespace(), 'Neos\ContentRepository\LegacyNodeMigration') + || str_starts_with($scope->getNamespace(), 'Neos\ContentRepository\StructureAdjustment') + ) + ) { + // todo this rule was intended to enforce the internal annotations from the Neos\ContentRepository\Core from all call sites. + // this is currently not achievable and thus we grant a few packages BUT NOT NEOS.NEOS free access. + // that is a good compromise between having this rule not enabled at all or cluttering everything with a baseline. return []; } if ($node instanceof Node\Expr\MethodCall) { $methodCallTargetClass = $scope->getType($node->var); if ($methodCallTargetClass instanceof ObjectType) { $targetClassName = $methodCallTargetClass->getClassName(); - // TODO: also extend to more packages if ( !str_starts_with($targetClassName, 'Neos\ContentRepository\Core') ) { + // currently only access to methods on the cr core is protected. return []; } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e18a7ab8349..8d8a7f46021 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,75 +1,5 @@ parameters: ignoreErrors: - - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\Projection\\\\ContentGraph\\\\ContentGraphWithRuntimeCaches\\\\InMemoryCache\\:\\:disable\" is called\\.$#" - count: 1 - path: Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjection.php - - - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\Projection\\\\ContentGraph\\\\ContentGraphWithRuntimeCaches\\\\InMemoryCache\\:\\:enable\" is called\\.$#" - count: 1 - path: Neos.ContentGraph.DoctrineDbalAdapter/src/DoctrineDbalContentGraphProjection.php - - - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\EventStore\\\\EventPersister\\:\\:publishEvents\" is called\\.$#" - count: 2 - path: Neos.ContentRepository.BehavioralTests/Classes/Command/PerformanceMeasurementService.php - - - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\Feature\\\\ContentStreamEventStreamName\\:\\:getEventStreamName\" is called\\.$#" - count: 2 - path: Neos.ContentRepository.BehavioralTests/Classes/Command/PerformanceMeasurementService.php - - - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\Feature\\\\WorkspaceEventStreamName\\:\\:getEventStreamName\" is called\\.$#" - count: 1 - path: Neos.ContentRepository.Export/src/ImportService.php - - - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\Feature\\\\ContentStreamEventStreamName\\:\\:getEventStreamName\" is called\\.$#" - count: 1 - path: Neos.ContentRepository.Export/src/Processors/EventExportProcessor.php - - - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\Feature\\\\ContentStreamEventStreamName\\:\\:getEventStreamName\" is called\\.$#" - count: 1 - path: Neos.ContentRepository.Export/src/Processors/EventStoreImportProcessor.php - - - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\Feature\\\\WorkspaceEventStreamName\\:\\:getEventStreamName\" is called\\.$#" - count: 1 - path: Neos.ContentRepository.Export/src/Processors/EventStoreImportProcessor.php - - - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\Infrastructure\\\\Property\\\\PropertyConverter\\:\\:serializePropertyValues\" is called\\.$#" - count: 1 - path: Neos.ContentRepository.LegacyNodeMigration/Classes/NodeDataToEventsProcessor.php - - - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\Feature\\\\ContentStreamEventStreamName\\:\\:getEventStreamName\" is called\\.$#" - count: 2 - path: Neos.ContentRepository.StructureAdjustment/src/Adjustment/DisallowedChildNodeAdjustment.php - - - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\Feature\\\\ContentStreamEventStreamName\\:\\:getEventStreamName\" is called\\.$#" - count: 1 - path: Neos.ContentRepository.StructureAdjustment/src/Adjustment/PropertyAdjustment.php - - - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\Feature\\\\ContentStreamEventStreamName\\:\\:getEventStreamName\" is called\\.$#" - count: 3 - path: Neos.ContentRepository.StructureAdjustment/src/Adjustment/TetheredNodeAdjustments.php - - - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\Feature\\\\ContentStreamEventStreamName\\:\\:getEventStreamName\" is called\\.$#" - count: 1 - path: Neos.ContentRepository.StructureAdjustment/src/Adjustment/UnknownNodeTypeAdjustment.php - - - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\EventStore\\\\EventPersister\\:\\:publishEvents\" is called\\.$#" - count: 1 - path: Neos.ContentRepository.StructureAdjustment/src/StructureAdjustmentService.php - - message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\Projection\\\\Projections\\:\\:getClassNames\" is called\\.$#" count: 1