Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix psalm issues #7355

Merged
merged 2 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"symfony/maker-bundle": "^1.25",
"symfony/phpunit-bridge": "^5.1.8",
"symfony/yaml": "^4.4 || ^5.1",
"vimeo/psalm": "^4.7.2"
"vimeo/psalm": "^4.9.2"
},
"suggest": {
"jms/translation-bundle": "Extract message keys from Admins",
Expand Down
24 changes: 24 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,36 @@ parameters:
count: 1
path: src/Form/FormMapper.php

-
# will be fixed in v4. Currently BC break
message: "#^Method Sonata\\\\AdminBundle\\\\FieldDescription\\\\FieldDescriptionInterface\\:\\:getLabel\\(\\) invoked with 1 parameter, 0 required\\.$#"
count: 1
path: src/Show/ShowMapper.php

-
# will be fixed in v4. Currently BC break
message: "#^Method Sonata\\\\AdminBundle\\\\Admin\\\\AdminInterface\\<T of object\\>\\:\\:getShowGroups\\(\\) invoked with 1 parameter, 0 required\\.$#"
count: 1
path: src/Show/ShowMapper.php

-
# will be fixed in v4. Currently BC break
message: "#^Method Sonata\\\\AdminBundle\\\\Admin\\\\AdminInterface\\<T of object\\>\\:\\:getShowTabs\\(\\) invoked with 1 parameter, 0 required\\.$#"
count: 1
path: src/Show/ShowMapper.php

-
# will be fixed in v4. Currently BC break
message: "#^Method Sonata\\\\AdminBundle\\\\Admin\\\\AdminInterface\\<T of object\\>\\:\\:getFormTabs\\(\\) invoked with 1 parameter, 0 required\\.$#"
count: 1
path: src/Form/FormMapper.php

-
# will be fixed in v4.
message: "#^Right side of && is always true\\.$#"
count: 1
path: src/Mapper/BaseGroupedMapper.php

-
# will be fixed in v4. Currently BC break
message: "#^Negated boolean expression is always false\\.$#"
Expand Down
8 changes: 8 additions & 0 deletions src/Admin/AdminExtensionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,29 @@ interface AdminExtensionInterface
{
/**
* @return void
*
* @phpstan-param FormMapper<T> $form
*/
public function configureFormFields(FormMapper $form);

/**
* @return void
*
* @phpstan-param ListMapper<T> $list
*/
public function configureListFields(ListMapper $list);

/**
* @return void
*
* @phpstan-param DatagridMapper<T> $filter
*/
public function configureDatagridFilters(DatagridMapper $filter);

/**
* @return void
*
* @phpstan-param ShowMapper<T> $show
*/
public function configureShowFields(ShowMapper $show);

Expand Down
1 change: 1 addition & 0 deletions src/Datagrid/DatagridMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*
* @phpstan-template T of object
* @phpstan-implements MapperInterface<T>
* @phpstan-extends BaseMapper<T>
*/
class DatagridMapper extends BaseMapper implements MapperInterface
{
Expand Down
1 change: 1 addition & 0 deletions src/Datagrid/ListMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*
* @phpstan-template T of object
* @phpstan-implements MapperInterface<T>
* @phpstan-extends BaseMapper<T>
*/
class ListMapper extends BaseMapper implements MapperInterface
{
Expand Down
1 change: 1 addition & 0 deletions src/Mapper/BaseGroupedMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*
* @phpstan-template T of object
* @phpstan-implements MapperInterface<T>
* @phpstan-extends BaseMapper<T>
*/
abstract class BaseGroupedMapper extends BaseMapper implements MapperInterface
{
Expand Down
9 changes: 9 additions & 0 deletions src/Mapper/BaseMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@
* This class is used to simulate the Form API.
*
* @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* @phpstan-template T of object
*/
abstract class BaseMapper
{
/**
* @var AdminInterface
* @phpstan-var AdminInterface<T>
*/
protected $admin;

Expand All @@ -35,6 +38,9 @@ abstract class BaseMapper
*/
protected $builder;

/**
* @phpstan-param AdminInterface<T> $admin
*/
public function __construct(BuilderInterface $builder, AdminInterface $admin)
{
@trigger_error(sprintf(
Expand All @@ -46,6 +52,9 @@ public function __construct(BuilderInterface $builder, AdminInterface $admin)
$this->admin = $admin;
}

/**
* @phpstan-return AdminInterface<T>
*/
public function getAdmin()
{
return $this->admin;
Expand Down
2 changes: 0 additions & 2 deletions src/Security/Handler/AclSecurityHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ public function getObjectAcl(ObjectIdentityInterface $objectIdentity)
{
try {
$acl = $this->aclProvider->findAcl($objectIdentity);
// todo - remove `assert` statement after https://github.com/phpstan/phpstan-symfony/pull/92 is released
\assert($acl instanceof MutableAclInterface);
} catch (AclNotFoundException $e) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Security/Handler/AclSecurityHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function getObjectAcl(ObjectIdentityInterface $objectIdentity);
*
* @throws \Exception
*
* @return \SplObjectStorage<ObjectIdentityInterface, SecurityIdentityInterface> mapping the passed object identities to ACLs
* @return \SplObjectStorage<ObjectIdentityInterface, MutableAclInterface> mapping the passed object identities to ACLs
*/
public function findObjectAcls(\Traversable $oids, array $sids = []);

Expand Down