diff --git a/Neos.ContentRepository.LegacyNodeMigration/Classes/Command/CrCommandController.php b/Neos.ContentRepository.LegacyNodeMigration/Classes/Command/CrCommandController.php index b3b7e1a11d6..6f6fe55ff91 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Classes/Command/CrCommandController.php +++ b/Neos.ContentRepository.LegacyNodeMigration/Classes/Command/CrCommandController.php @@ -202,7 +202,6 @@ private function determineResourcesPath(): string private static function defaultResourcesPath(): string { - // @phpstan-ignore-next-line return FLOW_PATH_DATA . 'Persistent/Resources'; } } diff --git a/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/FilterOperation.php b/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/FilterOperation.php index ea212ea5182..040dc4703cb 100644 --- a/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/FilterOperation.php +++ b/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/FilterOperation.php @@ -141,7 +141,6 @@ protected function evaluateOperator($value, $operator, $operand) { if ($operator === 'instanceof' && $value instanceof Node) { if ($this->operandIsSimpleType($operand)) { - /** @phpstan-ignore-next-line Flow does not properly declare its types here */ return $this->handleSimpleTypeOperand($operand, $value); } elseif ($operand === Node::class) { return true; diff --git a/Neos.ContentRepositoryRegistry/Classes/Command/NodeTypesCommandController.php b/Neos.ContentRepositoryRegistry/Classes/Command/NodeTypesCommandController.php index 9dd7ba7433d..2a77e6c7fe1 100644 --- a/Neos.ContentRepositoryRegistry/Classes/Command/NodeTypesCommandController.php +++ b/Neos.ContentRepositoryRegistry/Classes/Command/NodeTypesCommandController.php @@ -100,8 +100,10 @@ public function listCommand(?string $filter = null, bool $includeAbstract = true } /** + * @param array $array * @param int $truncateLevel 0 for no truncation and 1 to only show the first keys of the array * @param int $currentLevel 1 for the start and will be incremented recursively + * @return array */ private static function truncateArrayAtLevel(array $array, int $truncateLevel, int $currentLevel = 1): array { diff --git a/Neos.ContentRepositoryRegistry/Classes/Configuration/NodeTypesLoader.php b/Neos.ContentRepositoryRegistry/Classes/Configuration/NodeTypesLoader.php index d19628fcdf4..b8635bf5dfa 100644 --- a/Neos.ContentRepositoryRegistry/Classes/Configuration/NodeTypesLoader.php +++ b/Neos.ContentRepositoryRegistry/Classes/Configuration/NodeTypesLoader.php @@ -24,7 +24,6 @@ class NodeTypesLoader implements LoaderInterface */ private $configurationBasePath; - /** @phpstan-ignore-next-line FLOW_PATH_CONFIGURATION not found */ public function __construct(YamlSource $yamlSource, string $configurationBasePath = FLOW_PATH_CONFIGURATION, protected readonly ?Bootstrap $bootstrap = null) { $this->yamlSource = $yamlSource; diff --git a/Neos.ContentRepositoryRegistry/Classes/Package.php b/Neos.ContentRepositoryRegistry/Classes/Package.php index c51e1712ce7..acd45ae3bcd 100644 --- a/Neos.ContentRepositoryRegistry/Classes/Package.php +++ b/Neos.ContentRepositoryRegistry/Classes/Package.php @@ -38,7 +38,6 @@ public function boot(Bootstrap $bootstrap) $dispatcher = $bootstrap->getSignalSlotDispatcher(); $dispatcher->connect(ConfigurationManager::class, 'configurationManagerReady', function (ConfigurationManager $configurationManager) use ($bootstrap) { - /** @phpstan-ignore-next-line FLOW_* */ $configurationManager->registerConfigurationType('NodeTypes', new NodeTypesLoader(new YamlSource(), FLOW_PATH_CONFIGURATION, $bootstrap)); }); @@ -64,7 +63,6 @@ public function boot(Bootstrap $bootstrap) } } - /** @phpstan-ignore-next-line FLOW_* */ $nodeTypeConfigurationFileMonitor->monitorDirectory(FLOW_PATH_CONFIGURATION, 'NodeTypes(\..+)\.yaml'); $nodeTypeConfigurationFileMonitor->detectChanges(); diff --git a/Neos.Neos/Classes/Controller/LoginController.php b/Neos.Neos/Classes/Controller/LoginController.php index c7601c8b540..6fa34f50d47 100644 --- a/Neos.Neos/Classes/Controller/LoginController.php +++ b/Neos.Neos/Classes/Controller/LoginController.php @@ -164,16 +164,15 @@ public function tokenLoginAction(string $token): void if ($newSessionId === false) { $this->logger->warning(sprintf('Token-based login failed, non-existing or expired token %s', $token)); $this->redirect('index'); - return; } $this->logger->debug(sprintf('Token-based login succeeded, token %s', $token)); $newSession = $this->sessionManager->getSession($newSessionId); - if ($newSession->canBeResumed()) { + if ($newSession?->canBeResumed()) { $newSession->resume(); } - if (!$newSession->isStarted()) { + if (!$newSession?->isStarted()) { $this->logger->error(sprintf( 'Failed resuming or starting session %s which was referred to in the login token %s.', $newSessionId, @@ -211,13 +210,11 @@ protected function onAuthenticationFailure(AuthenticationRequiredException $exce * * @param ActionRequest|null $originalRequest The request that was intercepted by the security framework, * NULL if there was none - * @phpstan-ignore-next-line Flow does not properly declare its return type here - * @return void * @throws SessionNotStartedException * @throws StopActionException * @throws \Neos\Flow\Mvc\Exception\NoSuchArgumentException */ - protected function onAuthenticationSuccess(ActionRequest $originalRequest = null): void + protected function onAuthenticationSuccess(ActionRequest $originalRequest = null): null { if ($this->view instanceof JsonView) { $this->view->assign( @@ -227,6 +224,7 @@ protected function onAuthenticationSuccess(ActionRequest $originalRequest = null 'csrfToken' => $this->securityContext->getCsrfProtectionToken() ] ); + return null; } else { if ($originalRequest !== null) { // Redirect to the location that redirected to the login form because the user was nog logged in @@ -268,11 +266,8 @@ public function logoutAction(): void /** * Disable the default error flash message * - * - * @phpstan-ignore-next-line Flow does not properly declare its types here - * @return false */ - protected function getErrorFlashMessage(): bool + protected function getErrorFlashMessage(): false { return false; } diff --git a/Neos.Neos/Classes/Controller/Module/AbstractModuleController.php b/Neos.Neos/Classes/Controller/Module/AbstractModuleController.php index b52cee0325b..81d6445b6ff 100644 --- a/Neos.Neos/Classes/Controller/Module/AbstractModuleController.php +++ b/Neos.Neos/Classes/Controller/Module/AbstractModuleController.php @@ -68,9 +68,6 @@ public function indexAction() /** * Display no flash message at all on errors. - * - * @phpstan-ignore-next-line Flow does not properly declare its types here - * @return false */ protected function getErrorFlashMessage() { diff --git a/Neos.Neos/Classes/Controller/Module/Administration/PackagesController.php b/Neos.Neos/Classes/Controller/Module/Administration/PackagesController.php index a73a2374a7b..537f1504dba 100644 --- a/Neos.Neos/Classes/Controller/Module/Administration/PackagesController.php +++ b/Neos.Neos/Classes/Controller/Module/Administration/PackagesController.php @@ -36,7 +36,6 @@ public function indexAction() $packageGroups = []; foreach ($this->packageManager->getAvailablePackages() as $package) { /** @var Package $package */ - /** @phpstan-ignore-next-line FLOW_PATH_PACKAGES is known at this point */ $packagePath = substr($package->getPackagepath(), strlen(FLOW_PATH_PACKAGES)); $packageGroup = substr($packagePath, 0, strpos($packagePath, '/') ?: null); $packageGroups[$packageGroup][$package->getPackageKey()] = [ diff --git a/Neos.Neos/Classes/Controller/Module/Administration/SitesController.php b/Neos.Neos/Classes/Controller/Module/Administration/SitesController.php index 04fecdde89d..61f854c20f5 100755 --- a/Neos.Neos/Classes/Controller/Module/Administration/SitesController.php +++ b/Neos.Neos/Classes/Controller/Module/Administration/SitesController.php @@ -393,7 +393,6 @@ public function createSiteNodeAction($packageKey, $siteName, $nodeType) 1412372375 ); $this->redirect('createSiteNode'); - return; } catch (SiteNodeTypeIsInvalid $exception) { $this->addFlashMessage( $this->getModuleLabel( @@ -406,7 +405,6 @@ public function createSiteNodeAction($packageKey, $siteName, $nodeType) 1412372375 ); $this->redirect('createSiteNode'); - return; } catch (SiteNodeNameIsAlreadyInUseByAnotherSite | NodeNameIsAlreadyOccupied $exception) { $this->addFlashMessage( $this->getModuleLabel('sites.SiteCreationError.siteWithSiteNodeNameAlreadyExists.body', [$siteName]), @@ -416,7 +414,6 @@ public function createSiteNodeAction($packageKey, $siteName, $nodeType) 1412372375 ); $this->redirect('createSiteNode'); - return; } $this->addFlashMessage( diff --git a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php index 26d7046e851..ec474622f5c 100644 --- a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php +++ b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php @@ -163,7 +163,6 @@ public function showAction(WorkspaceName $workspace): void if (is_null($workspaceObj)) { /** @todo add flash message */ $this->redirect('index'); - return; } $this->view->assignMultiple([ 'selectedWorkspace' => $workspaceObj, @@ -259,7 +258,6 @@ public function editAction(WorkspaceName $workspaceName): void if (is_null($workspace)) { // @todo add flash message $this->redirect('index'); - return; } $this->view->assign('workspace', $workspace); $this->view->assign('baseWorkspaceOptions', $this->prepareBaseWorkspaceOptions($contentRepository, $workspace)); @@ -304,7 +302,6 @@ public function updateAction( Message::SEVERITY_ERROR ); $this->redirect('index'); - return; } if (!$workspace->workspaceTitle->equals($title) || !$workspace->workspaceDescription->equals($description)) { @@ -360,12 +357,10 @@ public function deleteAction(WorkspaceName $workspaceName): void Message::SEVERITY_ERROR ); $this->redirect('index'); - return; } if ($workspace->isPersonalWorkspace()) { $this->redirect('index'); - return; } $dependentWorkspaces = $contentRepository->getWorkspaceFinder() diff --git a/Neos.Neos/Classes/Service/Controller/AbstractServiceController.php b/Neos.Neos/Classes/Service/Controller/AbstractServiceController.php index 5a67975cbd7..eacebb5d5bd 100644 --- a/Neos.Neos/Classes/Service/Controller/AbstractServiceController.php +++ b/Neos.Neos/Classes/Service/Controller/AbstractServiceController.php @@ -95,7 +95,6 @@ public function processRequest(ActionRequest $request, ActionResponse $response) { try { parent::processRequest($request, $response); - /** @phpstan-ignore-next-line Although Flow does not declare it, StopActionExceptions might be thrown */ } catch (StopActionException $exception) { throw $exception; } catch (\Exception $exception) { diff --git a/bootstrap-phpstan.php b/bootstrap-phpstan.php new file mode 100644 index 00000000000..589be9a4f96 --- /dev/null +++ b/bootstrap-phpstan.php @@ -0,0 +1,9 @@ + but returns array\\\\>\\.$#" + count: 1 + path: Neos.Neos/Classes/Controller/Module/Administration/UsersController.php + + - + message: "#^Method Neos\\\\Neos\\\\Controller\\\\Module\\\\Administration\\\\UsersController\\:\\:updateAccountAction\\(\\) has parameter \\$password with no value type specified in iterable type array\\.$#" + count: 1 + path: Neos.Neos/Classes/Controller/Module/Administration/UsersController.php + + - + message: "#^Method Neos\\\\Neos\\\\Controller\\\\Module\\\\Administration\\\\UsersController\\:\\:updateAccountAction\\(\\) has parameter \\$roleIdentifiers with no value type specified in iterable type array\\.$#" + count: 1 + path: Neos.Neos/Classes/Controller/Module/Administration/UsersController.php + + - + message: "#^PHPDoc tag @var for variable \\$personName contains unknown class Neos\\\\Neos\\\\Controller\\\\Module\\\\Administration\\\\PersonName\\.$#" + count: 1 + path: Neos.Neos/Classes/Controller/Module/Administration/UsersController.php + + - + message: "#^Parameter \\#1 \\$messageBody of method Neos\\\\Flow\\\\Mvc\\\\Controller\\\\AbstractController\\:\\:addFlashMessage\\(\\) expects string, string\\|null given\\.$#" + count: 16 + path: Neos.Neos/Classes/Controller/Module/Administration/UsersController.php + + - + message: "#^Parameter \\#1 \\$roles of method Neos\\\\Flow\\\\Security\\\\Authorization\\\\PrivilegeManagerInterface\\:\\:isPrivilegeTargetGrantedForRoles\\(\\) expects array\\, array\\ given\\.$#" + count: 1 + path: Neos.Neos/Classes/Controller/Module/Administration/UsersController.php + + - + message: "#^Parameter \\#1 \\$string of function htmlspecialchars expects string, Neos\\\\Party\\\\Domain\\\\Model\\\\PersonName given\\.$#" + count: 1 + path: Neos.Neos/Classes/Controller/Module/Administration/UsersController.php + + - + message: "#^Parameter \\#1 \\$user of method Neos\\\\Neos\\\\Controller\\\\Module\\\\Administration\\\\UsersController\\:\\:isEditingAllowed\\(\\) expects Neos\\\\Neos\\\\Domain\\\\Model\\\\User, Neos\\\\Neos\\\\Domain\\\\Model\\\\User\\|null given\\.$#" + count: 1 + path: Neos.Neos/Classes/Controller/Module/Administration/UsersController.php + + - + message: "#^Parameter \\#1 \\$user of method Neos\\\\Neos\\\\Domain\\\\Service\\\\UserService\\:\\:setUserPassword\\(\\) expects Neos\\\\Neos\\\\Domain\\\\Model\\\\User, Neos\\\\Neos\\\\Domain\\\\Model\\\\User\\|null given\\.$#" + count: 1 + path: Neos.Neos/Classes/Controller/Module/Administration/UsersController.php + + - + message: "#^Parameter \\#2 \\$messageTitle of method Neos\\\\Flow\\\\Mvc\\\\Controller\\\\AbstractController\\:\\:addFlashMessage\\(\\) expects string, string\\|null given\\.$#" + count: 18 + path: Neos.Neos/Classes/Controller/Module/Administration/UsersController.php + + - + message: "#^Property Neos\\\\Neos\\\\Controller\\\\Module\\\\Administration\\\\UsersController\\:\\:\\$authenticationProviderSettings type has no value type specified in iterable type array\\.$#" + count: 1 + path: Neos.Neos/Classes/Controller/Module/Administration/UsersController.php + + - + message: "#^Property Neos\\\\Neos\\\\Controller\\\\Module\\\\Administration\\\\UsersController\\:\\:\\$currentUser \\(Neos\\\\Neos\\\\Domain\\\\Model\\\\User\\) does not accept Neos\\\\Neos\\\\Domain\\\\Model\\\\User\\|null\\.$#" + count: 1 + path: Neos.Neos/Classes/Controller/Module/Administration/UsersController.php + + - + message: "#^Ternary operator condition is always true\\.$#" + count: 1 + path: Neos.Neos/Classes/Controller/Module/Administration/UsersController.php + + - + message: "#^Method Neos\\\\Neos\\\\Controller\\\\Module\\\\User\\\\UserSettingsController\\:\\:updateAccountAction\\(\\) has parameter \\$password with no value type specified in iterable type array\\.$#" + count: 1 + path: Neos.Neos/Classes/Controller/Module/User/UserSettingsController.php + + - + message: "#^Parameter \\#1 \\$messageBody of method Neos\\\\Flow\\\\Mvc\\\\Controller\\\\AbstractController\\:\\:addFlashMessage\\(\\) expects string, string\\|null given\\.$#" + count: 4 + path: Neos.Neos/Classes/Controller/Module/User/UserSettingsController.php + + - + message: "#^Parameter \\#2 \\$messageTitle of method Neos\\\\Flow\\\\Mvc\\\\Controller\\\\AbstractController\\:\\:addFlashMessage\\(\\) expects string, string\\|null given\\.$#" + count: 5 + path: Neos.Neos/Classes/Controller/Module/User/UserSettingsController.php + + - + message: "#^Property Neos\\\\Neos\\\\Controller\\\\Module\\\\User\\\\UserSettingsController\\:\\:\\$currentUser \\(Neos\\\\Neos\\\\Domain\\\\Model\\\\User\\) does not accept Neos\\\\Neos\\\\Domain\\\\Model\\\\User\\|null\\.$#" + count: 1 + path: Neos.Neos/Classes/Controller/Module/User/UserSettingsController.php + + - + message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\Projection\\\\ContentStream\\\\ContentStreamFinder\\:\\:findAllIds\" is called\\.$#" + count: 1 + path: Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php + + - + message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\DimensionSpace\\\\WeightedDimensionSpacePoint\\:\\:getIdentityHash\" is called\\.$#" + count: 3 + path: Neos.Neos/Classes/Presentation/Dimensions/VisualInterDimensionalVariationGraph.php + + - + message: "#^The internal method \"Neos\\\\ContentRepository\\\\Core\\\\DimensionSpace\\\\WeightedDimensionSpacePoint\\:\\:getIdentityHash\" is called\\.$#" + count: 1 + path: Neos.Neos/Classes/Presentation/Dimensions/VisualWeightedDimensionSpacePoint.php + + - + message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php + + - + message: "#^Method Neos\\\\Neos\\\\ResourceManagement\\\\NodeTypesStreamWrapper\\:\\:cast\\(\\) should return resource but returns false\\.$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php + + - + message: "#^Method Neos\\\\Neos\\\\ResourceManagement\\\\NodeTypesStreamWrapper\\:\\:pathStat\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php + + - + message: "#^Method Neos\\\\Neos\\\\ResourceManagement\\\\NodeTypesStreamWrapper\\:\\:pathStat\\(\\) should return array but returns array\\\\|false\\.$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php + + - + message: "#^Method Neos\\\\Neos\\\\ResourceManagement\\\\NodeTypesStreamWrapper\\:\\:pathStat\\(\\) should return array but returns false\\.$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php + + - + message: "#^Method Neos\\\\Neos\\\\ResourceManagement\\\\NodeTypesStreamWrapper\\:\\:read\\(\\) should return string but returns string\\|false\\.$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php + + - + message: "#^Method Neos\\\\Neos\\\\ResourceManagement\\\\NodeTypesStreamWrapper\\:\\:readDirectory\\(\\) should return string but returns string\\|false\\.$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php + + - + message: "#^Method Neos\\\\Neos\\\\ResourceManagement\\\\NodeTypesStreamWrapper\\:\\:resourceStat\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php + + - + message: "#^Method Neos\\\\Neos\\\\ResourceManagement\\\\NodeTypesStreamWrapper\\:\\:resourceStat\\(\\) should return array but returns array\\\\|false\\.$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php + + - + message: "#^Method Neos\\\\Neos\\\\ResourceManagement\\\\NodeTypesStreamWrapper\\:\\:tell\\(\\) should return int but returns int\\|false\\.$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php + + - + message: "#^Method Neos\\\\Neos\\\\ResourceManagement\\\\NodeTypesStreamWrapper\\:\\:write\\(\\) should return int but returns int\\<0, max\\>\\|false\\.$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php + + - + message: "#^Parameter \\#2 \\$length of function fread expects int\\<0, max\\>, int given\\.$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php + + - + message: "#^Parameter \\#3 \\$recursive of function mkdir expects bool, int\\<0, 1\\> given\\.$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php + + - + message: "#^Return type \\(void\\) of method Neos\\\\Neos\\\\ResourceManagement\\\\NodeTypesStreamWrapper\\:\\:makeDirectory\\(\\) should be compatible with return type \\(bool\\) of method Neos\\\\Flow\\\\ResourceManagement\\\\Streams\\\\StreamWrapperInterface\\:\\:makeDirectory\\(\\)$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php + + - + message: "#^Return type \\(void\\) of method Neos\\\\Neos\\\\ResourceManagement\\\\NodeTypesStreamWrapper\\:\\:removeDirectory\\(\\) should be compatible with return type \\(bool\\) of method Neos\\\\Flow\\\\ResourceManagement\\\\Streams\\\\StreamWrapperInterface\\:\\:removeDirectory\\(\\)$#" + count: 1 + path: Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 108878cd883..2273d653107 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,3 +1,6 @@ +includes: + - phpstan-baseline.neon + parameters: level: 8 paths: @@ -12,13 +15,8 @@ parameters: - Neos.ContentRepository.TestSuite/Classes - Neos.ContentRepositoryRegistry/Classes - Neos.Neos/Classes - excludePaths: - analyse: - - Neos.Neos/Classes/ResourceManagement/NodeTypesStreamWrapper.php - - Neos.Neos/Classes/Controller/Module/User/UserSettingsController.php - - Neos.Neos/Classes/Controller/Module/Administration/UsersController.php - - Neos.Neos/Classes/Controller/Backend/MenuHelper.php - - Neos.ContentRepositoryRegistry/Classes/Command/ContentCommandController.php + bootstrapFiles: + - bootstrap-phpstan.php rules: - Neos\ContentRepository\BehavioralTests\PhpstanRules\ApiOrInternalAnnotationRule -# - Neos\ContentRepository\BehavioralTests\PhpstanRules\InternalMethodsNotAllowedOutsideContentRepositoryRule + - Neos\ContentRepository\BehavioralTests\PhpstanRules\InternalMethodsNotAllowedOutsideContentRepositoryRule