Skip to content

Commit

Permalink
TASK: Add php-stan level 1 to 8.3 codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Jan 18, 2024
1 parent 1ef2c6d commit 89bd03f
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 15 deletions.
1 change: 1 addition & 0 deletions Neos.ContentRepository/Classes/Domain/Model/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@ public function getProperty($propertyName, bool $returnNodesAsIdentifiers = fals
}

if (
/** @phpstan-ignore-next-line i will not touch this code */
isset($expectedPropertyType) &&
$expectedPropertyType === 'Neos\Media\Domain\Model\ImageInterface' &&
empty($value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function parseFilterString(string $serializedFilters): NodeTypeConstraint

// in case there are no filters, we fall back to allowing every node type.
// Furthermore, if there are only negated filters, we also fall back to allowing every node type (when the excludelist does not match)
$wildcardAllowed = empty($serializedFilters) || (!empty($serializedFilters) && $onlyNegatedFilters);
$wildcardAllowed = empty($serializedFilters) || $onlyNegatedFilters;

return new NodeTypeConstraints($wildcardAllowed, $explicitlyAllowedNodeTypeNames, $explicitlyDisallowedNodeTypeNames);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function findByNodeIdentifier($nodeIdentifier)
* @param array $dimensions An array of dimensions with array of ordered values to use for fallback matching
* @param boolean|NULL $removedNodes Include removed nodes, NULL (all), false (no removed nodes) or true (only removed nodes)
* @throws \InvalidArgumentException
* @return NodeData The matching node if found, otherwise NULL
* @return NodeData|null The matching node if found, otherwise NULL
*/
public function findOneByPath($path, Workspace $workspace, array $dimensions = null, $removedNodes = false)
{
Expand Down Expand Up @@ -321,7 +321,7 @@ public function findOneByPathInContext($path, Context $context)
* @param Workspace $workspace The containing workspace
* @param array $dimensions An array of dimensions with array of ordered values to use for fallback matching
* @param bool $removedNodes If shadow nodes should be considered while finding the specified node
* @return NodeData The matching node if found, otherwise NULL
* @return NodeData|null The matching node if found, otherwise NULL
*/
public function findOneByIdentifier($identifier, Workspace $workspace, array $dimensions = null, $removedNodes = false)
{
Expand Down
2 changes: 1 addition & 1 deletion Neos.Diff/Classes/SequenceMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ public function getGroupedOpcodes($context = 3)
];
}

if (!empty($group) && !(count($group) == 1 && $group[0][0] == 'equal')) {
if (!(count($group) == 1 && $group[0][0] == 'equal')) {
$groups[] = $group;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function handleRenderingException($fusionPath, \Exception $exception)
*
* @param string $fusionPath path causing the exception
* @param \Exception $exception exception to handle
* @param integer $referenceCode
* @param integer|null $referenceCode
* @return string
*/
abstract protected function handle($fusionPath, \Exception $exception, $referenceCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PlainTextHandler extends AbstractRenderingExceptionHandler
*
* @param string $fusionPath path causing the exception
* @param \Exception $exception exception to handle
* @param integer $referenceCode
* @param integer|null $referenceCode
* @return string
*/
protected function handle($fusionPath, \Exception $exception, $referenceCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function injectThrowableStorage(ThrowableStorageInterface $throwableStora
*
* @param string $fusionPath path causing the exception
* @param \Exception $exception exception to handle
* @param integer $referenceCode
* @param integer|null $referenceCode
* @return string
*/
protected function handle($fusionPath, \Exception $exception, $referenceCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ protected static function resolveRelativePath(string $filePattern, ?string $file

protected static function parseGlobPatternAndResolveFiles(string $filePattern, string $defaultFileNameEnd): array
{
$matches = null;
$fileIteratorCreator = match (1) {
// We use the flag SKIP_DOTS, as it might not be allowed to access `..` and we only are interested in files
// We use the flag UNIX_PATHS, so that stream wrapper paths are always valid on windows https://github.com/neos/neos-development-collection/issues/4358
Expand Down
2 changes: 2 additions & 0 deletions Neos.Fusion/Classes/Core/RuntimeConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function forPath(string $fusionPath): array

// Build configuration for the remaining path parts
$remainingPath = substr($fusionPath, $pathUntilNow === '' ? 0 : strlen($pathUntilNow) + 1);
/** @var non-empty-list<string> $pathParts */
$pathParts = explode('/', $remainingPath);
foreach ($pathParts as $pathPart) {
if ($pathUntilNow === '') {
Expand All @@ -106,6 +107,7 @@ public function forPath(string $fusionPath): array
continue;
}

/** @phpstan-ignore-next-line $configuration is set */
$configuration = $this->matchCurrentPathPart($pathPart, $configuration, $currentPrototypeDefinitions);
$this->pathCache[$pathUntilNow]['c'] = $configuration;
$this->pathCache[$pathUntilNow]['p'] = $currentPrototypeDefinitions;
Expand Down
2 changes: 1 addition & 1 deletion Neos.Media.Browser/Classes/Controller/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public function indexAction($view = null, $sortBy = null, $sortDirection = null,

$allCollectionsCount = $this->assetRepository->countAll();
$allCount = ($activeAssetCollection ? $this->assetRepository->countByAssetCollection($activeAssetCollection) : $allCollectionsCount);
$searchResultCount = isset($assetProxies) ? $assetProxies->count() : 0;
$searchResultCount = $assetProxies->count();
$untaggedCount = ($assetProxyRepository instanceof SupportsTaggingInterface ? $assetProxyRepository->countUntagged() : 0);
} catch (AssetSourceConnectionExceptionInterface $e) {
$this->view->assign('connectionError', $e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected function setPropertyLabels($nodeTypeName, array &$configuration, array
* Resolve help message thumbnail url
*
* @param string $nodeTypeName
* @param string $configurationThumbnail
* @param string|null $configurationThumbnail
* @return string $thumbnailUrl
*/
protected function resolveHelpMessageThumbnail($nodeTypeName, $configurationThumbnail)
Expand Down Expand Up @@ -168,7 +168,7 @@ protected function applyEditorLabels($nodeTypeLabelIdPrefix, $propertyName, $edi
{
switch ($editorName) {
case 'Neos.Neos/Inspector/Editors/SelectBoxEditor':
if (isset($editorOptions) && $this->shouldFetchTranslation($editorOptions, 'placeholder')) {
if ($this->shouldFetchTranslation($editorOptions, 'placeholder')) {
$editorOptions['placeholder'] = $translationIdGenerator('selectBoxEditor.placeholder');
}

Expand All @@ -190,12 +190,12 @@ protected function applyEditorLabels($nodeTypeLabelIdPrefix, $propertyName, $edi
}
break;
case 'Neos.Neos/Inspector/Editors/TextFieldEditor':
if (isset($editorOptions) && $this->shouldFetchTranslation($editorOptions, 'placeholder')) {
if ($this->shouldFetchTranslation($editorOptions, 'placeholder')) {
$editorOptions['placeholder'] = $translationIdGenerator('textFieldEditor.placeholder');
}
break;
case 'Neos.Neos/Inspector/Editors/TextAreaEditor':
if (isset($editorOptions) && $this->shouldFetchTranslation($editorOptions, 'placeholder')) {
if ($this->shouldFetchTranslation($editorOptions, 'placeholder')) {
$editorOptions['placeholder'] = $translationIdGenerator('textAreaEditor.placeholder');
}
break;
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Classes/Controller/Backend/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function indexAction(array $module)

$moduleRequest->setArgument('__moduleConfiguration', $moduleConfiguration);

$moduleResponse = new ActionResponse($this->response);
$moduleResponse = new ActionResponse();

$this->dispatcher->dispatch($moduleRequest, $moduleResponse);

Expand Down
2 changes: 2 additions & 0 deletions Neos.Neos/Classes/Domain/Repository/DomainRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
use Neos\Flow\Core\Bootstrap;
use Neos\Flow\Http\HttpRequestHandlerInterface;
use Neos\Flow\Persistence\QueryInterface;
use Neos\Flow\Persistence\QueryResultInterface;
use Neos\Flow\Persistence\Repository;
use Neos\Neos\Domain\Model\Domain;
use Neos\Neos\Domain\Service\DomainMatchingStrategy;

/**
* The Site Repository
*
* @method QueryResultInterface<Domain> findByActive(boolean $active)
* @Flow\Scope("singleton")
* @api
*/
Expand Down
1 change: 1 addition & 0 deletions Neos.Neos/Classes/Domain/Repository/SiteRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/**
* The Site Repository
*
* @method QueryResultInterface<Site> findByState(int $state)
* @Flow\Scope("singleton")
* @api
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public function processRequest(ActionRequest $request, ActionResponse $response)
*/
protected function convertException(\Exception $exception)
{
$exceptionData = [];
if ($this->objectManager->getContext()->isProduction()) {
if ($exception instanceof FlowException) {
$exceptionData['message'] = 'When contacting the maintainer of this application please mention the following reference code:<br /><br />' . $exception->getReferenceCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ protected static function evaluateCondition($arguments, RenderingContextInterfac
if (!$privilegeManager->isGranted(ModulePrivilege::class, new ModulePrivilegeSubject($arguments['modulePath']))) {
return false;
}
/** @phpstan-ignore-next-line condition will be fixed with Neos 9 */
if (isset($moduleConfiguration['privilegeTarget'])) {
return $privilegeManager->isPrivilegeTargetGranted($arguments['moduleConfiguration']['privilegeTarget']);
}
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 0
level: 1
ignoreErrors:
# Errors caused by the backport of the ESCR TraversableNodeInterface
- '#has invalid return type Neos\\ContentRepository\\DimensionSpace\\DimensionSpace\\DimensionSpacePoint.$#'
Expand All @@ -16,6 +16,6 @@ parameters:
- Neos.NodeTypes.Form/Classes
- Neos.SiteKickstarter/Classes
bootstrapFiles:
- ../Framework/phpstan.neon
- ../Framework/bootstrap-phpstan.php
excludePaths:
analyse: {}

0 comments on commit 89bd03f

Please sign in to comment.