From c51d0d4c4c28870405fa5737e0dfe66398cdc275 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 17 Jan 2024 13:02:51 +0100 Subject: [PATCH] TASK: Backport phpstan level 2 to Flow 8.3 and ignore to be fixed things Flow 9 Pr https://github.com/neos/flow-development-collection/pull/3217 --- Neos.Eel/Classes/FlowQuery/OperationResolver.php | 2 +- Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php | 2 +- Neos.Flow/Classes/Cli/Response.php | 5 +++-- Neos.Flow/Classes/Command/ResourceCommandController.php | 1 + Neos.Flow/Classes/Package.php | 1 - .../Persistence/Aspect/PersistenceMagicAspect.php | 1 + Neos.Flow/Classes/Reflection/ReflectionService.php | 9 +++++---- Neos.Flow/Classes/ResourceManagement/Collection.php | 1 + .../ResourceManagement/Target/FileSystemTarget.php | 1 + .../Core/Parser/Interceptor/ResourceInterceptor.php | 2 +- Neos.FluidAdaptor/Classes/View/TemplatePaths.php | 1 + 11 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Neos.Eel/Classes/FlowQuery/OperationResolver.php b/Neos.Eel/Classes/FlowQuery/OperationResolver.php index c0bdd615ca..e8724193b1 100644 --- a/Neos.Eel/Classes/FlowQuery/OperationResolver.php +++ b/Neos.Eel/Classes/FlowQuery/OperationResolver.php @@ -73,7 +73,7 @@ public static function buildOperationsAndFinalOperationNames($objectManager) $reflectionService = $objectManager->get(ReflectionService::class); $operationClassNames = $reflectionService->getAllImplementationClassNamesForInterface(OperationInterface::class); - /** @var $operationClassName OperationInterface */ + /** @var OperationInterface $operationClassName */ foreach ($operationClassNames as $operationClassName) { $shortOperationName = $operationClassName::getShortName(); $operationPriority = $operationClassName::getPriority(); diff --git a/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php b/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php index 2ec30d93fc..58e2ac329f 100644 --- a/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php +++ b/Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php @@ -435,7 +435,7 @@ public function buildProxyClass(string $targetClassName, array &$aspectContainer $proxyClass->addInterfaces($introducedInterfaces); $proxyClass->addTraits($introducedTraits); - /** @var $propertyIntroduction PropertyIntroduction */ + /** @var PropertyIntroduction $propertyIntroduction */ foreach ($propertyIntroductions as $propertyIntroduction) { $propertyName = $propertyIntroduction->getPropertyName(); $declaringAspectClassName = $propertyIntroduction->getDeclaringAspectClassName(); diff --git a/Neos.Flow/Classes/Cli/Response.php b/Neos.Flow/Classes/Cli/Response.php index f4dc4888b8..5e44675549 100644 --- a/Neos.Flow/Classes/Cli/Response.php +++ b/Neos.Flow/Classes/Cli/Response.php @@ -47,12 +47,12 @@ class Response private $content = ''; /** - * @var + * @var boolean|int */ private $colorSupport; /** - * @var + * @var int */ private $outputFormat = self::OUTPUTFORMAT_STYLED; @@ -118,6 +118,7 @@ public function getContent(): string /** * Sets color support / styled output to yes, no or auto detection * + * @deprecated and will be removed https://github.com/neos/flow-development-collection/pull/3262 * @param boolean $colorSupport true, false or NULL (= autodetection) * @return void */ diff --git a/Neos.Flow/Classes/Command/ResourceCommandController.php b/Neos.Flow/Classes/Command/ResourceCommandController.php index f9d8c8eb93..156cf3e227 100644 --- a/Neos.Flow/Classes/Command/ResourceCommandController.php +++ b/Neos.Flow/Classes/Command/ResourceCommandController.php @@ -98,6 +98,7 @@ public function publishCommand(string $collection = null) /** @var CollectionInterface $collection */ $this->outputLine('Publishing resources of collection "%s"', [$collection->getName()]); $target = $collection->getTarget(); + /** @phpstan-ignore-next-line will be fixed via https://github.com/neos/flow-development-collection/pull/3229 */ $target->publishCollection($collection, function ($iteration) { $this->clearState($iteration); }); diff --git a/Neos.Flow/Classes/Package.php b/Neos.Flow/Classes/Package.php index 94405c7a34..b69f7dd552 100644 --- a/Neos.Flow/Classes/Package.php +++ b/Neos.Flow/Classes/Package.php @@ -73,7 +73,6 @@ public function boot(Core\Bootstrap $bootstrap) if (!$request instanceof Mvc\ActionRequest || SecurityHelper::hasSafeMethod($request->getHttpRequest()) !== true) { $bootstrap->getObjectManager()->get(Persistence\PersistenceManagerInterface::class)->persistAll(); } elseif (SecurityHelper::hasSafeMethod($request->getHttpRequest())) { - /** @phpstan-ignore-next-line the persistence manager interface doesn't specify this method */ $bootstrap->getObjectManager()->get(Persistence\PersistenceManagerInterface::class)->persistAllowedObjects(); } } diff --git a/Neos.Flow/Classes/Persistence/Aspect/PersistenceMagicAspect.php b/Neos.Flow/Classes/Persistence/Aspect/PersistenceMagicAspect.php index 7a3fcd467a..60c77bc3e1 100644 --- a/Neos.Flow/Classes/Persistence/Aspect/PersistenceMagicAspect.php +++ b/Neos.Flow/Classes/Persistence/Aspect/PersistenceMagicAspect.php @@ -153,6 +153,7 @@ public function generateValueHash(JoinPointInterface $joinPoint) */ public function cloneObject(JoinPointInterface $joinPoint) { + /** @phpstan-ignore-next-line will be removed with https://github.com/neos/flow-development-collection/pull/3223 */ $joinPoint->getProxy()->Flow_Persistence_clone = true; } } diff --git a/Neos.Flow/Classes/Reflection/ReflectionService.php b/Neos.Flow/Classes/Reflection/ReflectionService.php index 12d310a005..40d8a0ae30 100644 --- a/Neos.Flow/Classes/Reflection/ReflectionService.php +++ b/Neos.Flow/Classes/Reflection/ReflectionService.php @@ -248,6 +248,7 @@ public function setStatusCache(StringFrontend $cache) $this->statusCache = $cache; $backend = $this->statusCache->getBackend(); if (is_callable(['initializeObject', $backend])) { + /** @phpstan-ignore-next-line will be refactored with neos 9 */ $backend->initializeObject(); } } @@ -1282,12 +1283,10 @@ protected function reflectClass($className) $this->classReflectionData[$className][self::DATA_CLASS_FINAL] = true; } - /** @var $parentClass ClassReflection */ foreach ($this->getParentClasses($class) as $parentClass) { $this->addParentClass($className, $parentClass); } - /** @var $interface ClassReflection */ foreach ($class->getInterfaces() as $interface) { $this->addImplementedInterface($className, $interface); } @@ -1308,7 +1307,6 @@ protected function reflectClass($className) } } - /** @var $property PropertyReflection */ foreach ($class->getProperties() as $property) { $this->reflectClassProperty($className, $property); } @@ -1877,6 +1875,7 @@ protected function convertParameterReflectionToArray(ParameterReflection $parame $parameterInformation[self::DATA_PARAMETER_ALLOWS_NULL] = true; } + /** @var \ReflectionNamedType|\ReflectionUnionType|\ReflectionIntersectionType|null $parameterType */ $parameterType = $parameter->getType(); if ($parameterType !== null) { if ($parameterType instanceof \ReflectionUnionType) { @@ -1940,7 +1939,6 @@ static function (\ReflectionNamedType $type) { protected function forgetChangedClasses() { $frozenNamespaces = []; - /** @var $package Package */ foreach ($this->packageManager->getAvailablePackages() as $packageKey => $package) { if ($this->packageManager->isPackageFrozen($packageKey)) { $frozenNamespaces = array_merge($frozenNamespaces, $package->getNamespaces()); @@ -2259,7 +2257,9 @@ protected function saveProductionData() $this->reflectionDataRuntimeCache->set('__classNames', $classNames); $this->reflectionDataRuntimeCache->set('__annotatedClasses', $this->annotatedClasses); + /** @phpstan-ignore-next-line will be refactored with neos 9 */ $this->reflectionDataRuntimeCache->getBackend()->freeze(); + /** @phpstan-ignore-next-line will be refactored with neos 9 */ $this->classSchemataRuntimeCache->getBackend()->freeze(); $this->log(sprintf('Built and froze reflection runtime caches (%s classes).', count($this->classReflectionData)), LogLevel::INFO); @@ -2343,6 +2343,7 @@ protected function getPrecompiledReflectionStoragePath() */ protected function hasFrozenCacheInProduction() { + /** @phpstan-ignore-next-line will be refactored with neos 9 */ return $this->environment->getContext()->isProduction() && $this->reflectionDataRuntimeCache->getBackend()->isFrozen(); } } diff --git a/Neos.Flow/Classes/ResourceManagement/Collection.php b/Neos.Flow/Classes/ResourceManagement/Collection.php index 40ac1677a1..281e9ba1fe 100644 --- a/Neos.Flow/Classes/ResourceManagement/Collection.php +++ b/Neos.Flow/Classes/ResourceManagement/Collection.php @@ -164,6 +164,7 @@ public function getObjects(callable $callback = null) } } } else { + /** @phpstan-ignore-next-line will be fixed via https://github.com/neos/flow-development-collection/pull/3229 */ yield from $this->storage->getObjectsByCollection($this, $callback); } diff --git a/Neos.Flow/Classes/ResourceManagement/Target/FileSystemTarget.php b/Neos.Flow/Classes/ResourceManagement/Target/FileSystemTarget.php index 5541935707..af71858c29 100644 --- a/Neos.Flow/Classes/ResourceManagement/Target/FileSystemTarget.php +++ b/Neos.Flow/Classes/ResourceManagement/Target/FileSystemTarget.php @@ -197,6 +197,7 @@ public function publishCollection(CollectionInterface $collection, callable $cal { $storage = $collection->getStorage(); $this->checkAndRemovePackageSymlinks($storage); + /** @phpstan-ignore-next-line will be fixed via https://github.com/neos/flow-development-collection/pull/3229 */ foreach ($collection->getObjects($callback) as $object) { /** @var StorageObject $object */ $sourceStream = $object->getStream(); diff --git a/Neos.FluidAdaptor/Classes/Core/Parser/Interceptor/ResourceInterceptor.php b/Neos.FluidAdaptor/Classes/Core/Parser/Interceptor/ResourceInterceptor.php index 9a15de7ac1..7a357088dc 100644 --- a/Neos.FluidAdaptor/Classes/Core/Parser/Interceptor/ResourceInterceptor.php +++ b/Neos.FluidAdaptor/Classes/Core/Parser/Interceptor/ResourceInterceptor.php @@ -91,7 +91,7 @@ public function setDefaultPackageKey($defaultPackageKey) */ public function process(NodeInterface $node, $interceptorPosition, ParsingState $parsingState) { - /** @var $node TextNode */ + /** @var TextNode $node */ if (strpos($node->getText(), 'Public/') === false) { return $node; } diff --git a/Neos.FluidAdaptor/Classes/View/TemplatePaths.php b/Neos.FluidAdaptor/Classes/View/TemplatePaths.php index 49e690804a..141f8f6e32 100644 --- a/Neos.FluidAdaptor/Classes/View/TemplatePaths.php +++ b/Neos.FluidAdaptor/Classes/View/TemplatePaths.php @@ -367,6 +367,7 @@ protected function getPackagePrivateResourcesPath($packageKey) if (!$this->packageManager->isPackageAvailable($packageKey)) { return null; } + /** @phpstan-ignore-next-line this code will be dropped totally as its unused */ $packageResourcesPath = $this->packageManager->getPackage($packageKey)->getResourcesPath(); return Files::concatenatePaths([$packageResourcesPath, 'Private']);