Skip to content

checkExplicitMixed - hardcoded functions in NodeScopeResolver like array_map and array_filter expect wrong callable #5609

@ondrejmirtes

Description

@ondrejmirtes

Bug report

Code like this:

	/**
	 * @return Entity[]
	 */
	public function getSavableEntities() : array{
		return array_filter($this->entities, function(Entity $entity) : bool{ return $entity->canSaveWithChunk() and !$entity->isClosed(); });
	}

fails with:

 ------ ----------------------------------------------------------------------------------------------
  Line   src/pocketmine/level/format/Chunk.php
 ------ ----------------------------------------------------------------------------------------------
  644    Parameter #2 $callback of function array_filter expects (callable(mixed, mixed): bool)|null,
         Closure(pocketmine\entity\Entity): bool given.
 ------ ----------------------------------------------------------------------------------------------

Because the reflection layer is unaware of the "genericness".

Code snippet that reproduces the problem

checkExplicitMixed not yet supported on phpstan.org

Expected output

No errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions