Skip to content

Commit 4e9cb7d

Browse files
author
Phil Bennett
committed
Fix normalisation on aliases
1 parent c4617e9 commit 4e9cb7d

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/Definition/Definition.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function __construct(
3131
protected array $methods = [],
3232
protected array $tags = [],
3333
) {
34+
$this->setId($this->id);
3435
$this->concrete ??= $this->id;
3536
}
3637

@@ -47,13 +48,13 @@ public function hasTag(string $tag): bool
4748

4849
public function setId(string $id): DefinitionInterface
4950
{
50-
$this->id = $id;
51+
$this->id = static::normaliseAlias($id);
5152
return $this;
5253
}
5354

5455
public function getId(): string
5556
{
56-
return $this->id;
57+
return static::normaliseAlias($this->id);
5758
}
5859

5960
public function setAlias(string $id): DefinitionInterface
@@ -206,10 +207,6 @@ protected function invokeMethods(object $instance): object
206207

207208
public static function normaliseAlias(string $alias): string
208209
{
209-
if (str_starts_with($alias, '\\')) {
210-
return substr($alias, 1);
211-
}
212-
213-
return $alias;
210+
return ltrim($alias, "\\");
214211
}
215212
}

0 commit comments

Comments
 (0)