fractalzombie /
frzb-request-mapper
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | namespace FRZB\Component\RequestMapper\PropertyMapper; |
||||
| 6 | |||||
| 7 | use Fp\Collections\ArrayList; |
||||
| 8 | use FRZB\Component\DependencyInjection\Attribute\AsService; |
||||
| 9 | use FRZB\Component\RequestMapper\Exception\PropertyMapperLocatorException; |
||||
| 10 | use FRZB\Component\RequestMapper\PropertyMapper\Mapper\PropertyMapperInterface as PropertyMapper; |
||||
| 11 | use Symfony\Component\DependencyInjection\Attribute\TaggedIterator; |
||||
| 12 | |||||
| 13 | #[AsService] |
||||
| 14 | class PropertyMapperLocator implements PropertyMapperLocatorInterface |
||||
| 15 | { |
||||
| 16 | /** @var ArrayList<PropertyMapper> */ |
||||
| 17 | private readonly ArrayList $mappers; |
||||
| 18 | |||||
| 19 | public function __construct( |
||||
| 20 | #[TaggedIterator(PropertyMapper::class)] iterable $mappers, |
||||
| 21 | ) { |
||||
| 22 | $this->mappers = ArrayList::collect($mappers); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 23 | } |
||||
| 24 | |||||
| 25 | public function get(\ReflectionProperty $property): PropertyMapper |
||||
| 26 | { |
||||
| 27 | return $this->mappers |
||||
| 28 | ->first(fn (PropertyMapper $pm) => $pm->canMap($property)) |
||||
| 29 | ->getOrThrow(PropertyMapperLocatorException::notFound($property)) |
||||
|
0 ignored issues
–
show
It seems like
FRZB\Component\RequestMa...on::notFound($property) can also be of type FRZB\Component\RequestMa...yMapperLocatorException; however, parameter $fallback of Fp\Functional\Option\Option::getOrThrow() does only seem to accept callable, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 30 | ; |
||||
| 31 | } |
||||
| 32 | } |
||||
| 33 |