Skip to content

Commit

Permalink
Upgrade psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
hlecorche committed Nov 18, 2024
1 parent c3551f1 commit 077014d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"symfony/panther": "^2.0.1",
"symfony/webpack-encore-bundle": "^1.7.3|^2.1.1",
"symfony/yaml": "^6.4|^7.1",
"vimeo/psalm": "^4.22"
"vimeo/psalm": "^5.0"
},
"autoload": {
"psr-4": { "Ecommit\\CrudBundle\\": "src/" }
Expand Down
14 changes: 14 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,19 @@
<referencedClass name="UnitEnum"/>
</errorLevel>
</UndefinedDocblockClass>
<MissingTemplateParam>
<errorLevel type="suppress">
<!-- DataTransformer to be rewritten -->
<file name="src/Form/DataTransformer/Entity/AbstractEntityTransformer.php" />
<file name="src/Crud/CrudConfig.php" />
</errorLevel>
</MissingTemplateParam>
<UndefinedClass>
<errorLevel type="suppress">
<!-- Doctrine ORM v2 support -->
<referencedClass name="Doctrine\ORM\Mapping\ClassMetadataInfo"/>
<file name="src/EventListener/MappingEntities.php" />
</errorLevel>
</UndefinedClass>
</issueHandlers>
</psalm>
8 changes: 3 additions & 5 deletions src/Crud/Crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function __construct(array $options, protected ContainerInterface $contai
throw new \Exception('A column must be an array or a CrudColum instance.');
}
if (\array_key_exists($column->getId(), $columns)) {
throw new \Exception(\sprintf('The column "column1" already exists.', $column->getId()));
throw new \Exception(\sprintf('The column "%s" already exists.', $column->getId()));
}
$columns[$column->getId()] = $column;
}
Expand All @@ -133,7 +133,7 @@ public function __construct(array $options, protected ContainerInterface $contai
throw new \Exception('A column must be an array or a CrudColum instance.');
}
if (\array_key_exists($column->getId(), $columns)) {
throw new \Exception(\sprintf('The column "column1" already exists.', $column->getId()));
throw new \Exception(\sprintf('The column "%s" already exists.', $column->getId()));
}
$columns[$column->getId()] = $column;
}
Expand Down Expand Up @@ -186,12 +186,10 @@ public function __construct(array $options, protected ContainerInterface $contai
// Check duplicates in columns / vitual columns
$duplicates = array_intersect_key($this->options['columns'], $this->options['virtual_columns']);
if (\count($duplicates) > 0) {
throw new \Exception(\sprintf('The column "column1" already exists.', array_keys($duplicates)[0]));
throw new \Exception(\sprintf('The column "%s" already exists.', array_keys($duplicates)[0]));
}

$this->init();

return $this;
}

protected function init(): void
Expand Down
2 changes: 1 addition & 1 deletion src/Crud/SearchFormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function createFormBuilder(?string $type): void
$formOptions['validation_groups'] = $this->options['validation_groups'];
}

if ($type) {
if (null !== $type) {
$this->form = $formFactory->createBuilder($type, null, $formOptions);
} else {
$formName = \sprintf('crud_search_%s', $this->crud->getSessionName());
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Configuration implements ConfigurationInterface
/**
* @psalm-suppress PossiblyUndefinedMethod
* @psalm-suppress PossiblyNullReference
* @psalm-suppress UndefinedInterfaceMethod
*/
public function getConfigTreeBuilder(): TreeBuilder
{
Expand Down
4 changes: 2 additions & 2 deletions src/Form/Filter/TextFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public function updateQueryBuilder(mixed $queryBuilder, string $property, mixed
$queryBuilder->andWhere(\sprintf('%s = :%s', $options['alias_search'], $parameterName))
->setParameter($parameterName, $value);
} else {
$after = ($options['must_begin']) ? '' : '%';
$before = ($options['must_end']) ? '' : '%';
$after = (true === $options['must_begin']) ? '' : '%';
$before = (true === $options['must_end']) ? '' : '%';
$value = addcslashes($value, '%_');
$like = $after.$value.$before;
$queryBuilder->andWhere($queryBuilder->expr()->like($options['alias_search'], ':'.$parameterName))
Expand Down
5 changes: 5 additions & 0 deletions src/Twig/CrudExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,11 @@ protected function validateAjaxOptions(array $options, array $requiredOptions =
return $resolver->resolve($options);
}

/**
* @param array<string, string|bool|array<array-key, mixed>|null> $options
*
* @return array<string, string>
*/
protected function getAjaxAttributes(array $options): array
{
$attributes = [];
Expand Down

0 comments on commit 077014d

Please sign in to comment.