-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathHasVisibility.php
More file actions
29 lines (24 loc) · 836 Bytes
/
HasVisibility.php
File metadata and controls
29 lines (24 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
declare(strict_types=1);
namespace Crell\AttributeUtils\Attributes\Reflect;
use Crell\AttributeUtils\Visibility;
trait HasVisibility
{
/**
* The visibility of the property.
*/
public readonly Visibility $visibility;
protected function parseVisibility(\Reflector $subject): void
{
// The Reflector interface is insufficient, but these methods are defined
// on all types we care about. This is a reflection API limitation.
$this->visibility = match (true) {
// @phpstan-ignore-next-line
$subject->isPrivate() => Visibility::Private,
// @phpstan-ignore-next-line
$subject->isProtected() => Visibility::Protected,
// @phpstan-ignore-next-line
$subject->isPublic() => Visibility::Public,
};
}
}