Skip to content

Commit 5afaba9

Browse files
author
Kirill Nesmeyanov
committed
Add Identifier::isVirtual() method
1 parent 9050b32 commit 5afaba9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Node/Identifier.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ public function __construct(string $value)
5555
));
5656
}
5757

58+
/**
59+
* Returns {@see true} if the identifier contains the name of
60+
* a "virtual" type, i.e. invalid in the PHP namespace.
61+
*
62+
* - `SomeClass` - Non-virtual, can be a type in PHP.
63+
* - `false` - Non-virtual, can be a type in PHP.
64+
* - `non-empty-array` - Virtual, cannot be defined in PHP.
65+
* - `empty-string` - Virtual, cannot be defined in PHP.
66+
*/
67+
public function isVirtual(): bool
68+
{
69+
return \str_contains($this->value, '-');
70+
}
71+
5872
/**
5973
* Returns {@see true} in case of name contains special class reference.
6074
*/

0 commit comments

Comments
 (0)