Skip to content

EntityStorageInterface::loadByProperties is assumed to always be non-empty-array when it can be empty #902

@mglaman

Description

@mglaman

Bug report

I just got an error in PHPUnit w/ PHPStan for assertEmpty on a loadByProperties call:

 ------ ------------------------------------------------------------------------- 
  Line   docroot/modules/custom/mymodul/tests/src/Kernel/ApiInstallTest.php  
 ------ ------------------------------------------------------------------------- 
  32     Call to method PHPUnit\Framework\Assert::assertEmpty() with              
         non-empty-array<Drupal\Core\Entity\EntityInterface> will always          
         evaluate to false.                                                       
         🪪 method.impossibleType                                                 
 ------ ------------------------------------------------------------------------- 

Code snippet that reproduces the problem

$this->assertEmpty($consumer_storage->loadByProperties(['client_id' => 'default_consumer']));

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions