1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-10 15:09:04 +01:00
psalm/src/Psalm/Storage/PropertyStorage.php

136 lines
2.3 KiB
PHP
Raw Normal View History

<?php
namespace Psalm\Storage;
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;
2022-02-24 01:50:05 +01:00
class PropertyStorage implements HasAttributesInterface
{
use CustomMetadataTrait;
/**
2019-11-25 21:20:31 +01:00
* @var ?bool
*/
public $is_static;
/**
* @var ClassLikeAnalyzer::VISIBILITY_*
*/
2021-10-04 00:03:06 +02:00
public $visibility = ClassLikeAnalyzer::VISIBILITY_PUBLIC;
/**
* @var CodeLocation|null
*/
public $location;
2017-03-02 04:27:52 +01:00
/**
* @var CodeLocation|null
*/
public $stmt_location;
/**
* @var CodeLocation|null
2017-03-02 04:27:52 +01:00
*/
public $type_location;
/**
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
*/
public $type;
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;
/**
2021-12-13 16:28:14 +01:00
* @var Union|null
*/
public $suggested_type;
/**
* @var bool
*/
public $has_default = false;
/**
* @var bool
*/
public $deprecated = false;
2019-08-11 22:01:37 +02:00
/**
* @var bool
*/
public $readonly = false;
/**
* Whether or not to allow mutation by internal methods
*
* @var bool
*/
public $allow_private_mutation = false;
/**
* @var list<non-empty-string>
*/
public $internal = [];
/**
* @var ?string
*/
2021-09-26 23:24:07 +02:00
public $getter_method;
/**
* @var bool
*/
public $is_promoted = false;
/**
* @var list<AttributeStorage>
*/
public $attributes = [];
/**
* @var array<int, string>
*/
public $suppressed_issues = [];
/**
* @var ?string
*/
public $description;
public function getInfo(): string
{
switch ($this->visibility) {
2018-11-06 03:57:36 +01:00
case ClassLikeAnalyzer::VISIBILITY_PRIVATE:
$visibility_text = 'private';
break;
2018-11-06 03:57:36 +01:00
case ClassLikeAnalyzer::VISIBILITY_PROTECTED:
$visibility_text = 'protected';
break;
default:
$visibility_text = 'public';
}
return $visibility_text . ' ' . ($this->type ? $this->type->getId() : 'mixed');
}
2022-02-24 01:50:05 +01:00
/**
* @return list<AttributeStorage>
*/
public function getAttributeStorages(): array
{
return $this->attributes;
}
}