Skip to content

Commit

Permalink
TASK: Backport phpstan level 2 to Flow 8.3 and ignore to be fixed things
Browse files Browse the repository at this point in the history
Flow 9 Pr neos#3217
  • Loading branch information
mhsdesign committed Jan 17, 2024
1 parent 10c08ff commit c51d0d4
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Neos.Eel/Classes/FlowQuery/OperationResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Neos.Flow/Classes/Aop/Builder/ProxyClassBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions Neos.Flow/Classes/Cli/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ class Response
private $content = '';

/**
* @var
* @var boolean|int
*/
private $colorSupport;

/**
* @var
* @var int
*/
private $outputFormat = self::OUTPUTFORMAT_STYLED;

Expand Down Expand Up @@ -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
*/
Expand Down
1 change: 1 addition & 0 deletions Neos.Flow/Classes/Command/ResourceCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
1 change: 0 additions & 1 deletion Neos.Flow/Classes/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
9 changes: 5 additions & 4 deletions Neos.Flow/Classes/Reflection/ReflectionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -1308,7 +1307,6 @@ protected function reflectClass($className)
}
}

/** @var $property PropertyReflection */
foreach ($class->getProperties() as $property) {
$this->reflectClassProperty($className, $property);
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
}
1 change: 1 addition & 0 deletions Neos.Flow/Classes/ResourceManagement/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions Neos.FluidAdaptor/Classes/View/TemplatePaths.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down

0 comments on commit c51d0d4

Please sign in to comment.