diff --git a/.composer.json b/.composer.json index 5dca2cdc74f..f39d91c24db 100644 --- a/.composer.json +++ b/.composer.json @@ -18,6 +18,7 @@ "@lint:phpcs-psr12 --exclude=Generic.Files.LineLength,PSR1.Files.SideEffects" ], "lint:phpstan": "../../bin/phpstan analyse", + "lint:phpstan-generate-baseline": "../../bin/phpstan analyse --generate-baseline", "lint:distributionintegrity": "[ -d 'Neos.ContentRepository' ] && { echo 'Package Neos.ContentRepository should not exist.' 1>&2; exit 1; } || exit 0;", "lint": [ "@lint:phpcs", diff --git a/Neos.ContentRepository.Core/Classes/DimensionSpace/ContentSubgraphVariationWeight.php b/Neos.ContentRepository.Core/Classes/DimensionSpace/ContentSubgraphVariationWeight.php index d497e981938..a4e1c67a98a 100644 --- a/Neos.ContentRepository.Core/Classes/DimensionSpace/ContentSubgraphVariationWeight.php +++ b/Neos.ContentRepository.Core/Classes/DimensionSpace/ContentSubgraphVariationWeight.php @@ -43,7 +43,7 @@ public function __construct( throw new \InvalidArgumentException( sprintf( 'Weight component %s was not of type ContentDimensionValueSpecializationDepth', - $specializationDepth + get_debug_type($specializationDepth) ), 1531477454 ); diff --git a/Neos.ContentRepository.Core/Classes/Feature/Common/ConstraintChecks.php b/Neos.ContentRepository.Core/Classes/Feature/Common/ConstraintChecks.php index e23507bb06a..39862e9ee45 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/Common/ConstraintChecks.php +++ b/Neos.ContentRepository.Core/Classes/Feature/Common/ConstraintChecks.php @@ -52,7 +52,6 @@ use Neos\ContentRepository\Core\Feature\NodeModification\Dto\PropertyValuesToWrite; use Neos\ContentRepository\Core\SharedModel\Node\ReferenceName; use Neos\ContentRepository\Core\NodeType\NodeType; -use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraintsWithSubNodeTypes; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; diff --git a/Neos.ContentRepository.Core/Classes/Feature/Common/NodeAggregateEventPublisher.php b/Neos.ContentRepository.Core/Classes/Feature/Common/NodeAggregateEventPublisher.php index 91d503e5e76..8371bc83d55 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/Common/NodeAggregateEventPublisher.php +++ b/Neos.ContentRepository.Core/Classes/Feature/Common/NodeAggregateEventPublisher.php @@ -44,13 +44,11 @@ public static function enrichWithCommand( get_class($event) )); } - } else { - if (!$event instanceof PublishableToOtherContentStreamsInterface) { - throw new \RuntimeException(sprintf( - 'TODO: Event %s has to implement PublishableToOtherContentStreamsInterface', - get_class($event) - )); - } + } elseif (!$event instanceof PublishableToOtherContentStreamsInterface) { + throw new \RuntimeException(sprintf( + 'TODO: Event %s has to implement PublishableToOtherContentStreamsInterface', + get_class($event) + )); } if ($i === 0) { @@ -75,11 +73,9 @@ public static function enrichWithCommand( $event = DecoratedEvent::create($event, eventId: EventId::create(), metadata: $metadata); // we remember the 1st event's identifier as causation identifier for all the others $causationId = $event->eventId; - } else { + } elseif ($causationId !== null) { // event 2,3,4,...n get a causation identifier set, as they all originate from the 1st event. - if ($causationId !== null) { - $event = DecoratedEvent::create($event, causationId: $causationId); - } + $event = DecoratedEvent::create($event, causationId: $causationId); } $processedEvents[] = $event; $i++; diff --git a/Neos.ContentRepository.Core/Classes/Feature/NodeVariation/NodeVariation.php b/Neos.ContentRepository.Core/Classes/Feature/NodeVariation/NodeVariation.php index 1e344c9fff1..dbed5b970aa 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/NodeVariation/NodeVariation.php +++ b/Neos.ContentRepository.Core/Classes/Feature/NodeVariation/NodeVariation.php @@ -17,7 +17,6 @@ use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\DimensionSpace\Exception\DimensionSpacePointNotFound; use Neos\ContentRepository\Core\EventStore\EventsToPublish; -use Neos\ContentRepository\Core\Feature\NodeVariation\Exception\RootNodeCannotBeVaried; use Neos\ContentRepository\Core\SharedModel\Exception\ContentStreamDoesNotExistYet; use Neos\ContentRepository\Core\Feature\ContentStreamEventStreamName; use Neos\ContentRepository\Core\Feature\NodeVariation\Command\CreateNodeVariant; diff --git a/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/ChildrenOperation.php b/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/ChildrenOperation.php index 370fefd9861..e2a07d15b64 100644 --- a/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/ChildrenOperation.php +++ b/Neos.ContentRepository.NodeAccess/Classes/FlowQueryOperations/ChildrenOperation.php @@ -116,6 +116,7 @@ protected function earlyOptimizationOfFilters(FlowQuery $flowQuery, array $parse $outputNodeAggregateIds = []; foreach ($parsedFilter['Filters'] as $filter) { $instanceOfFilters = []; + // @todo array is never queried $attributeFilters = []; if (isset($filter['AttributeFilters'])) { foreach ($filter['AttributeFilters'] as $attributeFilter) { diff --git a/Neos.ContentRepositoryRegistry/Classes/Command/ContentGraphIntegrityCommandController.php b/Neos.ContentRepositoryRegistry/Classes/Command/ContentGraphIntegrityCommandController.php index 0e096878182..2138ebd1fd0 100644 --- a/Neos.ContentRepositoryRegistry/Classes/Command/ContentGraphIntegrityCommandController.php +++ b/Neos.ContentRepositoryRegistry/Classes/Command/ContentGraphIntegrityCommandController.php @@ -17,8 +17,8 @@ final class ContentGraphIntegrityCommandController extends CommandController { - const OUTPUT_MODE_CONSOLE = 'console'; - const OUTPUT_MODE_LOG = 'log'; + private const OUTPUT_MODE_CONSOLE = 'console'; + private const OUTPUT_MODE_LOG = 'log'; private ProjectionIntegrityViolationDetectionRunner $detectionRunner; diff --git a/Neos.ContentRepositoryRegistry/Classes/ContentRepositoryRegistry.php b/Neos.ContentRepositoryRegistry/Classes/ContentRepositoryRegistry.php index ef9882db035..367ba4da484 100644 --- a/Neos.ContentRepositoryRegistry/Classes/ContentRepositoryRegistry.php +++ b/Neos.ContentRepositoryRegistry/Classes/ContentRepositoryRegistry.php @@ -196,7 +196,7 @@ private function buildPropertySerializer(ContentRepositoryId $contentRepositoryI $normalizers = []; foreach ($propertyConvertersConfiguration as $propertyConverterConfiguration) { - $normalizer = new $propertyConverterConfiguration['className']; + $normalizer = new $propertyConverterConfiguration['className'](); if (!$normalizer instanceof NormalizerInterface && !$normalizer instanceof DenormalizerInterface) { throw InvalidConfigurationException::fromMessage('Serializers can only be created of %s and %s, %s given', NormalizerInterface::class, DenormalizerInterface::class, get_debug_type($normalizer)); } diff --git a/Neos.Fusion/Classes/Core/Cache/ContentCache.php b/Neos.Fusion/Classes/Core/Cache/ContentCache.php index f36526283a8..3436c87e66a 100644 --- a/Neos.Fusion/Classes/Core/Cache/ContentCache.php +++ b/Neos.Fusion/Classes/Core/Cache/ContentCache.php @@ -40,30 +40,31 @@ * Note: If you choose a different cache backend for this content cache, make sure that it is one implementing * TaggableBackendInterface. * + * @internal * @Flow\Scope("singleton") */ class ContentCache { - const CACHE_SEGMENT_START_TOKEN = "\x02"; - const CACHE_SEGMENT_END_TOKEN = "\x03"; - const CACHE_SEGMENT_SEPARATOR_TOKEN = "\x1f"; + public const CACHE_SEGMENT_START_TOKEN = "\x02"; + public const CACHE_SEGMENT_END_TOKEN = "\x03"; + public const CACHE_SEGMENT_SEPARATOR_TOKEN = "\x1f"; - const CACHE_SEGMENT_MARKER = 'CONTENT_CACHE'; + public const CACHE_SEGMENT_MARKER = 'CONTENT_CACHE'; - const CACHE_PLACEHOLDER_REGEX = "/\x02CONTENT_CACHE(?P[a-f0-9]+)\x03CONTENT_CACHE/"; - const EVAL_PLACEHOLDER_REGEX = "/\x02CONTENT_CACHE(?P[^\x02\x1f\x03]+)\x1fCONTENT_CACHE(?P[^\x02\x1f\x03]+)\x03CONTENT_CACHE/"; + public const CACHE_PLACEHOLDER_REGEX = "/\x02CONTENT_CACHE(?P[a-f0-9]+)\x03CONTENT_CACHE/"; + public const EVAL_PLACEHOLDER_REGEX = "/\x02CONTENT_CACHE(?P[^\x02\x1f\x03]+)\x1fCONTENT_CACHE(?P[^\x02\x1f\x03]+)\x03CONTENT_CACHE/"; - const MAXIMUM_NESTING_LEVEL = 32; + public const MAXIMUM_NESTING_LEVEL = 32; /** * A cache entry tag that will be used by default to flush an entry on "every" change - whatever that means to * the application. */ - const TAG_EVERYTHING = 'Everything'; + public const TAG_EVERYTHING = 'Everything'; - const SEGMENT_TYPE_CACHED = 'cached'; - const SEGMENT_TYPE_UNCACHED = 'uncached'; - const SEGMENT_TYPE_DYNAMICCACHED = 'dynamiccached'; + public const SEGMENT_TYPE_CACHED = 'cached'; + public const SEGMENT_TYPE_UNCACHED = 'uncached'; + public const SEGMENT_TYPE_DYNAMICCACHED = 'dynamiccached'; /** * @var StringFrontend diff --git a/Neos.Fusion/Classes/Core/FusionConfiguration.php b/Neos.Fusion/Classes/Core/FusionConfiguration.php index 591ac3b533f..311892e1a87 100644 --- a/Neos.Fusion/Classes/Core/FusionConfiguration.php +++ b/Neos.Fusion/Classes/Core/FusionConfiguration.php @@ -35,7 +35,7 @@ protected function __construct( */ public static function fromArray(array $fusionConfiguration): self { - return new static($fusionConfiguration); + return new self($fusionConfiguration); } /** diff --git a/Neos.Fusion/Classes/Core/FusionSourceCode.php b/Neos.Fusion/Classes/Core/FusionSourceCode.php index 0acfdf706f2..45e1d8b9a1d 100644 --- a/Neos.Fusion/Classes/Core/FusionSourceCode.php +++ b/Neos.Fusion/Classes/Core/FusionSourceCode.php @@ -25,7 +25,7 @@ protected function __construct( public static function fromString(string $string): self { - return new static(null, $string); + return new self(null, $string); } public static function fromFilePath(string $filePath): self @@ -33,7 +33,7 @@ public static function fromFilePath(string $filePath): self if (is_readable($filePath) === false) { throw new Fusion\Exception("Trying to read Fusion source code from file, but '$filePath' is not readable.", 1657963790); } - return new static($filePath, fn () => file_get_contents($filePath)); + return new self($filePath, fn () => file_get_contents($filePath)); } /** @@ -41,7 +41,7 @@ public static function fromFilePath(string $filePath): self */ public static function fromDangerousPotentiallyDifferingSourceCodeAndFilePath(string $sourceCode, string $filePath): self { - return new static($filePath, $sourceCode); + return new self($filePath, $sourceCode); } public function getSourceCode(): string diff --git a/Neos.Fusion/Classes/Core/FusionSourceCodeCollection.php b/Neos.Fusion/Classes/Core/FusionSourceCodeCollection.php index c69a671d7ac..9388bdf7d1f 100644 --- a/Neos.Fusion/Classes/Core/FusionSourceCodeCollection.php +++ b/Neos.Fusion/Classes/Core/FusionSourceCodeCollection.php @@ -13,6 +13,8 @@ * source code. */ +use Neos\Flow\Annotations as Flow; + /** * @implements \IteratorAggregate * @api @@ -22,7 +24,10 @@ final class FusionSourceCodeCollection implements \IteratorAggregate, \Countable /** @var array */ private array $fusionCodeCollection; - /** @param $fusionSourceCode array */ + /** + * @Flow\Autowiring(false) + * @param $fusionSourceCode array + */ public function __construct(FusionSourceCode ...$fusionSourceCode) { $this->fusionCodeCollection = self::deduplicateItemsAndKeepLast($fusionSourceCode); @@ -30,36 +35,36 @@ public function __construct(FusionSourceCode ...$fusionSourceCode) public static function fromFilePath(string $filePath): self { - return new static(FusionSourceCode::fromFilePath($filePath)); + return new self(FusionSourceCode::fromFilePath($filePath)); } public static function fromString(string $string): self { - return new static(FusionSourceCode::fromString($string)); + return new self(FusionSourceCode::fromString($string)); } public static function tryFromFilePath(string $filePath): self { if (!is_readable($filePath)) { - return static::empty(); + return self::empty(); } - return static::fromFilePath($filePath); + return self::fromFilePath($filePath); } public static function tryFromPackageRootFusion(string $packageKey): self { $fusionPathAndFilename = sprintf('resource://%s/Private/Fusion/Root.fusion', $packageKey); - return static::tryFromFilePath($fusionPathAndFilename); + return self::tryFromFilePath($fusionPathAndFilename); } public static function empty(): self { - return new static(); + return new self(); } public function union(FusionSourceCodeCollection $other): self { - return new static(...$this->fusionCodeCollection, ...$other->fusionCodeCollection); + return new self(...$this->fusionCodeCollection, ...$other->fusionCodeCollection); } /** diff --git a/Neos.Fusion/Classes/Core/Runtime.php b/Neos.Fusion/Classes/Core/Runtime.php index 3fb7624a08a..e14a792a41c 100644 --- a/Neos.Fusion/Classes/Core/Runtime.php +++ b/Neos.Fusion/Classes/Core/Runtime.php @@ -54,16 +54,16 @@ class Runtime /** * Internal constants defining how evaluate should work in case of an error */ - const BEHAVIOR_EXCEPTION = 'Exception'; + public const BEHAVIOR_EXCEPTION = 'Exception'; - const BEHAVIOR_RETURNNULL = 'NULL'; + public const BEHAVIOR_RETURNNULL = 'NULL'; /** * Internal constants defining a status of how evaluate was evaluated */ - const EVALUATION_EXECUTED = 'Executed'; + public const EVALUATION_EXECUTED = 'Executed'; - const EVALUATION_SKIPPED = 'Skipped'; + public const EVALUATION_SKIPPED = 'Skipped'; /** * @var \Neos\Eel\CompilingEvaluator diff --git a/Neos.Fusion/Classes/FusionObjects/CaseImplementation.php b/Neos.Fusion/Classes/FusionObjects/CaseImplementation.php index 6356c2929e2..96525b2a846 100644 --- a/Neos.Fusion/Classes/FusionObjects/CaseImplementation.php +++ b/Neos.Fusion/Classes/FusionObjects/CaseImplementation.php @@ -31,7 +31,7 @@ class CaseImplementation extends AbstractArrayFusionObject * * You should not rely on the contents or type of this constant. */ - const MATCH_NORESULT = '_____________NO_MATCH_RESULT_____________'; + public const MATCH_NORESULT = '_____________NO_MATCH_RESULT_____________'; /** * Execute each matcher until the first one matches diff --git a/Neos.Fusion/Classes/FusionObjects/TagImplementation.php b/Neos.Fusion/Classes/FusionObjects/TagImplementation.php index 069b165db14..d644d725c4b 100644 --- a/Neos.Fusion/Classes/FusionObjects/TagImplementation.php +++ b/Neos.Fusion/Classes/FusionObjects/TagImplementation.php @@ -63,7 +63,7 @@ public function getOmitClosingTag() */ public function isSelfClosingTag($tagName) { - return in_array($tagName, self::$SELF_CLOSING_TAGS, true) || (boolean)$this->fusionValue('selfClosingTag'); + return in_array($tagName, self::$SELF_CLOSING_TAGS, true) || $this->fusionValue('selfClosingTag'); } diff --git a/Neos.Media/Classes/Domain/Model/AssetSource/Neos/NeosAssetSource.php b/Neos.Media/Classes/Domain/Model/AssetSource/Neos/NeosAssetSource.php index a69172353e4..24193075225 100644 --- a/Neos.Media/Classes/Domain/Model/AssetSource/Neos/NeosAssetSource.php +++ b/Neos.Media/Classes/Domain/Model/AssetSource/Neos/NeosAssetSource.php @@ -120,11 +120,11 @@ public function __construct(string $assetSourceIdentifier, array $assetSourceOpt /** * @param string $assetSourceIdentifier * @param array $assetSourceOptions - * @return AssetSourceInterface + * @return self */ - public static function createFromConfiguration(string $assetSourceIdentifier, array $assetSourceOptions): AssetSourceInterface + public static function createFromConfiguration(string $assetSourceIdentifier, array $assetSourceOptions): self { - return new static($assetSourceIdentifier, $assetSourceOptions); + return new self($assetSourceIdentifier, $assetSourceOptions); } /** diff --git a/Neos.Media/Classes/Domain/Model/AssetSource/SupportsSortingInterface.php b/Neos.Media/Classes/Domain/Model/AssetSource/SupportsSortingInterface.php index 699eb410108..641e6a0d052 100644 --- a/Neos.Media/Classes/Domain/Model/AssetSource/SupportsSortingInterface.php +++ b/Neos.Media/Classes/Domain/Model/AssetSource/SupportsSortingInterface.php @@ -19,8 +19,8 @@ interface SupportsSortingInterface /** * Constants representing the direction when ordering result sets. */ - const ORDER_ASCENDING = 'ASC'; - const ORDER_DESCENDING = 'DESC'; + public const ORDER_ASCENDING = 'ASC'; + public const ORDER_DESCENDING = 'DESC'; /** * Note: This method is preliminary, not to be used for third-party asset sources yet. diff --git a/Neos.Media/Classes/Domain/Model/ImageInterface.php b/Neos.Media/Classes/Domain/Model/ImageInterface.php index 110e010c96f..e701b87fa9b 100644 --- a/Neos.Media/Classes/Domain/Model/ImageInterface.php +++ b/Neos.Media/Classes/Domain/Model/ImageInterface.php @@ -16,21 +16,21 @@ */ interface ImageInterface extends ResourceBasedInterface { - const ORIENTATION_SQUARE = 'square'; - const ORIENTATION_LANDSCAPE = 'landscape'; - const ORIENTATION_PORTRAIT = 'portrait'; + public const ORIENTATION_SQUARE = 'square'; + public const ORIENTATION_LANDSCAPE = 'landscape'; + public const ORIENTATION_PORTRAIT = 'portrait'; /** * Inset ratio mode: If an image is attempted to get scaled with the size of both edges stated, using this mode will scale it to the lower of both edges. * Consider an image of 320/480 being scaled to 50/50: because aspect ratio wouldn't get hurt, the target image size will become 33/50. */ - const RATIOMODE_INSET = 'inset'; + public const RATIOMODE_INSET = 'inset'; /** * Outbound ratio mode: If an image is attempted to get scaled with the size of both edges stated, using this mode will scale the image and crop it. * Consider an image of 320/480 being scaled to 50/50: the image will be scaled to height 50, then centered and cropped so the width will also be 50. */ - const RATIOMODE_OUTBOUND = 'outbound'; + public const RATIOMODE_OUTBOUND = 'outbound'; /** * Width of the image in pixels diff --git a/Neos.Media/Classes/Domain/Service/ImageService.php b/Neos.Media/Classes/Domain/Service/ImageService.php index ecbe0a245ba..35a97987ce0 100644 --- a/Neos.Media/Classes/Domain/Service/ImageService.php +++ b/Neos.Media/Classes/Domain/Service/ImageService.php @@ -310,6 +310,6 @@ protected function applyAdjustments(ImageInterface $image, array $adjustments, & protected function isAnimatedGif($image) { $count = preg_match_all('#\x00\x21\xF9\x04.{4}\x00(\x2C|\x21)#s', $image, $matches); - return $count ? true : false; + return (bool)$count; } } diff --git a/Neos.Media/Classes/Domain/ValueObject/Configuration/Adjustment.php b/Neos.Media/Classes/Domain/ValueObject/Configuration/Adjustment.php index a08175f0ed2..876a5055514 100644 --- a/Neos.Media/Classes/Domain/ValueObject/Configuration/Adjustment.php +++ b/Neos.Media/Classes/Domain/ValueObject/Configuration/Adjustment.php @@ -43,15 +43,15 @@ public function __construct(string $identifier, string $type) /** * @param string $identifier * @param array $configuration - * @return Adjustment + * @return self */ - public static function fromConfiguration(string $identifier, array $configuration): Adjustment + public static function fromConfiguration(string $identifier, array $configuration): self { if (!isset($configuration['type'])) { throw new \InvalidArgumentException(sprintf('Missing type in configuration for adjustment "%s".', $identifier), 1549276551); } - $adjustment = new static( + $adjustment = new self( $identifier, $configuration['type'] ); diff --git a/Neos.Media/Classes/Domain/ValueObject/Configuration/AspectRatio.php b/Neos.Media/Classes/Domain/ValueObject/Configuration/AspectRatio.php index 307c8510f62..af7c7a3ea4d 100644 --- a/Neos.Media/Classes/Domain/ValueObject/Configuration/AspectRatio.php +++ b/Neos.Media/Classes/Domain/ValueObject/Configuration/AspectRatio.php @@ -53,7 +53,7 @@ public static function fromString(string $ratio): self throw new \InvalidArgumentException(sprintf('Invalid aspect ratio specified ("%s").', $ratio), 1552641724); } [$width, $height] = explode(':', $ratio); - return new static((int)$width, (int)$height); + return new self((int)$width, (int)$height); } /** diff --git a/Neos.Media/Classes/Domain/ValueObject/Configuration/Variant.php b/Neos.Media/Classes/Domain/ValueObject/Configuration/Variant.php index e70247038cf..a72e8a3ef70 100644 --- a/Neos.Media/Classes/Domain/ValueObject/Configuration/Variant.php +++ b/Neos.Media/Classes/Domain/ValueObject/Configuration/Variant.php @@ -13,6 +13,8 @@ * source code. */ +use Neos\Flow\Annotations as Flow; + final class Variant { /** @@ -39,6 +41,7 @@ final class Variant * @param string $identifier * @param Label $label * @param string $description + * @Flow\Autowiring(false) */ public function __construct(string $identifier, Label $label, string $description = null) { @@ -52,9 +55,9 @@ public function __construct(string $identifier, Label $label, string $descriptio * @param array $configuration * @return Variant */ - public static function fromConfiguration(string $identifier, array $configuration): Variant + public static function fromConfiguration(string $identifier, array $configuration): self { - $variant = new static( + $variant = new self( $identifier, new Label($configuration['label']), $configuration['description'] ?? null diff --git a/Neos.Media/Classes/Domain/ValueObject/Configuration/VariantPreset.php b/Neos.Media/Classes/Domain/ValueObject/Configuration/VariantPreset.php index fe9a7a7181c..683b2b271bf 100644 --- a/Neos.Media/Classes/Domain/ValueObject/Configuration/VariantPreset.php +++ b/Neos.Media/Classes/Domain/ValueObject/Configuration/VariantPreset.php @@ -45,9 +45,9 @@ public function __construct(Label $label) * @param array $configuration * @return VariantPreset */ - public static function fromConfiguration(array $configuration): VariantPreset + public static function fromConfiguration(array $configuration): self { - $variantPreset = new static( + $variantPreset = new self( new Label($configuration['label']) ); if (!isset($configuration['mediaTypePatterns'])) { diff --git a/Neos.Media/Classes/Imagine/Box.php b/Neos.Media/Classes/Imagine/Box.php index 154d0443741..61d3ff0e2ae 100644 --- a/Neos.Media/Classes/Imagine/Box.php +++ b/Neos.Media/Classes/Imagine/Box.php @@ -89,7 +89,7 @@ public function increase($size) */ public function contains(BoxInterface $box, PointInterface $start = null) { - $start = $start ? $start : new Point(0, 0); + $start ??= new Point(0, 0); return $start->in($this) && $this->width >= $box->getWidth() + $start->getX() && $this->height >= $box->getHeight() + $start->getY(); } diff --git a/Neos.Media/Classes/TypeConverter/AssetInterfaceConverter.php b/Neos.Media/Classes/TypeConverter/AssetInterfaceConverter.php index 323d5b16b74..a0d48fc1340 100644 --- a/Neos.Media/Classes/TypeConverter/AssetInterfaceConverter.php +++ b/Neos.Media/Classes/TypeConverter/AssetInterfaceConverter.php @@ -43,7 +43,7 @@ class AssetInterfaceConverter extends PersistentObjectConverter /** * @var integer */ - const CONFIGURATION_ONE_PER_RESOURCE = 'onePerResource'; + public const CONFIGURATION_ONE_PER_RESOURCE = 'onePerResource'; /** * @var array diff --git a/Neos.Neos/Classes/Command/CrCommandController.php b/Neos.Neos/Classes/Command/CrCommandController.php index fdf13fa8db9..0ba3ae6dd85 100644 --- a/Neos.Neos/Classes/Command/CrCommandController.php +++ b/Neos.Neos/Classes/Command/CrCommandController.php @@ -81,7 +81,7 @@ public function exportCommand(string $path, string $contentRepository = 'default * @param bool $verbose If set, all notices will be rendered * @throws \Exception */ - public function importCommand(string $path, string $contentRepository = 'default', bool $verbose = false,): void + public function importCommand(string $path, string $contentRepository = 'default', bool $verbose = false): void { $filesystem = new Filesystem(new LocalFilesystemAdapter($path)); diff --git a/Neos.Neos/Classes/Command/SiteCommandController.php b/Neos.Neos/Classes/Command/SiteCommandController.php index 14354cd743b..888c0923ed3 100644 --- a/Neos.Neos/Classes/Command/SiteCommandController.php +++ b/Neos.Neos/Classes/Command/SiteCommandController.php @@ -158,12 +158,12 @@ public function listCommand() foreach ($sites as $site) { /** @var Site $site */ - array_push($availableSites, [ + $availableSites[] = [ 'name' => $site->getName(), 'nodeName' => $site->getNodeName()->value, 'siteResourcesPackageKey' => $site->getSiteResourcesPackageKey(), 'status' => ($site->getState() === SITE::STATE_ONLINE) ? 'online' : 'offline' - ]); + ]; if (strlen($site->getName()) > $longestSiteName) { $longestSiteName = strlen($site->getName()); } diff --git a/Neos.Neos/Classes/Controller/Backend/ModuleController.php b/Neos.Neos/Classes/Controller/Backend/ModuleController.php index b0e913e5c58..fdf66a9c1bb 100644 --- a/Neos.Neos/Classes/Controller/Backend/ModuleController.php +++ b/Neos.Neos/Classes/Controller/Backend/ModuleController.php @@ -94,7 +94,7 @@ public function indexAction(array $module) $moduleBreadcrumb = []; $path = []; foreach ($modules as $moduleIdentifier) { - array_push($path, $moduleIdentifier); + $path[] = $moduleIdentifier; $config = Arrays::getValueByPath($this->settings['modules'], implode('.submodules.', $path)); $moduleBreadcrumb[implode('/', $path)] = $config; } diff --git a/Neos.Neos/Classes/Controller/Module/Administration/UsersController.php b/Neos.Neos/Classes/Controller/Module/Administration/UsersController.php index c91ceee1e55..5239eb90ce5 100644 --- a/Neos.Neos/Classes/Controller/Module/Administration/UsersController.php +++ b/Neos.Neos/Classes/Controller/Module/Administration/UsersController.php @@ -224,7 +224,7 @@ public function editAction(User $user): void { if (!$this->isEditingAllowed($user)) { $this->addFlashMessage( - $this->translator->translateById('users.userEditingDenied.editing.body', [htmlspecialchars($user->getName())], null, null, 'Modules', 'Neos.Neos'), + $this->translator->translateById('users.userEditingDenied.editing.body', [htmlspecialchars((string)$user->getName())], null, null, 'Modules', 'Neos.Neos'), $this->translator->translateById('users.userEditingDenied.editing.‚title', [], null, null, 'Modules', 'Neos.Neos'), Message::SEVERITY_ERROR, [], @@ -479,7 +479,6 @@ public function deleteElectronicAddressAction(User $user, ElectronicAddress $ele $user->removeElectronicAddress($electronicAddress); $this->userService->updateUser($user); - /** @var PersonName $personName */ $personName = $user->getName(); $name = $personName ? $personName->getFullName() : ''; $this->addFlashMessage( diff --git a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php index 2e0ce705dd3..91191a38306 100644 --- a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php +++ b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php @@ -711,7 +711,7 @@ protected function computeChangesCount(Workspace $selectedWorkspace, ContentRepo $changesCount['new']++; } else { $changesCount['changed']++; - }; + } $changesCount['total']++; } } diff --git a/Neos.Neos/Classes/Controller/Service/AssetProxiesController.php b/Neos.Neos/Classes/Controller/Service/AssetProxiesController.php index e3043d7bc7e..71019e4c8a4 100644 --- a/Neos.Neos/Classes/Controller/Service/AssetProxiesController.php +++ b/Neos.Neos/Classes/Controller/Service/AssetProxiesController.php @@ -85,7 +85,7 @@ class AssetProxiesController extends ActionController * @param ViewInterface $view * @return void */ - public function initializeView(ViewInterface $view) + protected function initializeView(ViewInterface $view) { $view->assign('asyncThumbnails', $this->asyncThumbnails); } diff --git a/Neos.Neos/Classes/Controller/Service/AssetsController.php b/Neos.Neos/Classes/Controller/Service/AssetsController.php index 7bd163e06cd..08698889952 100644 --- a/Neos.Neos/Classes/Controller/Service/AssetsController.php +++ b/Neos.Neos/Classes/Controller/Service/AssetsController.php @@ -74,7 +74,7 @@ class AssetsController extends ActionController * @param ViewInterface $view * @return void */ - public function initializeView(ViewInterface $view) + protected function initializeView(ViewInterface $view) { $view->assign('asyncThumbnails', $this->asyncThumbnails); } diff --git a/Neos.Neos/Classes/FrontendRouting/NodeUriBuilder.php b/Neos.Neos/Classes/FrontendRouting/NodeUriBuilder.php index 7e80a7633e0..a3f2433a824 100644 --- a/Neos.Neos/Classes/FrontendRouting/NodeUriBuilder.php +++ b/Neos.Neos/Classes/FrontendRouting/NodeUriBuilder.php @@ -15,6 +15,7 @@ namespace Neos\Neos\FrontendRouting; use GuzzleHttp\Psr7\Uri; +use Neos\Flow\Annotations as Flow; use Neos\Flow\Http\Exception as HttpException; use Neos\Flow\Mvc\ActionRequest; use Neos\Flow\Mvc\Exception\NoMatchingRouteException; @@ -31,22 +32,25 @@ final class NodeUriBuilder { private UriBuilder $uriBuilder; - protected function __construct(UriBuilder $uriBuilder) + /** + * @Flow\Autowiring(false) + */ + private function __construct(UriBuilder $uriBuilder) { $this->uriBuilder = $uriBuilder; } - public static function fromRequest(ActionRequest $request): static + public static function fromRequest(ActionRequest $request): self { $uriBuilder = new UriBuilder(); $uriBuilder->setRequest($request); - return new static($uriBuilder); + return new self($uriBuilder); } - public static function fromUriBuilder(UriBuilder $uriBuilder): static + public static function fromUriBuilder(UriBuilder $uriBuilder): self { - return new static($uriBuilder); + return new self($uriBuilder); } /** diff --git a/Neos.Neos/Classes/FrontendRouting/Projection/DocumentNodeInfos.php b/Neos.Neos/Classes/FrontendRouting/Projection/DocumentNodeInfos.php index a53401de5b3..047f1fa709d 100644 --- a/Neos.Neos/Classes/FrontendRouting/Projection/DocumentNodeInfos.php +++ b/Neos.Neos/Classes/FrontendRouting/Projection/DocumentNodeInfos.php @@ -29,11 +29,11 @@ private function __construct( /** * @param array $documentNodeInfos - * @return static + * @return self */ - public static function create(array $documentNodeInfos): static + public static function create(array $documentNodeInfos): self { - return new static($documentNodeInfos); + return new self($documentNodeInfos); } public function getIterator(): \Traversable diff --git a/Neos.Neos/Classes/Fusion/DimensionsMenuItemsImplementation.php b/Neos.Neos/Classes/Fusion/DimensionsMenuItemsImplementation.php index 97fff10f134..2671c2ef3a2 100644 --- a/Neos.Neos/Classes/Fusion/DimensionsMenuItemsImplementation.php +++ b/Neos.Neos/Classes/Fusion/DimensionsMenuItemsImplementation.php @@ -210,14 +210,12 @@ protected function determineLabel(?Node $variant = null, array $metadata = []): { if ($this->getContentDimensionIdentifierToLimitTo()) { return $metadata[$this->getContentDimensionIdentifierToLimitTo()->value]['label'] ?: ''; + } elseif ($variant) { + return $variant->getLabel() ?: ''; } else { - if ($variant) { - return $variant->getLabel() ?: ''; - } else { - return array_reduce($metadata, function ($carry, $item) { - return $carry . (empty($carry) ? '' : '-') . $item['label']; - }, ''); - } + return array_reduce($metadata, function ($carry, $item) { + return $carry . (empty($carry) ? '' : '-') . $item['label']; + }, ''); } } diff --git a/Neos.Neos/Classes/Service/Controller/AbstractServiceController.php b/Neos.Neos/Classes/Service/Controller/AbstractServiceController.php index eacebb5d5bd..f31cc00b114 100644 --- a/Neos.Neos/Classes/Service/Controller/AbstractServiceController.php +++ b/Neos.Neos/Classes/Service/Controller/AbstractServiceController.php @@ -54,7 +54,7 @@ abstract class AbstractServiceController extends ActionController * * @throws StopActionException */ - public function errorAction(): never + protected function errorAction(): never { if ($this->arguments->getValidationResults()->hasErrors()) { $errors = []; diff --git a/composer.json b/composer.json index 5bce829ccdb..93e2955b2a6 100644 --- a/composer.json +++ b/composer.json @@ -101,6 +101,7 @@ "@lint:phpcs-psr12 --exclude=Generic.Files.LineLength,PSR1.Files.SideEffects" ], "lint:phpstan": "../../bin/phpstan analyse", + "lint:phpstan-generate-baseline": "../../bin/phpstan analyse --generate-baseline", "lint:distributionintegrity": "[ -d 'Neos.ContentRepository' ] && { echo 'Package Neos.ContentRepository should not exist.' 1>&2; exit 1; } || exit 0;", "lint": [ "@lint:phpcs", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e18a7ab8349..19ba0c03157 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -145,11 +145,6 @@ parameters: count: 1 path: Neos.Neos/Classes/Controller/Frontend/NodeController.php - - - message: "#^Call to method getFullName\\(\\) on an unknown class Neos\\\\Neos\\\\Controller\\\\Module\\\\Administration\\\\PersonName\\.$#" - count: 1 - path: Neos.Neos/Classes/Controller/Module/Administration/UsersController.php - - message: "#^Cannot call method getName\\(\\) on Neos\\\\Neos\\\\Domain\\\\Model\\\\User\\|null\\.$#" count: 2 @@ -185,21 +180,11 @@ parameters: 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 \\$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