<?php
interface SomeSearch
{
/**
* @param array{alias?: string, id?: string} $criteria
*/
public function findOneMatching(array $criteria): ?object;
}
final class OrmSomeSearch implements SomeSearch
{
public function findOneById(string $id): ?\stdClass
{
return $this->findOneMatching(['id' => $id]);
}
#[\Override]
public function findOneMatching(array $criteria): ?\stdClass
{
if ([] === $criteria) {
return null;
}
foreach ($criteria as $field => $value) {
\assert(\is_string($field));
}
return new \stdClass();
}
}
Rector should skip this rule as the interface already declares a more narrow type.
Bug Report
Minimal PHP Code Causing Issue
See https://getrector.com/demo/e911c6c9-d5cc-4c8a-b3f4-24cd899a7a0e
Responsible rules
ClassMethodArrayDocblockParamFromLocalCallsRectorExpected Behavior
Rector should skip this rule as the interface already declares a more narrow type.