Skip to content

Commit

Permalink
TASK: Fix phpstan
Browse files Browse the repository at this point in the history
Using the rule was originally reintroduces via `InternalMethodsNotAllowedOutsideContentRepositoryRule` #4703

But the baseline is too cluttered because of that.
  • Loading branch information
mhsdesign committed Feb 10, 2024
1 parent f8a42d0 commit d39df08
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
}

Expand Down
70 changes: 0 additions & 70 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit d39df08

Please sign in to comment.