Skip to content

Commit 4c9f1b0

Browse files
committed
TASK: Raise PhpStan level for Flow.Validation to 8 and adjust breakiness
1 parent 6330bb6 commit 4c9f1b0

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

Neos.Flow/Classes/Validation/Validator/AbstractCompositeValidator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ function ($value) {
7979
$options
8080
);
8181
$this->validators = new \SplObjectStorage();
82+
$this->validatedInstancesContainer = new \SplObjectStorage();
8283
}
8384

8485
/**
@@ -113,9 +114,10 @@ public function addValidator(ValidatorInterface $validator)
113114
*
114115
* @param ValidatorInterface $validator The validator to remove
115116
* @throws NoSuchValidatorException
117+
* @return void
116118
* @api
117119
*/
118-
public function removeValidator(ValidatorInterface $validator): void
120+
public function removeValidator(ValidatorInterface $validator)
119121
{
120122
if (!$this->validators->contains($validator)) {
121123
throw new NoSuchValidatorException('Cannot remove validator because its not in the conjunction.', 1207020177);

Neos.Flow/Classes/Validation/Validator/GenericObjectValidator.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ protected function isValid($object)
8585
}
8686

8787
/**
88+
* @param object $object
8889
* @return boolean
8990
*/
90-
protected function isUninitializedProxy(object $object)
91+
protected function isUninitializedProxy($object)
9192
{
9293
return ($object instanceof DoctrineProxy && $object->__isInitialized() === false);
9394
}
@@ -163,7 +164,7 @@ protected function checkProperty($value, $validators)
163164
* @return void
164165
* @api
165166
*/
166-
public function addPropertyValidator(string $propertyName, ValidatorInterface $validator)
167+
public function addPropertyValidator($propertyName, ValidatorInterface $validator)
167168
{
168169
if (!isset($this->propertyValidators[$propertyName])) {
169170
/** @var \SplObjectStorage<ValidatorInterface,mixed> $storage */
@@ -179,16 +180,19 @@ public function addPropertyValidator(string $propertyName, ValidatorInterface $v
179180
* @param ?string $propertyName Name of the property to return validators for
180181
* @return ($propertyName is null ? array<string,\SplObjectStorage<ValidatorInterface,mixed>> : \SplObjectStorage<ValidatorInterface,mixed>)
181182
*/
182-
public function getPropertyValidators(?string $propertyName = null)
183+
public function getPropertyValidators($propertyName = null)
183184
{
184-
if ($propertyName !== null) {
185+
if ($propertyName === null) {
186+
return $this->propertyValidators;
187+
}
188+
if (is_string($propertyName)) {
185189
$propertyValidators = $this->propertyValidators[$propertyName] ?? null;
186-
if (!$propertyValidators) {
187-
/** @var \SplObjectStorage<ValidatorInterface,mixed> $propertyValidators */
188-
$propertyValidators = new \SplObjectStorage();
190+
if ($propertyValidators instanceof \SplObjectStorage) {
191+
return $propertyValidators;
189192
}
190-
return $propertyValidators;
191193
}
192-
return $this->propertyValidators;
194+
/** @var \SplObjectStorage<ValidatorInterface,mixed> $propertyValidators */
195+
$propertyValidators = new \SplObjectStorage();
196+
return $propertyValidators;
193197
}
194198
}

Neos.Flow/Classes/Validation/ValidatorResolver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ public function buildMethodArgumentsValidatorConjunctions($className, $methodNam
187187
}
188188

189189
if ($methodValidateAnnotations === null) {
190+
/** @var Flow\Validate[] $validateAnnotations */
190191
$validateAnnotations = $this->reflectionService->getMethodAnnotations($className, $methodName, Flow\Validate::class);
191192
$methodValidateAnnotations = array_map(function ($validateAnnotation) {
192193
return [
@@ -336,6 +337,7 @@ protected function buildBaseValidatorConjunction($indexKey, $targetClassName, ar
336337
$needsCollectionValidator = TypeHandling::isCollectionType($propertyTargetClassName);
337338
$needsObjectValidator = (!TypeHandling::isSimpleType($propertyTargetClassName) && $this->objectManager->isRegistered($propertyTargetClassName) && $this->objectManager->getScope($propertyTargetClassName) === Configuration::SCOPE_PROTOTYPE);
338339

340+
/** @var Flow\Validate[] $validateAnnotations */
339341
$validateAnnotations = $this->reflectionService->getPropertyAnnotations($targetClassName, $classPropertyName, Flow\Validate::class);
340342
foreach ($validateAnnotations as $validateAnnotation) {
341343
if ($validateAnnotation->type === null) {

phpstan.neon.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
parameters:
22
level: 8
33
paths:
4+
- Neos.Flow/Classes/SignalSlot
5+
- Neos.Flow/Classes/Utility
6+
- Neos.Flow/Classes/Validation
47
- Neos.Flow.Log/Classes
58
- Neos.FluidAdaptor/Classes
69
- Neos.Http.Factories/Classes

0 commit comments

Comments
 (0)