From 6395dc2d41f370a456ebf747b6b631d6f1691ea8 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:51:32 +0200 Subject: [PATCH 01/11] TASK: Remove NodePolicyService --- .../Controller/BackendServiceController.php | 16 +- Classes/Service/NodePolicyService.php | 189 ------------------ 2 files changed, 14 insertions(+), 191 deletions(-) delete mode 100644 Classes/Service/NodePolicyService.php diff --git a/Classes/Controller/BackendServiceController.php b/Classes/Controller/BackendServiceController.php index f77a2ecec1..c3c18a9d90 100644 --- a/Classes/Controller/BackendServiceController.php +++ b/Classes/Controller/BackendServiceController.php @@ -513,7 +513,13 @@ public function getAdditionalNodeMetadataAction(array $nodes): void }, $node->getOtherNodeVariants())));*/ if (!is_null($node)) { $result[$nodeAddress->serializeForUri()] = [ - 'policy' => $this->nodePolicyService->getNodePolicyInformation($node), + // todo reimplement nodePolicyService + 'policy' => [ + 'disallowedNodeTypes' => [], + 'canRemove' => true, + 'canEdit' => true, + 'disallowedProperties' => [] + ] //'dimensions' => $this->getCurrentDimensionPresetIdentifiersForNode($node), //'otherNodeVariants' => $otherNodeVariants ]; @@ -549,7 +555,13 @@ public function getPolicyInformationAction(array $nodes): void $node = $subgraph->findNodeById($nodeAddress->nodeAggregateId); if (!is_null($node)) { $result[$nodeAddress->serializeForUri()] = [ - 'policy' => $this->nodePolicyService->getNodePolicyInformation($node) + // todo reimplement nodePolicyService + 'policy' => [ + 'disallowedNodeTypes' => [], + 'canRemove' => true, + 'canEdit' => true, + 'disallowedProperties' => [] + ] ]; } } diff --git a/Classes/Service/NodePolicyService.php b/Classes/Service/NodePolicyService.php deleted file mode 100644 index 5f95a48d1d..0000000000 --- a/Classes/Service/NodePolicyService.php +++ /dev/null @@ -1,189 +0,0 @@ - the key is a Privilege class name; - * the value is "true" if privileges are configured for this class name. - * @Flow\CompileStatic - */ - public static function getUsedPrivilegeClassNames(ObjectManagerInterface $objectManager): array - { - /** @var PolicyService $policyService */ - $policyService = $objectManager->get(PolicyService::class); - $usedPrivilegeClassNames = []; - foreach ($policyService->getPrivilegeTargets() as $privilegeTarget) { - $usedPrivilegeClassNames[$privilegeTarget->getPrivilegeClassName()] = true; - foreach (class_parents($privilegeTarget->getPrivilegeClassName()) ?: [] as $parentPrivilege) { - if (is_a($parentPrivilege, PrivilegeInterface::class)) { - /** @var string $parentPrivilege */ - $usedPrivilegeClassNames[$parentPrivilege] = true; - } - } - } - - return $usedPrivilegeClassNames; - } - - /** - * @return array - */ - public function getNodePolicyInformation(Node $node): array - { - return [ - 'disallowedNodeTypes' => $this->getDisallowedNodeTypes($node), - 'canRemove' => $this->canRemoveNode($node), - 'canEdit' => $this->canEditNode($node), - 'disallowedProperties' => $this->getDisallowedProperties($node) - ]; - } - - /** - * @param Node $node - * @return bool - */ - public function isNodeTreePrivilegeGranted(Node $node): bool - { - if (!isset(self::getUsedPrivilegeClassNames($this->objectManager)[NodeTreePrivilege::class])) { - return true; - } - - return $this->privilegeManager->isGranted( - NodeTreePrivilege::class, - new NodePrivilegeSubject($node) - ); - } - - /** - * @param Node $node - * @return array - */ - public function getDisallowedNodeTypes(Node $node): array - { - $disallowedNodeTypes = []; - - if (!isset(self::getUsedPrivilegeClassNames($this->objectManager)[CreateNodePrivilege::class])) { - return $disallowedNodeTypes; - } - - $filter = function ($nodeType) use ($node) { - return !$this->privilegeManager->isGranted( - CreateNodePrivilege::class, - new CreateNodePrivilegeSubject($node, $nodeType) - ); - }; - - $contentRepository = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId); - $disallowedNodeTypeObjects = array_filter($contentRepository->getNodeTypeManager()->getNodeTypes(), $filter); - - $mapper = function ($nodeType) { - return $nodeType->getName(); - }; - - return array_map($mapper, $disallowedNodeTypeObjects); - } - - /** - * @param Node $node - * @return bool - */ - public function canRemoveNode(Node $node): bool - { - $canRemove = true; - if (isset(self::getUsedPrivilegeClassNames($this->objectManager)[RemoveNodePrivilege::class])) { - $canRemove = $this->privilegeManager->isGranted( - RemoveNodePrivilege::class, - new NodePrivilegeSubject($node) - ); - } - - return $canRemove; - } - - /** - * @param Node $node - * @return bool - */ - public function canEditNode(Node $node): bool - { - $canEdit = true; - if (isset(self::getUsedPrivilegeClassNames($this->objectManager)[EditNodePrivilege::class])) { - $canEdit = $this->privilegeManager->isGranted(EditNodePrivilege::class, new NodePrivilegeSubject($node)); - } - - return $canEdit; - } - - /** - * @param Node $node - * @return array - */ - public function getDisallowedProperties(Node $node): array - { - $disallowedProperties = []; - - if (!isset(self::getUsedPrivilegeClassNames($this->objectManager)[EditNodePropertyPrivilege::class])) { - return $disallowedProperties; - } - - $filter = function ($propertyName) use ($node) { - return !$this->privilegeManager->isGranted( - EditNodePropertyPrivilege::class, - new PropertyAwareNodePrivilegeSubject($node, null, $propertyName) - ); - }; - - $disallowedProperties = array_filter(array_keys($this->getNodeType($node)->getProperties()), $filter); - return $disallowedProperties; - } -} From 3642373031bf8c947521bc5537889723962c1482 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:57:09 +0200 Subject: [PATCH 02/11] TASK: Introduce phpstan level 2 --- .../Controller/BackendServiceController.php | 15 ------------- .../Domain/Model/Changes/AbstractCreate.php | 2 +- Classes/Domain/Model/Changes/Property.php | 1 - Classes/Domain/Model/Changes/Remove.php | 1 - .../NeosUiDefaultNodesOperation.php | 3 +-- .../ExceptionHandler/PageExceptionHandler.php | 3 +-- ...ontentDimensionsHelperInternalsFactory.php | 3 ++- Classes/Fusion/Helper/NodeInfoHelper.php | 21 ------------------- .../ChangeCollectionConverter.php | 9 -------- phpstan.neon | 4 ++++ 10 files changed, 9 insertions(+), 53 deletions(-) create mode 100644 phpstan.neon diff --git a/Classes/Controller/BackendServiceController.php b/Classes/Controller/BackendServiceController.php index c3c18a9d90..32f16f0a10 100644 --- a/Classes/Controller/BackendServiceController.php +++ b/Classes/Controller/BackendServiceController.php @@ -50,7 +50,6 @@ use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper; use Neos\Neos\Ui\Fusion\Helper\WorkspaceHelper; use Neos\Neos\Ui\Service\NodeClipboard; -use Neos\Neos\Ui\Service\NodePolicyService; use Neos\Neos\Ui\Service\PublishingService; use Neos\Neos\Ui\TypeConverter\ChangeCollectionConverter; use Neos\Neos\Utility\NodeUriPathSegmentGenerator; @@ -103,12 +102,6 @@ class BackendServiceController extends ActionController */ protected $userService; - /** - * @Flow\Inject - * @var NodePolicyService - */ - protected $nodePolicyService; - /** * @Flow\Inject * @var ChangeCollectionConverter @@ -158,7 +151,6 @@ protected function initializeController(ActionRequest $request, ActionResponse $ /** * Apply a set of changes to the system */ - /** @phpstan-ignore-next-line */ public function changeAction(array $changes): void { $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId; @@ -210,7 +202,6 @@ public function publishAllAction(): void * * @param array $nodeContextPaths */ - /** @phpstan-ignore-next-line */ public function publishAction(array $nodeContextPaths, string $targetWorkspaceName): void { $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId; @@ -269,7 +260,6 @@ public function publishAction(array $nodeContextPaths, string $targetWorkspaceNa * * @param array $nodeContextPaths */ - /** @phpstan-ignore-next-line */ public function discardAction(array $nodeContextPaths): void { $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId; @@ -422,7 +412,6 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, string $d * @throws \Neos\Flow\Property\Exception * @throws \Neos\Flow\Security\Exception */ - /** @phpstan-ignore-next-line */ public function copyNodesAction(array $nodes): void { $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId; @@ -454,7 +443,6 @@ public function clearClipboardAction() * @throws \Neos\Flow\Property\Exception * @throws \Neos\Flow\Security\Exception */ - /** @phpstan-ignore-next-line */ public function cutNodesAction(array $nodes): void { $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId; @@ -490,7 +478,6 @@ public function initializeGetAdditionalNodeMetadataAction(): void /** * Fetches all the node information that can be lazy-loaded */ - /** @phpstan-ignore-next-line */ public function getAdditionalNodeMetadataAction(array $nodes): void { $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId; @@ -574,7 +561,6 @@ public function getPolicyInformationAction(array $nodes): void * * @param array $chain */ - /** @phpstan-ignore-next-line */ public function flowQueryAction(array $chain): string { $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId; @@ -590,7 +576,6 @@ public function flowQueryAction(array $chain): string )); foreach ($chain as $operation) { - // @phpstan-ignore-next-line $flowQuery = call_user_func_array([$flowQuery, $operation['type']], $operation['payload']); } diff --git a/Classes/Domain/Model/Changes/AbstractCreate.php b/Classes/Domain/Model/Changes/AbstractCreate.php index 86aca9dc6a..6ebae28193 100644 --- a/Classes/Domain/Model/Changes/AbstractCreate.php +++ b/Classes/Domain/Model/Changes/AbstractCreate.php @@ -87,7 +87,7 @@ public function getName(): ?string * @param Node $parentNode * @param NodeAggregateId|null $succeedingSiblingNodeAggregateId * @return Node - * @throws InvalidNodeCreationHandlerException|NodeNameIsAlreadyOccupied|NodeException + * @throws InvalidNodeCreationHandlerException|NodeNameIsAlreadyOccupied */ protected function createNode( Node $parentNode, diff --git a/Classes/Domain/Model/Changes/Property.php b/Classes/Domain/Model/Changes/Property.php index 2afbc0687b..6401e3bb28 100644 --- a/Classes/Domain/Model/Changes/Property.php +++ b/Classes/Domain/Model/Changes/Property.php @@ -142,7 +142,6 @@ public function canApply(): bool /** * Applies this change * - * @throws \Neos\ContentRepository\Exception\NodeException * @throws ContentStreamDoesNotExistYet * @throws NodeAggregatesTypeIsAmbiguous * @throws DimensionSpacePointNotFound diff --git a/Classes/Domain/Model/Changes/Remove.php b/Classes/Domain/Model/Changes/Remove.php index ccf87a5c04..e1e9063013 100644 --- a/Classes/Domain/Model/Changes/Remove.php +++ b/Classes/Domain/Model/Changes/Remove.php @@ -52,7 +52,6 @@ public function canApply(): bool * @throws NodeAggregatesTypeIsAmbiguous * @throws ContentStreamDoesNotExistYet * @throws DimensionSpacePointNotFound - * @throws \Neos\ContentRepository\Exception\NodeException */ public function apply(): void { diff --git a/Classes/FlowQueryOperations/NeosUiDefaultNodesOperation.php b/Classes/FlowQueryOperations/NeosUiDefaultNodesOperation.php index 4d80cd82b4..4a2da32809 100644 --- a/Classes/FlowQueryOperations/NeosUiDefaultNodesOperation.php +++ b/Classes/FlowQueryOperations/NeosUiDefaultNodesOperation.php @@ -101,8 +101,7 @@ public function evaluate(FlowQuery $flowQuery, array $arguments) $toggledNodes, $ancestors, $subgraph, - $nodeAddressFactory, - $contentRepository + $nodeAddressFactory ) { $baseNodeAddress = $nodeAddressFactory->createFromNode($baseNode); diff --git a/Classes/Fusion/ExceptionHandler/PageExceptionHandler.php b/Classes/Fusion/ExceptionHandler/PageExceptionHandler.php index 8fdfb46ed7..0f5da7f79d 100644 --- a/Classes/Fusion/ExceptionHandler/PageExceptionHandler.php +++ b/Classes/Fusion/ExceptionHandler/PageExceptionHandler.php @@ -12,7 +12,6 @@ */ use GuzzleHttp\Psr7\Message; -use function GuzzleHttp\Psr7\str; use Neos\Flow\Annotations as Flow; use Neos\Flow\Exception; use Neos\Flow\Mvc\View\ViewInterface; @@ -76,7 +75,7 @@ protected function handle($fusionPath, \Exception $exception, $referenceCode): s /** * Renders an actual HTTP response including the correct status and cache control header. * - * @param \Exception the exception + * @param \Exception $exception the exception * @param string $bodyContent * @return string */ diff --git a/Classes/Fusion/Helper/ContentDimensionsHelperInternalsFactory.php b/Classes/Fusion/Helper/ContentDimensionsHelperInternalsFactory.php index 77993c426e..1bb0c34aae 100644 --- a/Classes/Fusion/Helper/ContentDimensionsHelperInternalsFactory.php +++ b/Classes/Fusion/Helper/ContentDimensionsHelperInternalsFactory.php @@ -18,10 +18,11 @@ /** * @deprecated ugly - we want to get rid of this by adding dimension infos in the Subgraph + * @implements ContentRepositoryServiceFactoryInterface */ class ContentDimensionsHelperInternalsFactory implements ContentRepositoryServiceFactoryInterface { - public function build(ContentRepositoryServiceFactoryDependencies $serviceFactoryDependencies): ContentRepositoryServiceInterface + public function build(ContentRepositoryServiceFactoryDependencies $serviceFactoryDependencies): ContentDimensionsHelperInternals { return new ContentDimensionsHelperInternals($serviceFactoryDependencies->contentDimensionSource); } diff --git a/Classes/Fusion/Helper/NodeInfoHelper.php b/Classes/Fusion/Helper/NodeInfoHelper.php index 62abda3f3c..0f2bd21300 100644 --- a/Classes/Fusion/Helper/NodeInfoHelper.php +++ b/Classes/Fusion/Helper/NodeInfoHelper.php @@ -11,7 +11,6 @@ * source code. */ -use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\CountAncestorNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; @@ -26,10 +25,8 @@ use Neos\Neos\FrontendRouting\NodeAddress; use Neos\Neos\FrontendRouting\NodeAddressFactory; use Neos\Neos\FrontendRouting\NodeUriBuilder; -use Neos\Neos\TypeConverter\EntityToIdentityConverter; use Neos\Neos\Ui\Domain\Service\NodePropertyConverterService; use Neos\Neos\Ui\Domain\Service\UserLocaleService; -use Neos\Neos\Ui\Service\NodePolicyService; use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** @@ -42,24 +39,12 @@ class NodeInfoHelper implements ProtectedContextAwareInterface #[Flow\Inject] protected ContentRepositoryRegistry $contentRepositoryRegistry; - /** - * @Flow\Inject - * @var NodePolicyService - */ - protected $nodePolicyService; - /** * @Flow\Inject * @var UserLocaleService */ protected $userLocaleService; - /** - * @Flow\Inject - * @var EntityToIdentityConverter - */ - protected $entityToIdentityConverter; - /** * @Flow\Inject * @var PersistenceManagerInterface @@ -78,12 +63,6 @@ class NodeInfoHelper implements ProtectedContextAwareInterface */ protected $baseNodeType; - /** - * @Flow\InjectConfiguration(path="userInterface.navigateComponent.nodeTree.loadingDepth", package="Neos.Neos") - * @var string - */ - protected $loadingDepth; - /** * @Flow\InjectConfiguration(path="nodeTypeRoles.document", package="Neos.Neos.Ui") * @var string diff --git a/Classes/TypeConverter/ChangeCollectionConverter.php b/Classes/TypeConverter/ChangeCollectionConverter.php index f6ac74214b..1d1d24f9ce 100644 --- a/Classes/TypeConverter/ChangeCollectionConverter.php +++ b/Classes/TypeConverter/ChangeCollectionConverter.php @@ -96,21 +96,12 @@ class ChangeCollectionConverter * Converts a accordingly formatted, associative array to a change collection * * @param array> $source - * @param string $targetType not used - * @param array $subProperties not used - * @param PropertyMappingConfigurationInterface $configuration not used - * @return ChangeCollection|Error An object or \Neos\Error\Messages\Error if the input format is not supported - * or could not be converted for other reasons * @throws \Exception */ public function convert( array $source, ContentRepositoryId $contentRepositoryId ): ChangeCollection { - if (!is_array($source)) { - throw new \RuntimeException(sprintf('Cannot convert %s to ChangeCollection.', gettype($source))); - } - $changeCollection = new ChangeCollection(); foreach ($source as $changeData) { $convertedData = $this->convertChangeData($changeData, $contentRepositoryId); diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000000..93039f2700 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: 2 + paths: + - Classes From 455fd86bca311550987d04fc099fd9262409846a Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:59:29 +0200 Subject: [PATCH 03/11] TASK: Level up to phpstan 5 --- Classes/Domain/Model/Changes/Remove.php | 2 +- Classes/Fusion/Helper/NodeInfoHelper.php | 2 +- phpstan.neon | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/Domain/Model/Changes/Remove.php b/Classes/Domain/Model/Changes/Remove.php index e1e9063013..e58a98ff76 100644 --- a/Classes/Domain/Model/Changes/Remove.php +++ b/Classes/Domain/Model/Changes/Remove.php @@ -78,7 +78,7 @@ public function apply(): void NodeVariantSelectionStrategy::STRATEGY_ALL_SPECIALIZATIONS, ); if ($closestDocumentParentNode !== null) { - $command = $command->withRemovalAttachmentPoint($closestDocumentParentNode?->nodeAggregateId); + $command = $command->withRemovalAttachmentPoint($closestDocumentParentNode->nodeAggregateId); } $contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId); diff --git a/Classes/Fusion/Helper/NodeInfoHelper.php b/Classes/Fusion/Helper/NodeInfoHelper.php index 0f2bd21300..05b79eb763 100644 --- a/Classes/Fusion/Helper/NodeInfoHelper.php +++ b/Classes/Fusion/Helper/NodeInfoHelper.php @@ -226,7 +226,7 @@ protected function getBasicNodeInformation(Node $node): array 'parent' => $parentNode ? $nodeAddressFactory->createFromNode($parentNode)->serializeForUri() : null, 'matchesCurrentDimensions' => $node->subgraphIdentity->dimensionSpacePoint->equals($node->originDimensionSpacePoint), 'lastModificationDateTime' => $node->timestamps->lastModified?->format(\DateTime::ATOM), - 'creationDateTime' => $node->timestamps->created?->format(\DateTime::ATOM), + 'creationDateTime' => $node->timestamps->created->format(\DateTime::ATOM), 'lastPublicationDateTime' => $node->timestamps->originalLastModified?->format(\DateTime::ATOM) ]; } diff --git a/phpstan.neon b/phpstan.neon index 93039f2700..3abf7a6cac 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: - level: 2 + level: 5 paths: - Classes From 2d1b2b856f6665d50e627648e71928ba15fb0e78 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:04:59 +0200 Subject: [PATCH 04/11] TASK: Run phpstan in ci --- .circleci/config.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index bbcb37a3b9..565b0fde03 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -140,6 +140,20 @@ jobs: cd /home/circleci/app/ bin/phpunit -c Build/BuildEssentials/PhpUnit/UnitTests.xml Packages/Application/Neos.Neos.Ui/Tests/Unit + php-linting: + docker: + - image: cimg/php:8.2-node + working_directory: *workspace_root + steps: + - attach_workspace: *attach_workspace + - restore_cache: *restore_app_cache + + - run: rm -rf /home/circleci/app/Packages/Application/Neos.Neos.Ui + - run: cd /home/circleci/app/Packages/Application && mv ~/neos-ui-workspace Neos.Neos.Ui + - run: | + cd /home/circleci/app/Packages/Application/Neos.Neos.Ui/Tests/Unit + ../../../bin/phpstan analyse + workflows: version: 2 build_and_test: From ad5890212aa7960c159b6bc937f8ea79b50f1441 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:33:03 +0200 Subject: [PATCH 05/11] TASK: Add array types (phpstan level 6) --- .../Service/WorkspaceService.php | 1 + Classes/Controller/BackendServiceController.php | 14 +++++++------- Classes/Domain/Model/AbstractFeedback.php | 3 ++- .../Model/Feedback/Operations/Redirect.php | 4 ++-- .../Operations/ReloadContentOutOfBand.php | 2 +- .../Operations/UpdateNodePreviewUrl.php | 4 ++-- Classes/Domain/Model/FeedbackCollection.php | 4 ++-- Classes/Domain/Model/FeedbackInterface.php | 4 ++-- Classes/Domain/Model/RenderedNodeDomAddress.php | 5 ++--- .../Service/ConfigurationRenderingService.php | 16 ++++++++-------- .../StyleAndJavascriptInclusionService.php | 17 ++++++++++------- Classes/Domain/Service/UserLocaleService.php | 4 ++-- Classes/Fusion/Helper/ApiHelper.php | 7 +++---- .../Fusion/Helper/ContentDimensionsHelper.php | 1 + .../Helper/PositionalArraySorterHelper.php | 6 +++--- Classes/Fusion/Helper/StaticResourcesHelper.php | 2 +- Classes/Fusion/Helper/WorkspaceHelper.php | 5 ++++- .../RenderConfigurationImplementation.php | 6 +++--- phpstan.neon | 2 +- 19 files changed, 57 insertions(+), 50 deletions(-) diff --git a/Classes/ContentRepository/Service/WorkspaceService.php b/Classes/ContentRepository/Service/WorkspaceService.php index 8e05538eae..e717383043 100644 --- a/Classes/ContentRepository/Service/WorkspaceService.php +++ b/Classes/ContentRepository/Service/WorkspaceService.php @@ -157,6 +157,7 @@ public function getAllowedTargetWorkspaces(ContentRepository $contentRepository) return $workspacesArray; } + /** @return list */ public function predictRemoveNodeFeedbackFromDiscardIndividualNodesFromWorkspaceCommand( DiscardIndividualNodesFromWorkspace $command, ContentRepository $contentRepository diff --git a/Classes/Controller/BackendServiceController.php b/Classes/Controller/BackendServiceController.php index 32f16f0a10..7d9dc91ef1 100644 --- a/Classes/Controller/BackendServiceController.php +++ b/Classes/Controller/BackendServiceController.php @@ -150,14 +150,13 @@ protected function initializeController(ActionRequest $request, ActionResponse $ /** * Apply a set of changes to the system + * @param array> $changes */ public function changeAction(array $changes): void { $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryId; - /** @param array> $changes */ $changes = $this->changeCollectionConverter->convert($changes, $contentRepositoryId); - /** @var ChangeCollection $changes */ try { $count = $changes->count(); $changes->apply(); @@ -200,7 +199,7 @@ public function publishAllAction(): void /** * Publish nodes * - * @param array $nodeContextPaths + * @param list $nodeContextPaths */ public function publishAction(array $nodeContextPaths, string $targetWorkspaceName): void { @@ -258,7 +257,7 @@ public function publishAction(array $nodeContextPaths, string $targetWorkspaceNa /** * Discard nodes * - * @param array $nodeContextPaths + * @param list $nodeContextPaths */ public function discardAction(array $nodeContextPaths): void { @@ -407,7 +406,7 @@ public function changeBaseWorkspaceAction(string $targetWorkspaceName, string $d /** * Persists the clipboard node on copy * - * @param array $nodes + * @param list $nodes * @return void * @throws \Neos\Flow\Property\Exception * @throws \Neos\Flow\Security\Exception @@ -439,7 +438,7 @@ public function clearClipboardAction() /** * Persists the clipboard node on cut * - * @param array $nodes + * @param list $nodes * @throws \Neos\Flow\Property\Exception * @throws \Neos\Flow\Security\Exception */ @@ -477,6 +476,7 @@ public function initializeGetAdditionalNodeMetadataAction(): void /** * Fetches all the node information that can be lazy-loaded + * @param list $nodes */ public function getAdditionalNodeMetadataAction(array $nodes): void { @@ -559,7 +559,7 @@ public function getPolicyInformationAction(array $nodes): void /** * Build and execute a flow query chain * - * @param array $chain + * @param array $chain */ public function flowQueryAction(array $chain): string { diff --git a/Classes/Domain/Model/AbstractFeedback.php b/Classes/Domain/Model/AbstractFeedback.php index 5a4ca35ae1..e852cd7c60 100644 --- a/Classes/Domain/Model/AbstractFeedback.php +++ b/Classes/Domain/Model/AbstractFeedback.php @@ -16,7 +16,8 @@ abstract class AbstractFeedback implements FeedbackInterface { - public function serialize(ControllerContext $controllerContext) + /** @return array */ + public function serialize(ControllerContext $controllerContext): array { return [ 'type' => $this->getType(), diff --git a/Classes/Domain/Model/Feedback/Operations/Redirect.php b/Classes/Domain/Model/Feedback/Operations/Redirect.php index 8020b73dab..e5d271dc88 100644 --- a/Classes/Domain/Model/Feedback/Operations/Redirect.php +++ b/Classes/Domain/Model/Feedback/Operations/Redirect.php @@ -89,9 +89,9 @@ public function isSimilarTo(FeedbackInterface $feedback) * Serialize the payload for this feedback * * @param ControllerContext $controllerContext - * @return array + * @return array */ - public function serializePayload(ControllerContext $controllerContext) + public function serializePayload(ControllerContext $controllerContext): array { $node = $this->getNode(); $redirectUri = $this->linkingService->createNodeUri($controllerContext, $node, null, null, true); diff --git a/Classes/Domain/Model/Feedback/Operations/ReloadContentOutOfBand.php b/Classes/Domain/Model/Feedback/Operations/ReloadContentOutOfBand.php index 07a6108a3f..fc511798de 100644 --- a/Classes/Domain/Model/Feedback/Operations/ReloadContentOutOfBand.php +++ b/Classes/Domain/Model/Feedback/Operations/ReloadContentOutOfBand.php @@ -154,7 +154,7 @@ protected function renderContent(ControllerContext $controllerContext): string|R /** * @return array */ - public function serialize(ControllerContext $controllerContext) + public function serialize(ControllerContext $controllerContext): array { try { return parent::serialize($controllerContext); diff --git a/Classes/Domain/Model/Feedback/Operations/UpdateNodePreviewUrl.php b/Classes/Domain/Model/Feedback/Operations/UpdateNodePreviewUrl.php index a0d122c2e3..5ef0b821f3 100644 --- a/Classes/Domain/Model/Feedback/Operations/UpdateNodePreviewUrl.php +++ b/Classes/Domain/Model/Feedback/Operations/UpdateNodePreviewUrl.php @@ -92,9 +92,9 @@ public function isSimilarTo(FeedbackInterface $feedback) * Serialize the payload for this feedback * * @param ControllerContext $controllerContext - * @return array + * @return array */ - public function serializePayload(ControllerContext $controllerContext) + public function serializePayload(ControllerContext $controllerContext): array { if ($this->node === null) { $newPreviewUrl = ''; diff --git a/Classes/Domain/Model/FeedbackCollection.php b/Classes/Domain/Model/FeedbackCollection.php index 511289c083..0857f1adbe 100644 --- a/Classes/Domain/Model/FeedbackCollection.php +++ b/Classes/Domain/Model/FeedbackCollection.php @@ -60,7 +60,7 @@ public function add(FeedbackInterface $feedback) /** * Serialize collection to `json_encode`able array * - * @return array + * @return array */ public function jsonSerialize(): array { @@ -76,7 +76,7 @@ public function jsonSerialize(): array ]; } - public function reset() + public function reset(): void { $this->feedbacks = []; } diff --git a/Classes/Domain/Model/FeedbackInterface.php b/Classes/Domain/Model/FeedbackInterface.php index 4ca4bd4f97..6eb7af63b7 100644 --- a/Classes/Domain/Model/FeedbackInterface.php +++ b/Classes/Domain/Model/FeedbackInterface.php @@ -20,9 +20,9 @@ interface FeedbackInterface * in AbstractFeedback, but can be overridden to implement fallback logic in case of errors. * * @param ControllerContext $controllerContext - * @return array + * @return array */ - public function serialize(ControllerContext $controllerContext); + public function serialize(ControllerContext $controllerContext): array; /** * Get the type identifier diff --git a/Classes/Domain/Model/RenderedNodeDomAddress.php b/Classes/Domain/Model/RenderedNodeDomAddress.php index 95264deaaf..249ce70e1e 100644 --- a/Classes/Domain/Model/RenderedNodeDomAddress.php +++ b/Classes/Domain/Model/RenderedNodeDomAddress.php @@ -95,10 +95,9 @@ public function getFusionPathForContentRendering(): string /** * Serialize to json * - * @return array + * @return array */ - #[\ReturnTypeWillChange] - public function jsonSerialize(): mixed + public function jsonSerialize(): array { return [ 'contextPath' => $this->getContextPath(), diff --git a/Classes/Domain/Service/ConfigurationRenderingService.php b/Classes/Domain/Service/ConfigurationRenderingService.php index 1c9c75c31b..577934152d 100644 --- a/Classes/Domain/Service/ConfigurationRenderingService.php +++ b/Classes/Domain/Service/ConfigurationRenderingService.php @@ -28,20 +28,20 @@ class ConfigurationRenderingService /** * @Flow\InjectConfiguration(package="Neos.Fusion", path="defaultContext") - * @var array + * @var array */ protected $fusionDefaultEelContext; /** * @Flow\InjectConfiguration(path="configurationDefaultEelContext") - * @var array + * @var array */ protected $additionalEelDefaultContext; /** - * @param array $configuration - * @param array $context - * @return array + * @param array $configuration + * @param array $context + * @return array * @throws \Neos\Eel\Exception */ public function computeConfiguration(array $configuration, array $context): array @@ -53,11 +53,11 @@ public function computeConfiguration(array $configuration, array $context): arra } /** - * @param array $adjustedConfiguration - * @param array $context + * @param array $adjustedConfiguration + * @param array $context * @throws \Neos\Eel\Exception */ - protected function computeConfigurationInternally(array &$adjustedConfiguration, array $context) + protected function computeConfigurationInternally(array &$adjustedConfiguration, array $context): void { foreach ($adjustedConfiguration as $key => &$value) { if (is_array($value)) { diff --git a/Classes/Domain/Service/StyleAndJavascriptInclusionService.php b/Classes/Domain/Service/StyleAndJavascriptInclusionService.php index afaf8e5ba9..28a095b080 100644 --- a/Classes/Domain/Service/StyleAndJavascriptInclusionService.php +++ b/Classes/Domain/Service/StyleAndJavascriptInclusionService.php @@ -36,43 +36,46 @@ class StyleAndJavascriptInclusionService /** * @Flow\InjectConfiguration(package="Neos.Fusion", path="defaultContext") - * @var array + * @var array */ protected $fusionDefaultEelContext; /** * @Flow\InjectConfiguration(path="configurationDefaultEelContext") - * @var array + * @var array */ protected $additionalEelDefaultContext; /** * @Flow\InjectConfiguration(path="resources.javascript") - * @var array + * @var array, position: string}> */ protected $javascriptResources; /** * @Flow\InjectConfiguration(path="resources.stylesheets") - * @var array + * @var array, position: string}> */ protected $stylesheetResources; - public function getHeadScripts() + public function getHeadScripts(): string { return $this->build($this->javascriptResources, function ($uri, $additionalAttributes) { return ''; }); } - public function getHeadStylesheets() + public function getHeadStylesheets(): string { return $this->build($this->stylesheetResources, function ($uri, $additionalAttributes) { return ''; }); } - protected function build(array $resourceArrayToSort, \Closure $builderForLine) + /** + * @param array}> $resourceArrayToSort + */ + protected function build(array $resourceArrayToSort, \Closure $builderForLine): string { $sortedResources = (new PositionalArraySorter($resourceArrayToSort))->toArray(); diff --git a/Classes/Domain/Service/UserLocaleService.php b/Classes/Domain/Service/UserLocaleService.php index b7dc351b24..aaafb2d721 100644 --- a/Classes/Domain/Service/UserLocaleService.php +++ b/Classes/Domain/Service/UserLocaleService.php @@ -40,9 +40,9 @@ class UserLocaleService /** * For serialization, we need to respect the UI locale, rather than the content locale * - * @param boolean $reset Reset to remebered locale + * @param boolean $reset Reset to remembered locale */ - public function switchToUILocale($reset = false) + public function switchToUILocale($reset = false): void { if ($reset === true) { // Reset the locale diff --git a/Classes/Fusion/Helper/ApiHelper.php b/Classes/Fusion/Helper/ApiHelper.php index 4f51751f9e..e53289a259 100644 --- a/Classes/Fusion/Helper/ApiHelper.php +++ b/Classes/Fusion/Helper/ApiHelper.php @@ -20,12 +20,11 @@ class ApiHelper implements ProtectedContextAwareInterface * * Use this helper to prevent associative arrays from being converted to non-associative arrays by json_encode. * This is an internal helper and might change without further notice - * FIXME: Probably better to produce objects in the first place "upstream". * - * @param array $array Associative array which may be empty - * @return array|\stdClass Non-empty associative array or empty object + * @param array $array Associative array which may be empty + * @return array|\stdClass Non-empty associative array or empty object */ - public function emptyArrayToObject(array $array) + public function emptyArrayToObject(array $array): array|object { return $array === [] ? new \stdClass() : $array; } diff --git a/Classes/Fusion/Helper/ContentDimensionsHelper.php b/Classes/Fusion/Helper/ContentDimensionsHelper.php index 7008f58a68..ff2226a185 100644 --- a/Classes/Fusion/Helper/ContentDimensionsHelper.php +++ b/Classes/Fusion/Helper/ContentDimensionsHelper.php @@ -88,6 +88,7 @@ public function allowedPresetsByName(DimensionSpacePoint $dimensions, ContentRep return $allowedPresets; } + /** @return array> */ public function dimensionSpacePointArray(AbstractDimensionSpacePoint $dimensionSpacePoint): array { return $dimensionSpacePoint->toLegacyDimensionArray(); diff --git a/Classes/Fusion/Helper/PositionalArraySorterHelper.php b/Classes/Fusion/Helper/PositionalArraySorterHelper.php index d3aab671b2..5cb7bc44b4 100644 --- a/Classes/Fusion/Helper/PositionalArraySorterHelper.php +++ b/Classes/Fusion/Helper/PositionalArraySorterHelper.php @@ -17,11 +17,11 @@ class PositionalArraySorterHelper implements ProtectedContextAwareInterface { /** - * @param array $array + * @param array $array * @param string $positionPath - * @return array + * @return array */ - public function sort($array, $positionPath = 'position') + public function sort(array $array, string $positionPath = 'position'): array { return (new PositionalArraySorter($array, $positionPath))->toArray(); } diff --git a/Classes/Fusion/Helper/StaticResourcesHelper.php b/Classes/Fusion/Helper/StaticResourcesHelper.php index 2eb9cc9927..1e0b595bd3 100644 --- a/Classes/Fusion/Helper/StaticResourcesHelper.php +++ b/Classes/Fusion/Helper/StaticResourcesHelper.php @@ -22,7 +22,7 @@ class StaticResourcesHelper implements ProtectedContextAwareInterface */ protected $frontendDevelopmentMode; - public function compiledResourcePackage() + public function compiledResourcePackage(): string { if ($this->frontendDevelopmentMode) { return 'Neos.Neos.Ui'; diff --git a/Classes/Fusion/Helper/WorkspaceHelper.php b/Classes/Fusion/Helper/WorkspaceHelper.php index 79903349ac..7d3c8c14b3 100644 --- a/Classes/Fusion/Helper/WorkspaceHelper.php +++ b/Classes/Fusion/Helper/WorkspaceHelper.php @@ -49,7 +49,10 @@ class WorkspaceHelper implements ProtectedContextAwareInterface */ protected $securityContext; - public function getAllowedTargetWorkspaces(ContentRepositoryId $contentRepositoryId) + /** + * @return array> + */ + public function getAllowedTargetWorkspaces(ContentRepositoryId $contentRepositoryId): array { $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); return $this->workspaceService->getAllowedTargetWorkspaces($contentRepository); diff --git a/Classes/Fusion/RenderConfigurationImplementation.php b/Classes/Fusion/RenderConfigurationImplementation.php index 152d82093b..96b085b7f0 100644 --- a/Classes/Fusion/RenderConfigurationImplementation.php +++ b/Classes/Fusion/RenderConfigurationImplementation.php @@ -26,12 +26,12 @@ class RenderConfigurationImplementation extends AbstractFusionObject /** * @Flow\InjectConfiguration() - * @var array + * @var array */ protected $settings; /** - * @return array + * @return array */ protected function getContext(): array { @@ -49,7 +49,7 @@ protected function getPath(): string /** * Appends an item to the given collection * - * @return array + * @return array * @throws Exception */ public function evaluate() diff --git a/phpstan.neon b/phpstan.neon index 3abf7a6cac..302c9f028f 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: - level: 5 + level: 6 paths: - Classes From 5a6602671beb532ee4957ef7d7bacf69f8c2d21a Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:33:22 +0200 Subject: [PATCH 06/11] TASK: Remove legacy UiDependentImageSerializer --- .../UiDependentImageSerializer.php | 45 ------------------- Configuration/Settings.yaml | 2 +- 2 files changed, 1 insertion(+), 46 deletions(-) delete mode 100644 Classes/TypeConverter/UiDependentImageSerializer.php diff --git a/Classes/TypeConverter/UiDependentImageSerializer.php b/Classes/TypeConverter/UiDependentImageSerializer.php deleted file mode 100644 index 39f6456aec..0000000000 --- a/Classes/TypeConverter/UiDependentImageSerializer.php +++ /dev/null @@ -1,45 +0,0 @@ -objectManager->get(ImageInterfaceArrayPresenter::class); - return $innerConverter->convertFrom($source, $targetType, $convertedChildProperties, $configuration); - } -} diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index 7e7ee51eaf..92de6e127f 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -20,7 +20,7 @@ Neos: inspector: dataTypes: Neos\Media\Domain\Model\ImageInterface: - typeConverter: Neos\Neos\Ui\TypeConverter\UiDependentImageSerializer + typeConverter: Neos\Media\TypeConverter\ImageInterfaceArrayPresenter translation: autoInclude: 'Neos.Neos.Ui': From afb3460bd1be1fb1dc1f5e123659db3f80ef8676 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:46:04 +0200 Subject: [PATCH 07/11] TASK: Fix phpstan level 6 --- Classes/Service/NodePropertyValidationService.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Classes/Service/NodePropertyValidationService.php b/Classes/Service/NodePropertyValidationService.php index 552fbd20f3..228e00bb88 100644 --- a/Classes/Service/NodePropertyValidationService.php +++ b/Classes/Service/NodePropertyValidationService.php @@ -38,12 +38,11 @@ class NodePropertyValidationService protected $dateTimeConverter; /** - * @param $value * @param string $validatorName - * @param array $validatorConfiguration + * @param array $validatorConfiguration * @return bool */ - public function validate($value, string $validatorName, array $validatorConfiguration): bool + public function validate(mixed $value, string $validatorName, array $validatorConfiguration): bool { $validator = $this->resolveValidator($validatorName, $validatorConfiguration); @@ -70,7 +69,7 @@ public function validate($value, string $validatorName, array $validatorConfigur /** * @param string $validatorName - * @param array $validatorConfiguration + * @param array $validatorConfiguration * @return ValidatorInterface|null */ protected function resolveValidator(string $validatorName, array $validatorConfiguration) @@ -88,6 +87,8 @@ protected function resolveValidator(string $validatorName, array $validatorConfi return null; } - return new $fullQualifiedValidatorClassName($validatorConfiguration); + /** @var ValidatorInterface $validator */ + $validator = new $fullQualifiedValidatorClassName($validatorConfiguration); + return $validator; } } From ef2172f53dffe51a9797411d942f4fcccd6b7680 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:47:18 +0200 Subject: [PATCH 08/11] TASK: Fix phpstan ci --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 565b0fde03..f57d0a5c8e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -175,3 +175,6 @@ workflows: - php-unittests: requires: - build_flow_app + - php-linting: + requires: + - build_flow_app From fc1b95830e94be34c006f19665b76ae7e1022a6f Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 19 Oct 2023 13:03:03 +0200 Subject: [PATCH 09/11] TASK: Level up - pling kling kling 7 :D --- Classes/Controller/BackendServiceController.php | 10 ++++++---- .../Service/StyleAndJavascriptInclusionService.php | 2 +- .../Fusion/ExceptionHandler/PageExceptionHandler.php | 1 + phpstan.neon | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Classes/Controller/BackendServiceController.php b/Classes/Controller/BackendServiceController.php index 7d9dc91ef1..afc3205d06 100644 --- a/Classes/Controller/BackendServiceController.php +++ b/Classes/Controller/BackendServiceController.php @@ -24,6 +24,7 @@ use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Eel\FlowQuery\FlowQuery; +use Neos\Eel\FlowQuery\Operations\GetOperation; use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\ActionRequest; use Neos\Flow\Mvc\ActionResponse; @@ -39,7 +40,6 @@ use Neos\Neos\Service\UserService; use Neos\Neos\Ui\ContentRepository\Service\NeosUiNodeService; use Neos\Neos\Ui\ContentRepository\Service\WorkspaceService; -use Neos\Neos\Ui\Domain\Model\ChangeCollection; use Neos\Neos\Ui\Domain\Model\Feedback\Messages\Error; use Neos\Neos\Ui\Domain\Model\Feedback\Messages\Info; use Neos\Neos\Ui\Domain\Model\Feedback\Messages\Success; @@ -559,7 +559,7 @@ public function getPolicyInformationAction(array $nodes): void /** * Build and execute a flow query chain * - * @param array $chain + * @param list}> $chain */ public function flowQueryAction(array $chain): string { @@ -568,7 +568,6 @@ public function flowQueryAction(array $chain): string $createContext = array_shift($chain); $finisher = array_pop($chain); - /** @var array $payload */ $payload = $createContext['payload'] ?? []; $flowQuery = new FlowQuery(array_map( fn ($envelope) => $this->nodeService->findNodeBySerializedNodeAddress($envelope['$node'], $contentRepositoryId), @@ -576,9 +575,12 @@ public function flowQueryAction(array $chain): string )); foreach ($chain as $operation) { - $flowQuery = call_user_func_array([$flowQuery, $operation['type']], $operation['payload']); + $flowQuery = $flowQuery->__call($operation['type'], $operation['payload']); } + /** @see GetOperation */ + assert(is_callable([$flowQuery, 'get'])); + $nodeInfoHelper = new NodeInfoHelper(); $type = $finisher['type'] ?? null; $result = match ($type) { diff --git a/Classes/Domain/Service/StyleAndJavascriptInclusionService.php b/Classes/Domain/Service/StyleAndJavascriptInclusionService.php index 28a095b080..429acb92aa 100644 --- a/Classes/Domain/Service/StyleAndJavascriptInclusionService.php +++ b/Classes/Domain/Service/StyleAndJavascriptInclusionService.php @@ -95,7 +95,7 @@ protected function build(array $resourceArrayToSort, \Closure $builderForLine): if (strpos($resourceExpression, 'resource://') === 0) { // Cache breaker - $hash = substr(md5_file($resourceExpression), 0, 8); + $hash = substr(md5_file($resourceExpression) ?: '', 0, 8); $resourceExpression = $this->resourceManager->getPublicPackageResourceUriByPath($resourceExpression); } $finalUri = $hash ? $resourceExpression . '?' . $hash : $resourceExpression; diff --git a/Classes/Fusion/ExceptionHandler/PageExceptionHandler.php b/Classes/Fusion/ExceptionHandler/PageExceptionHandler.php index 0f5da7f79d..3ac58869a0 100644 --- a/Classes/Fusion/ExceptionHandler/PageExceptionHandler.php +++ b/Classes/Fusion/ExceptionHandler/PageExceptionHandler.php @@ -69,6 +69,7 @@ protected function handle($fusionPath, \Exception $exception, $referenceCode): s 'message' => $output ]); + // @phpstan-ignore-next-line return $this->wrapHttpResponse($exception, $fluidView->render()); } diff --git a/phpstan.neon b/phpstan.neon index 302c9f028f..90b4b0c2db 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: - level: 6 + level: 7 paths: - Classes From 140346b1c3b0c9523aa577858438b4c28d5bf92b Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 19 Oct 2023 13:05:56 +0200 Subject: [PATCH 10/11] TASK: Add phpstan to ci via composer --- Tests/IntegrationTests/TestDistribution/composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/IntegrationTests/TestDistribution/composer.json b/Tests/IntegrationTests/TestDistribution/composer.json index 20704ec76d..a83a30f06b 100644 --- a/Tests/IntegrationTests/TestDistribution/composer.json +++ b/Tests/IntegrationTests/TestDistribution/composer.json @@ -1,4 +1,3 @@ - { "name": "neos/test-distribution", "description": "Neos test distribution. Change this number if you need to break CircleCI's cache: 14", @@ -28,7 +27,8 @@ }, "require-dev": { "neos/buildessentials": "@dev", - "phpunit/phpunit": "^9.0" + "phpunit/phpunit": "^9.0", + "phpstan/phpstan": "^1.10" }, "extra": { "patches": { From 3055ab83671d9011a83cd5f1ce8f8751eaf6887a Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 19 Oct 2023 22:33:06 +0200 Subject: [PATCH 11/11] TASK: Fix types --- Classes/ContentRepository/Service/WorkspaceService.php | 4 +--- Classes/Domain/Model/Changes/AbstractStructuralChange.php | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Classes/ContentRepository/Service/WorkspaceService.php b/Classes/ContentRepository/Service/WorkspaceService.php index e717383043..86e6bc4f52 100644 --- a/Classes/ContentRepository/Service/WorkspaceService.php +++ b/Classes/ContentRepository/Service/WorkspaceService.php @@ -16,7 +16,6 @@ use Neos\ContentRepository\Core\Feature\WorkspacePublication\Command\DiscardIndividualNodesFromWorkspace; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindClosestNodeFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepository\Core\Projection\Workspace\Workspace; use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\FrontendRouting\NodeAddress; use Neos\Neos\FrontendRouting\NodeAddressFactory; @@ -128,7 +127,6 @@ public function getAllowedTargetWorkspaces(ContentRepository $contentRepository) $user = $this->domainUserService->getCurrentUser(); $workspacesArray = []; - /** @var Workspace $workspace */ foreach ($contentRepository->getWorkspaceFinder()->findAll() as $workspace) { // FIXME: This check should be implemented through a specialized Workspace Privilege or something similar // Skip workspace not owned by current user @@ -193,7 +191,7 @@ public function predictRemoveNodeFeedbackFromDiscardIndividualNodesFromWorkspace $childNode = $subgraph->findNodeById($nodeToDiscard->nodeAggregateId); $parentNode = $subgraph->findParentNode($nodeToDiscard->nodeAggregateId); - if ($parentNode) { + if ($childNode && $parentNode) { $result[] = new RemoveNode($childNode, $parentNode); $handledNodes[] = $nodeToDiscard; } diff --git a/Classes/Domain/Model/Changes/AbstractStructuralChange.php b/Classes/Domain/Model/Changes/AbstractStructuralChange.php index cf44178df0..f49e22baa5 100644 --- a/Classes/Domain/Model/Changes/AbstractStructuralChange.php +++ b/Classes/Domain/Model/Changes/AbstractStructuralChange.php @@ -106,7 +106,7 @@ public function getSiblingDomAddress(): ?RenderedNodeDomAddress */ public function getSiblingNode(): ?Node { - if ($this->siblingDomAddress === null) { + if ($this->siblingDomAddress === null || !$this->getSubject()) { return null; } @@ -152,7 +152,7 @@ protected function finish(Node $node) // 1) the parent of our new (or copied or moved) node is a ContentCollection; // so we can directly update an element of this content collection - $contentRepository = $this->contentRepositoryRegistry->get($parentNode->subgraphIdentity->contentRepositoryId); + $contentRepository = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId); if ($parentNode && $this->getNodeType($parentNode)->isOfType('Neos.Neos:ContentCollection') && // 2) the parent DOM address (i.e. the closest RENDERED node in DOM is actually the ContentCollection; // and no other node in between