2017-01-02 01:09:17 +01:00
|
|
|
<?php
|
|
|
|
namespace Psalm\Storage;
|
|
|
|
|
2017-01-27 07:40:22 +01:00
|
|
|
use Psalm\CodeLocation;
|
2018-11-06 03:57:36 +01:00
|
|
|
use Psalm\Internal\Analyzer\ClassLikeAnalyzer;
|
2019-07-05 22:24:00 +02:00
|
|
|
use Psalm\Type;
|
2017-01-02 01:09:17 +01:00
|
|
|
|
|
|
|
class PropertyStorage
|
|
|
|
{
|
2019-02-24 22:21:28 +01:00
|
|
|
use CustomMetadataTrait;
|
|
|
|
|
2017-01-02 01:09:17 +01:00
|
|
|
/**
|
2019-11-25 21:20:31 +01:00
|
|
|
* @var ?bool
|
2017-01-02 01:09:17 +01:00
|
|
|
*/
|
|
|
|
public $is_static;
|
|
|
|
|
|
|
|
/**
|
2020-10-05 15:50:32 +02:00
|
|
|
* @var ClassLikeAnalyzer::VISIBILITY_*
|
2017-01-02 01:09:17 +01:00
|
|
|
*/
|
2020-10-05 15:50:32 +02:00
|
|
|
public $visibility = 1;
|
2017-01-02 01:09:17 +01:00
|
|
|
|
2017-01-27 07:40:22 +01:00
|
|
|
/**
|
|
|
|
* @var CodeLocation|null
|
|
|
|
*/
|
|
|
|
public $location;
|
|
|
|
|
2017-03-02 04:27:52 +01:00
|
|
|
/**
|
|
|
|
* @var CodeLocation|null
|
2019-04-17 17:12:18 +02:00
|
|
|
*/
|
|
|
|
public $stmt_location;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var CodeLocation|null
|
2017-03-02 04:27:52 +01:00
|
|
|
*/
|
|
|
|
public $type_location;
|
|
|
|
|
2017-01-02 01:09:17 +01:00
|
|
|
/**
|
2019-01-11 23:21:50 +01:00
|
|
|
* @var CodeLocation|null
|
|
|
|
*/
|
|
|
|
public $signature_type_location;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Type\Union|null
|
2017-01-02 01:09:17 +01:00
|
|
|
*/
|
|
|
|
public $type;
|
2017-01-27 07:23:12 +01:00
|
|
|
|
2019-01-11 23:21:50 +01:00
|
|
|
/**
|
|
|
|
* @var Type\Union|null
|
|
|
|
*/
|
|
|
|
public $signature_type;
|
|
|
|
|
2017-04-15 05:09:34 +02:00
|
|
|
/**
|
|
|
|
* @var Type\Union|null
|
|
|
|
*/
|
|
|
|
public $suggested_type;
|
|
|
|
|
2017-01-27 07:23:12 +01:00
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
public $has_default = false;
|
2017-05-25 07:32:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
public $deprecated = false;
|
2018-01-11 05:29:18 +01:00
|
|
|
|
2019-08-11 22:01:37 +02:00
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
public $readonly = false;
|
|
|
|
|
2020-02-02 21:35:12 +01:00
|
|
|
/**
|
|
|
|
* Whether or not to allow mutation by internal methods
|
|
|
|
*
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
public $allow_private_mutation = false;
|
|
|
|
|
2019-05-11 16:45:25 +02:00
|
|
|
/**
|
2020-07-24 15:32:54 +02:00
|
|
|
* @var string
|
2019-05-11 16:45:25 +02:00
|
|
|
*/
|
2020-07-24 15:32:54 +02:00
|
|
|
public $internal = '';
|
2019-05-11 16:45:25 +02:00
|
|
|
|
2020-07-16 18:59:49 +02:00
|
|
|
/**
|
|
|
|
* @var ?string
|
|
|
|
*/
|
|
|
|
public $getter_method = null;
|
|
|
|
|
2018-10-26 22:17:15 +02:00
|
|
|
public function getInfo() : string
|
|
|
|
{
|
|
|
|
switch ($this->visibility) {
|
2018-11-06 03:57:36 +01:00
|
|
|
case ClassLikeAnalyzer::VISIBILITY_PRIVATE:
|
2018-10-26 22:17:15 +02:00
|
|
|
$visibility_text = 'private';
|
|
|
|
break;
|
|
|
|
|
2018-11-06 03:57:36 +01:00
|
|
|
case ClassLikeAnalyzer::VISIBILITY_PROTECTED:
|
2018-10-26 22:17:15 +02:00
|
|
|
$visibility_text = 'protected';
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
$visibility_text = 'public';
|
|
|
|
}
|
|
|
|
|
2019-06-21 23:10:35 +02:00
|
|
|
return $visibility_text . ' ' . ($this->type ? $this->type->getId() : 'mixed');
|
2018-10-26 22:17:15 +02:00
|
|
|
}
|
2017-01-02 01:09:17 +01:00
|
|
|
}
|