-
Notifications
You must be signed in to change notification settings - Fork 41
/
helpers.php
34 lines (29 loc) · 746 Bytes
/
helpers.php
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
30
31
32
33
34
<?php
use PhpParser\Node\Name;
if (!function_exists('extractNamespaceFromFQCN')) {
function extractNamespaceFromFQCN(string $classname): string
{
$parts = explode('\\', $classname);
array_pop($parts);
return implode('\\', $parts);
}
}
if (!function_exists('trimSeparators')) {
function trimSeparators(string $name): string
{
return rtrim(ltrim($name, '\\'), '\\');
}
}
if (!function_exists('namesToClassStrings')) {
/**
* @param array<Name> $names
* @return array<class-string>
*/
function namesToClassStrings(array $names): array
{
return array_map(
static fn(Name $name): string => (string) $name,
$names
);
}
}