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
|
|
|
|
{
|
2022-12-14 01:52:54 +01:00
|
|
|
public ?Union $type = null;
|
2017-02-23 06:25:28 +01:00
|
|
|
|
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) {
|
2022-10-03 10:45:36 +02:00
|
|
|
$type = $type->getBuilder();
|
2018-05-18 17:02:50 +02:00
|
|
|
|
2022-10-03 10:45:36 +02:00
|
|
|
if ($type->getLiteralStrings()) {
|
|
|
|
$type->addType(new TString);
|
2018-05-18 17:02:50 +02:00
|
|
|
}
|
|
|
|
|
2022-10-03 10:45:36 +02:00
|
|
|
if ($type->getLiteralInts()) {
|
|
|
|
$type->addType(new TInt);
|
2018-05-18 17:02:50 +02:00
|
|
|
}
|
|
|
|
|
2022-10-03 10:45:36 +02:00
|
|
|
if ($type->getLiteralFloats()) {
|
|
|
|
$type->addType(new TFloat);
|
2018-05-18 17:02:50 +02:00
|
|
|
}
|
2022-10-03 10:45:36 +02:00
|
|
|
|
|
|
|
$this->type = $type->freeze();
|
2018-05-18 17:02:50 +02:00
|
|
|
}
|
2017-02-23 06:25:28 +01:00
|
|
|
}
|
|
|
|
}
|