1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-10 23:18:40 +01:00
psalm/src/Psalm/Internal/ReferenceConstraint.php

38 lines
721 B
PHP
Raw Normal View History

<?php
2018-11-06 03:57:36 +01:00
namespace Psalm\Internal;
2021-12-13 04:45:57 +01:00
use Psalm\Type\Atomic\TFloat;
use Psalm\Type\Atomic\TInt;
use Psalm\Type\Atomic\TString;
2021-12-13 16:28:14 +01:00
use Psalm\Type\Union;
/**
* @internal
*/
class ReferenceConstraint
{
2022-12-14 01:52:54 +01:00
public ?Union $type = null;
2021-12-13 16:28:14 +01:00
public function __construct(?Union $type = null)
{
if ($type) {
2022-10-03 10:45:36 +02:00
$type = $type->getBuilder();
2022-10-03 10:45:36 +02:00
if ($type->getLiteralStrings()) {
$type->addType(new TString);
}
2022-10-03 10:45:36 +02:00
if ($type->getLiteralInts()) {
$type->addType(new TInt);
}
2022-10-03 10:45:36 +02:00
if ($type->getLiteralFloats()) {
$type->addType(new TFloat);
}
2022-10-03 10:45:36 +02:00
$this->type = $type->freeze();
}
}
}