Skip to content

Commit

Permalink
Bump psalm to level 2
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu authored and jordisala1991 committed Mar 18, 2023
1 parent da1c059 commit fd4a79a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 13 deletions.
12 changes: 11 additions & 1 deletion psalm.xml
@@ -1,12 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" errorLevel="3" findUnusedPsalmSuppress="true" findUnusedBaselineEntry="true" findUnusedCode="false" resolveFromConfigFile="true" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" errorLevel="2" findUnusedPsalmSuppress="true" findUnusedBaselineEntry="true" findUnusedCode="false" resolveFromConfigFile="true" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
<projectFiles>
<directory name="src"/>
<directory name="tests"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>
<issueHandlers>
<!-- Psalm equivalent of PHPStan config `treatPhpDocTypesAsCertain: false` -->
<DocblockTypeContradiction errorLevel="suppress"/>
<RedundantConditionGivenDocblockType errorLevel="suppress"/>
<DeprecatedClass>
<errorLevel type="suppress">
<referencedClass name="Sonata\Form\Type\EqualType"/>
</errorLevel>
</DeprecatedClass>
</issueHandlers>
<plugins>
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
Expand Down
Expand Up @@ -62,6 +62,8 @@ public function load(array $configs, ContainerBuilder $container): void
/**
* NEXT_MAJOR: Remove this method.
*
* @psalm-suppress DeprecatedClass
*
* @param mixed[] $config
*/
private function configureSerializerFormats(array $config): void
Expand Down
16 changes: 12 additions & 4 deletions src/EventListener/ResizeFormListener.php
Expand Up @@ -68,9 +68,12 @@ public function preSetData(FormEvent $event): void
}

// First remove all rows except for the prototype row
// Type cast to string, because Symfony form can returns integer keys
// Type cast to string, because Symfony form can return integer keys
/**
* @psalm-suppress RedundantCastGivenDocblockType -- Remove this and the casting when dropping support of < Symfony 6.2
*/
foreach ($form as $name => $child) {
// @phpstan-ignore-next-line
// @phpstan-ignore-next-line -- Remove this and the casting when dropping support of < Symfony 6.2
$form->remove((string) $name);
}

Expand Down Expand Up @@ -108,9 +111,12 @@ public function preSubmit(FormEvent $event): void
}

// Remove all empty rows except for the prototype row
// Type cast to string, because Symfony form can returns integer keys
// Type cast to string, because Symfony form can return integer keys
/**
* @psalm-suppress RedundantCastGivenDocblockType -- Remove this and the casting when dropping support of < Symfony 6.2
*/
foreach ($form as $name => $child) {
// @phpstan-ignore-next-line
// @phpstan-ignore-next-line -- Remove this and the casting when dropping support of < Symfony 6.2
$form->remove((string) $name);
}

Expand Down Expand Up @@ -140,6 +146,8 @@ public function preSubmit(FormEvent $event): void
}

/**
* @psalm-suppress PossibleRawObjectIteration -- https://github.com/vimeo/psalm/issues/9489
*
* @throws UnexpectedTypeException
*/
public function onSubmit(FormEvent $event): void
Expand Down
2 changes: 2 additions & 0 deletions src/Serializer/BaseSerializerHandler.php
Expand Up @@ -23,6 +23,8 @@
/**
* NEXT_MAJOR: Remove this class.
*
* @psalm-suppress DeprecatedInterface
*
* @deprecated since sonata-project/form-extensions version 1.13 and will be removed in 2.0.
*
* @author Sylvain Deloux <sylvain.deloux@ekino.com>
Expand Down
5 changes: 1 addition & 4 deletions src/Type/BasePickerType.php
Expand Up @@ -80,10 +80,7 @@ public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setNormalizer(
'format',
/**
* @param int|string $format
*/
function (Options $options, $format): string {
function (Options $options, int|string $format): string {
if (isset($options['date_format']) && \is_string($options['date_format'])) {
return $options['date_format'];
}
Expand Down
5 changes: 1 addition & 4 deletions src/Validator/Constraints/InlineConstraint.php
Expand Up @@ -108,10 +108,7 @@ public function getRequiredOptions(): array
];
}

/**
* @return string|callable
*/
public function getMethod()
public function getMethod(): string|callable
{
return $this->method;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Validator/ErrorElement.php
Expand Up @@ -179,6 +179,8 @@ public function getSubject()
}

/**
* @psalm-suppress RedundantCastGivenDocblockType
*
* @param string|array{0?:string, 1?:array<string, mixed>, 2?:mixed} $message
* @param array<string, mixed> $parameters
*/
Expand Down Expand Up @@ -247,6 +249,8 @@ private function getValue()
}

/**
* @psalm-suppress UnsafeInstantiation -- it is supposed that Constraint constructor is not going to change
*
* @param array<string, mixed> $options
*
* @throws \RuntimeException
Expand Down

0 comments on commit fd4a79a

Please sign in to comment.