mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Small fixes
This commit is contained in:
parent
9dd8533806
commit
575fd1c55a
@ -5980,7 +5980,7 @@ return [
|
||||
'ImagickPixel::clear' => ['bool'],
|
||||
'ImagickPixel::clone' => ['void'],
|
||||
'ImagickPixel::destroy' => ['bool'],
|
||||
'ImagickPixel::getColor' => ['array{r: int|float, g: int|float, b: int|float, a: int|float}', 'normalized='=>'int'],
|
||||
'ImagickPixel::getColor' => ['array{r: int|float, g: int|float, b: int|float, a: int|float}', 'normalized='=>'0|1|2'],
|
||||
'ImagickPixel::getColorAsString' => ['string'],
|
||||
'ImagickPixel::getColorCount' => ['int'],
|
||||
'ImagickPixel::getColorQuantum' => ['mixed'],
|
||||
|
@ -3161,7 +3161,7 @@ return [
|
||||
'ImagickPixel::clear' => ['bool'],
|
||||
'ImagickPixel::clone' => ['void'],
|
||||
'ImagickPixel::destroy' => ['bool'],
|
||||
'ImagickPixel::getColor' => ['array{r: int|float, g: int|float, b: int|float, a: int|float}', 'normalized='=>'int'],
|
||||
'ImagickPixel::getColor' => ['array{r: int|float, g: int|float, b: int|float, a: int|float}', 'normalized='=>'0|1|2'],
|
||||
'ImagickPixel::getColorAsString' => ['string'],
|
||||
'ImagickPixel::getColorCount' => ['int'],
|
||||
'ImagickPixel::getColorQuantum' => ['mixed'],
|
||||
|
@ -8,6 +8,8 @@ use Psalm\Type\Atomic\TKeyedArray;
|
||||
use Psalm\Type\Atomic\TLiteralInt;
|
||||
use Psalm\Type\Union;
|
||||
|
||||
use function in_array;
|
||||
|
||||
class ImagickPixelColorReturnTypeProvider implements \Psalm\Plugin\EventHandler\MethodReturnTypeProviderInterface
|
||||
{
|
||||
public static function getClassLikeNames() : array
|
||||
@ -32,10 +34,10 @@ class ImagickPixelColorReturnTypeProvider implements \Psalm\Plugin\EventHandler\
|
||||
if (!$call_args) {
|
||||
$formats = [0 => true];
|
||||
} else {
|
||||
$normalized = $source->node_data->getType($call_args[0]->value);
|
||||
$normalized = $source->node_data->getType($call_args[0]->value) ?? Type::getMixed();
|
||||
$formats = [];
|
||||
foreach ($normalized->getAtomicTypes() as $t) {
|
||||
if ($t instanceof TLiteralInt) {
|
||||
if ($t instanceof TLiteralInt && in_array($t->value, [0, 1, 2], true)) {
|
||||
$formats[$t->value] = true;
|
||||
} else {
|
||||
$formats[0] = true;
|
||||
@ -76,6 +78,7 @@ class ImagickPixelColorReturnTypeProvider implements \Psalm\Plugin\EventHandler\
|
||||
]);
|
||||
}
|
||||
|
||||
/** @var non-empty-list<Psalm\Type\Union> $types */
|
||||
return Type::combineUnionTypeArray($types, $event->getSource()->getCodebase());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user