2017-01-02 01:09:17 +01:00
|
|
|
<?php
|
2021-12-15 04:58:32 +01:00
|
|
|
|
2017-01-02 01:09:17 +01:00
|
|
|
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;
|
2021-12-13 16:28:14 +01:00
|
|
|
use Psalm\Type\Union;
|
2017-01-02 01:09:17 +01:00
|
|
|
|
2022-02-24 01:50:05 +01:00
|
|
|
class PropertyStorage implements HasAttributesInterface
|
2017-01-02 01:09:17 +01:00
|
|
|
{
|
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
|
|
|
*/
|
2021-10-04 00:03:06 +02:00
|
|
|
public $visibility = ClassLikeAnalyzer::VISIBILITY_PUBLIC;
|
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;
|
|
|
|
|
|
|
|
/**
|
2021-12-13 16:28:14 +01:00
|
|
|
* @var 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
|
|
|
/**
|
2021-12-13 16:28:14 +01:00
|
|
|
* @var Union|null
|
2019-01-11 23:21:50 +01:00
|
|
|
*/
|
|
|
|
public $signature_type;
|
|
|
|
|
2017-04-15 05:09:34 +02:00
|
|
|
/**
|
2021-12-13 16:28:14 +01:00
|
|
|
* @var Union|null
|
2017-04-15 05:09:34 +02:00
|
|
|
*/
|
|
|
|
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
|
|
|
/**
|
2022-06-25 09:03:26 +02:00
|
|
|
* @var list<non-empty-string>
|
2019-05-11 16:45:25 +02:00
|
|
|
*/
|
2022-06-25 09:03:26 +02:00
|
|
|
public $internal = [];
|
2019-05-11 16:45:25 +02:00
|
|
|
|
2020-07-16 18:59:49 +02:00
|
|
|
/**
|
|
|
|
* @var ?string
|
|
|
|
*/
|
2021-09-26 23:24:07 +02:00
|
|
|
public $getter_method;
|
2020-07-16 18:59:49 +02:00
|
|
|
|
2020-11-22 06:32:02 +01:00
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
public $is_promoted = false;
|
|
|
|
|
2020-10-24 06:10:22 +02:00
|
|
|
/**
|
|
|
|
* @var list<AttributeStorage>
|
|
|
|
*/
|
|
|
|
public $attributes = [];
|
|
|
|
|
2021-01-31 17:32:24 +01:00
|
|
|
/**
|
|
|
|
* @var array<int, string>
|
|
|
|
*/
|
|
|
|
public $suppressed_issues = [];
|
|
|
|
|
2021-02-24 16:14:04 +01:00
|
|
|
/**
|
|
|
|
* @var ?string
|
|
|
|
*/
|
|
|
|
public $description;
|
|
|
|
|
2021-12-05 18:51:26 +01:00
|
|
|
public function getInfo(): string
|
2018-10-26 22:17:15 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
2022-02-24 01:50:05 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return list<AttributeStorage>
|
|
|
|
*/
|
|
|
|
public function getAttributeStorages(): array
|
|
|
|
{
|
|
|
|
return $this->attributes;
|
|
|
|
}
|
2017-01-02 01:09:17 +01:00
|
|
|
}
|