Skip to content

Entity query define non-negative-int for return type #909

@Chi-teck

Description

@Chi-teck
/**
 * @return non-negative-int
 */
public function count(): int {
  return $this->entityTypeManager
    ->getStorage('example')
    ->getQuery()
    ->accessCheck()
    ->count()
    ->execute();
}
Method Drupal\example\Repository\Example::count() should return int<0, max> but returns int.  
         🪪  return.type  

It's great that it managed to figure out the count query. But we can narrow down the type further since the result can never be negative.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions