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

36 lines
723 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
{
2021-12-13 16:28:14 +01:00
/** @var Union|null */
public $type;
2021-12-13 16:28:14 +01:00
public function __construct(?Union $type = null)
{
if ($type) {
$this->type = clone $type;
if ($this->type->getLiteralStrings()) {
2021-12-13 04:45:57 +01:00
$this->type->addType(new TString);
}
if ($this->type->getLiteralInts()) {
2021-12-13 04:45:57 +01:00
$this->type->addType(new TInt);
}
if ($this->type->getLiteralFloats()) {
2021-12-13 04:45:57 +01:00
$this->type->addType(new TFloat);
}
}
}
}