2017-02-23 06:25:28 +01:00
|
|
|
<?php
|
2018-11-06 03:57:36 +01:00
|
|
|
namespace Psalm\Internal;
|
|
|
|
|
|
|
|
use Psalm\Type;
|
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
|
|
|
|
{
|
2018-01-25 07:04:26 +01:00
|
|
|
/** @var Type\Union|null */
|
2017-02-23 06:25:28 +01:00
|
|
|
public $type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Type\Union $type
|
|
|
|
*/
|
2018-01-25 07:04:26 +01:00
|
|
|
public function __construct(Type\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()) {
|
|
|
|
$this->type->addType(new Type\Atomic\TString);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->type->getLiteralInts()) {
|
|
|
|
$this->type->addType(new Type\Atomic\TInt);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->type->getLiteralFloats()) {
|
|
|
|
$this->type->addType(new Type\Atomic\TFloat);
|
|
|
|
}
|
|
|
|
}
|
2017-02-23 06:25:28 +01:00
|
|
|
}
|
|
|
|
}
|