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
2022-10-03 10:45:36 +02:00

39 lines
734 B
PHP

<?php
namespace Psalm\Internal;
use Psalm\Type\Atomic\TFloat;
use Psalm\Type\Atomic\TInt;
use Psalm\Type\Atomic\TString;
use Psalm\Type\Union;
/**
* @internal
*/
class ReferenceConstraint
{
/** @var Union|null */
public $type;
public function __construct(?Union $type = null)
{
if ($type) {
$type = $type->getBuilder();
if ($type->getLiteralStrings()) {
$type->addType(new TString);
}
if ($type->getLiteralInts()) {
$type->addType(new TInt);
}
if ($type->getLiteralFloats()) {
$type->addType(new TFloat);
}
$this->type = $type->freeze();
}
}
}