2017-02-23 06:25:28 +01:00
|
|
|
<?php
|
2021-12-15 04:58:32 +01:00
|
|
|
|
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;
|
2017-02-23 06:25:28 +01:00
|
|
|
|
2018-12-02 00:37:49 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2017-02-23 06:25:28 +01:00
|
|
|
class ReferenceConstraint
|
|
|
|
{
|
2021-12-13 16:28:14 +01:00
|
|
|
/** @var Union|null */
|
2017-02-23 06:25:28 +01:00
|
|
|
public $type;
|
|
|
|
|
2021-12-13 16:28:14 +01:00
|
|
|
public function __construct(?Union $type = null)
|
2017-02-23 06:25:28 +01:00
|
|
|
{
|
2018-05-18 17:02:50 +02:00
|
|
|
if ($type) {
|
|
|
|
$this->type = clone $type;
|
|
|
|
|
|
|
|
if ($this->type->getLiteralStrings()) {
|
2021-12-13 04:45:57 +01:00
|
|
|
$this->type->addType(new TString);
|
2018-05-18 17:02:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->type->getLiteralInts()) {
|
2021-12-13 04:45:57 +01:00
|
|
|
$this->type->addType(new TInt);
|
2018-05-18 17:02:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->type->getLiteralFloats()) {
|
2021-12-13 04:45:57 +01:00
|
|
|
$this->type->addType(new TFloat);
|
2018-05-18 17:02:50 +02:00
|
|
|
}
|
|
|
|
}
|
2017-02-23 06:25:28 +01:00
|
|
|
}
|
|
|
|
}
|