Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Aug 19, 2022
1 parent 925890e commit f8f434f
Show file tree
Hide file tree
Showing 22 changed files with 64 additions and 63 deletions.
3 changes: 2 additions & 1 deletion src/Admin/AbstractAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2411,7 +2411,8 @@ private function buildDatagrid(): ?DatagridInterface

$this->datagrid->getPager()->setMaxPageLinks($this->getMaxPageLinks());

$mapper = new DatagridMapper($this->getDatagridBuilder(), $this->datagrid, $this);
/** @psalm-suppress InvalidArgument https://github.com/vimeo/psalm/issues/8423 */
$mapper = new DatagridMapper($this->getDatagridBuilder(), $this->datagrid, $admin);

// build the datagrid filter
$this->configureDatagridFilters($mapper);
Expand Down
4 changes: 2 additions & 2 deletions src/Admin/AdminHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ public function getChildFormView(FormView $formView, string $elementId): ?FormVi
* Note:
* This code is ugly, but there is no better way of doing it.
*
* @return array{FieldDescriptionInterface|null, FormInterface}
*
* @throws \RuntimeException
* @throws \Exception
*
* @return array{FieldDescriptionInterface|null, FormInterface}
*
* @phpstan-template T of object
* @phpstan-param AdminInterface<T> $admin
*/
Expand Down
12 changes: 6 additions & 6 deletions src/Admin/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ public function hasAdminByClass(string $class): bool
* Returns an admin class by its Admin code
* ie : sonata.news.admin.post|sonata.news.admin.comment => return the child class of post.
*
* @throws AdminCodeNotFoundException
*
* @return AdminInterface<object>
*
* @throws AdminCodeNotFoundException
*/
public function getAdminByAdminCode(string $adminCode): AdminInterface
{
Expand Down Expand Up @@ -237,11 +237,11 @@ public function hasAdminByAdminCode(string $adminCode): bool
}

/**
* @return AdminInterface<object>
*
* @throws AdminClassNotFoundException if there is no admin for the field description target model
* @throws TooManyAdminClassException if there is too many admin for the field description target model
* @throws AdminCodeNotFoundException if the admin_code option is invalid
*
* @return AdminInterface<object>
*/
public function getAdminByFieldDescription(FieldDescriptionInterface $fieldDescription): AdminInterface
{
Expand All @@ -262,9 +262,9 @@ public function getAdminByFieldDescription(FieldDescriptionInterface $fieldDescr
/**
* Returns a new admin instance depends on the given code.
*
* @throws AdminCodeNotFoundException if the code is not found in admin pool
*
* @return AdminInterface<object>
*
* @throws AdminCodeNotFoundException if the code is not found in admin pool
*/
public function getInstance(string $id): AdminInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/Block/AdminPreviewBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public function configureSettings(OptionsResolver $resolver): void
}

/**
* @throws \InvalidArgumentException if the provided admin code is invalid
*
* @return AdminInterface<object>
*
* @throws \InvalidArgumentException if the provided admin code is invalid
*/
private function getAdmin(string $code): AdminInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/CRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1075,9 +1075,9 @@ protected function handleModelManagerException(\Exception $exception): void
/**
* NEXT_MAJOR: Add typehint.
*
* @throws ModelManagerThrowable
*
* @return string|null A custom error message to display in the flag bag instead of the generic one
*
* @throws ModelManagerThrowable
*/
protected function handleModelManagerThrowable(ModelManagerThrowable $exception)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Datagrid/DatagridMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public function getAdmin(): AdminInterface
* @param array<string, mixed> $filterOptions
* @param array<string, mixed> $fieldDescriptionOptions
*
* @throws \LogicException
*
* @return static
*
* @throws \LogicException
*
* @phpstan-param class-string|null $type
* @phpstan-param FieldDescriptionOptions $fieldDescriptionOptions
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Datagrid/ListMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ public function addIdentifier(string $name, ?string $type = null, array $fieldDe
/**
* @param array<string, mixed> $fieldDescriptionOptions
*
* @throws \LogicException
*
* @return static
*
* @throws \LogicException
*
* @phpstan-param FieldDescriptionOptions $fieldDescriptionOptions
*/
public function add(string $name, ?string $type = null, array $fieldDescriptionOptions = []): self
Expand Down
4 changes: 2 additions & 2 deletions src/FieldDescription/BaseFieldDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,9 @@ abstract protected function setAssociationMapping(array $associationMapping): vo
abstract protected function setParentAssociationMappings(array $parentAssociationMappings): void;

/**
* @throws NoValueException
*
* @return mixed
*
* @throws NoValueException
*/
final protected function getFieldValue(?object $object, string $fieldName)
{
Expand Down
16 changes: 8 additions & 8 deletions src/FieldDescription/FieldDescriptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ public function setParent(AdminInterface $parent): void;
/**
* Returns the parent Admin (only used in nested admin).
*
* @throws \LogicException
*
* @return AdminInterface<object>
*
* @throws \LogicException
*/
public function getParent(): AdminInterface;

Expand Down Expand Up @@ -186,9 +186,9 @@ public function setAssociationAdmin(AdminInterface $associationAdmin): void;
/**
* Returns the associated Admin instance (only used if the field is linked to an Admin).
*
* @throws \LogicException
*
* @return AdminInterface<object>
*
* @throws \LogicException
*/
public function getAssociationAdmin(): AdminInterface;

Expand Down Expand Up @@ -217,9 +217,9 @@ public function isIdentifier(): bool;
/**
* Returns the value linked to the description.
*
* @throws NoValueException if the value cannot be determined
*
* @return mixed
*
* @throws NoValueException if the value cannot be determined
*/
public function getValue(object $object);

Expand All @@ -232,9 +232,9 @@ public function getValue(object $object);
public function setAdmin(AdminInterface $admin): void;

/**
* @throws \LogicException
*
* @return AdminInterface<object>
*
* @throws \LogicException
*/
public function getAdmin(): AdminInterface;

Expand Down
8 changes: 4 additions & 4 deletions src/Filter/FilterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ public function getFieldName(): string;
public function getParentAssociationMappings(): array;

/**
* @throws \RuntimeException if the `field_mapping` option is not set
*
* @return array<string, mixed> field mapping
*
* @throws \RuntimeException if the `field_mapping` option is not set
*/
public function getFieldMapping(): array;

/**
* @throws \RuntimeException if the `association_mapping` option is not set
*
* @return array<string, mixed> association mapping
*
* @throws \RuntimeException if the `association_mapping` option is not set
*/
public function getAssociationMapping(): array;

Expand Down
8 changes: 4 additions & 4 deletions src/Form/DataTransformer/ModelToIdPropertyTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public function __construct(
/**
* @param int|string|array<int|string|array<string>>|null $value
*
* @throws \UnexpectedValueException
*
* @return Collection<int|string, object>|object|null
*
* @throws \UnexpectedValueException
*
* @psalm-param int|string|(array{_labels?: array<string>}&array<int|string>)|null $value
* @phpstan-param int|string|array<int|string|array<string>>|null $value
* @phpstan-return Collection<array-key, T>|T|null
Expand Down Expand Up @@ -118,10 +118,10 @@ public function reverseTransform($value)
/**
* @param object|array<object>|\Traversable<object>|null $value
*
* @throws \InvalidArgumentException
*
* @return array<string|int, int|string|array<string>>
*
* @throws \InvalidArgumentException
*
* @phpstan-param T|array<T>|\Traversable<T>|null $value
* @psalm-return array{_labels?: array<string>}&array<int|string>
* @phpstan-return array<int|string|array<string>>
Expand Down
4 changes: 2 additions & 2 deletions src/Form/DataTransformer/ModelsToArrayTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ public function transform($value): array
/**
* @param array<int|string>|null $value
*
* @throws UnexpectedTypeException
*
* @return Collection<int|string, object>|null
*
* @throws UnexpectedTypeException
*
* @phpstan-return Collection<array-key, T>|null
*/
public function reverseTransform($value)
Expand Down
12 changes: 6 additions & 6 deletions src/Mapper/BaseGroupedMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ abstract class BaseGroupedMapper implements MapperInterface
*
* @param array<string, mixed> $options
*
* @throws \LogicException
*
* @return static
*
* @throws \LogicException
*/
final public function with(string $name, array $options = []): self
{
Expand Down Expand Up @@ -190,9 +190,9 @@ final public function ifFalse(bool $bool): self
}

/**
* @throws \LogicException
*
* @return static
*
* @throws \LogicException
*/
final public function ifEnd(): self
{
Expand Down Expand Up @@ -220,9 +220,9 @@ final public function tab(string $name, array $options = []): self
/**
* Close the current group or tab.
*
* @throws \LogicException
*
* @return static
*
* @throws \LogicException
*/
final public function end(): self
{
Expand Down
4 changes: 2 additions & 2 deletions src/Request/AdminFetcherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
interface AdminFetcherInterface
{
/**
* @return AdminInterface<object>
*
* @throws \InvalidArgumentException if the admin code is not found in the request
* @throws AdminCodeNotFoundException if no admin was found for the admin code provided
*
* @return AdminInterface<object>
*/
public function get(Request $request): AdminInterface;
}
4 changes: 2 additions & 2 deletions src/Route/RouteCollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function get(string $name): Route;
public function remove(string $name): self;

/**
* @throws \InvalidArgumentException
*
* @return static
*
* @throws \InvalidArgumentException
*/
public function restore(string $name): self;

Expand Down
4 changes: 2 additions & 2 deletions src/Route/RoutesCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public function __construct(string $cacheFolder, bool $debug)
/**
* @param AdminInterface<object> $admin
*
* @throws \RuntimeException
*
* @return array<string, string>
*
* @throws \RuntimeException
*
* @phpstan-template T of object
* @phpstan-param AdminInterface<T> $admin
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Security/Handler/AclSecurityHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public function getObjectAcl(ObjectIdentityInterface $objectIdentity): ?MutableA
* @param \Traversable<ObjectIdentityInterface> $oids
* @param SecurityIdentityInterface[] $sids
*
* @throws \Exception
*
* @return \SplObjectStorage<ObjectIdentityInterface, MutableAclInterface> mapping the passed object identities to ACLs
*
* @throws \Exception
*/
public function findObjectAcls(\Traversable $oids, array $sids = []): \SplObjectStorage;

Expand Down
4 changes: 2 additions & 2 deletions src/Show/ShowMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public function getAdmin(): AdminInterface
}

/**
* @throws \LogicException
*
* @return static
*
* @throws \LogicException
*
* @phpstan-param FieldDescriptionOptions $fieldDescriptionOptions
*/
public function add(string $name, ?string $type = null, array $fieldDescriptionOptions = []): self
Expand Down
4 changes: 2 additions & 2 deletions src/Twig/Extension/RenderElementExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ public function renderViewElementCompare(
*
* @param mixed $element
*
* @throws \RuntimeException
*
* @return mixed
*
* @throws \RuntimeException
*/
public function renderRelationElement($element, FieldDescriptionInterface $fieldDescription)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Twig/RenderElementRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ public function renderViewElementCompare(
/**
* @param mixed $element
*
* @throws \RuntimeException
*
* @return mixed
*
* @throws \RuntimeException
*/
public function renderRelationElement($element, FieldDescriptionInterface $fieldDescription)
{
Expand Down Expand Up @@ -174,9 +174,9 @@ public function renderRelationElement($element, FieldDescriptionInterface $field
*
* @param object|mixed[] $listElement
*
* @throws \TypeError when $listElement is not an object or an array with an object on offset 0
*
* @return array{object, mixed} An array containing object and value
*
* @throws \TypeError when $listElement is not an object or an array with an object on offset 0
*/
private function getObjectAndValueFromListElement(
$listElement,
Expand Down
4 changes: 2 additions & 2 deletions src/Util/ObjectAclManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ abstract class ObjectAclManipulator implements ObjectAclManipulatorInterface
* @param AdminInterface<object> $admin
* @param \Traversable<ObjectIdentityInterface> $oids
*
* @throws \Exception
*
* @return array{int, int} [countAdded, countUpdated]
*
* @throws \Exception
*
* @phpstan-template T of object
* @phpstan-param AdminInterface<T> $admin
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Util/TraversableToCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ final class TraversableToCollection
*
* @param iterable<mixed, mixed> $value
*
* @throws \TypeError
*
* @return Collection<int|string, mixed>
*
* @throws \TypeError
*
* @phpstan-template T
* @phpstan-param iterable<mixed, T> $value
* @phpstan-return Collection<array-key, T>
Expand Down

0 comments on commit f8f434f

Please sign in to comment.