Skip to content

Commit

Permalink
Merge branch 'release/v0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
betterthanclay committed Apr 26, 2024
2 parents bba77ab + 048b7ef commit 6688a34
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v0.3.1 (2024-04-26)
* Fixed namespaceMap accessor

## v0.3.0 (2024-04-26)
* Created Namespace Mapping system
* Removed Extensions
Expand Down
4 changes: 2 additions & 2 deletions src/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function map(
string $namespace,
int $priority = 0
): void {
$this->namespaces->add($root, $namespace, $priority);
$this->getNamespaceMap()->add($root, $namespace, $priority);
}

/**
Expand All @@ -180,7 +180,7 @@ public function alias(
string $interface,
string $alias
): void {
$this->namespaces->addAlias($interface, $alias);
$this->getNamespaceMap()->addAlias($interface, $alias);
}


Expand Down
6 changes: 3 additions & 3 deletions src/NamespaceList.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function import(
NamespaceList $list,
?string $mapTo = null,
): void {
foreach($list->namespaces as $namespace => $priority) {
if($mapTo !== null) {
$namespace .= '\\'.$mapTo;
foreach ($list->namespaces as $namespace => $priority) {
if ($mapTo !== null) {
$namespace .= '\\' . $mapTo;
}

$this->add($namespace, $priority);
Expand Down
6 changes: 3 additions & 3 deletions src/NamespaceMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function addAlias(
string $interface,
string $alias
): void {
if(!isset($this->aliases[$interface])) {
if (!isset($this->aliases[$interface])) {
$this->aliases[$interface] = [];
}

Expand Down Expand Up @@ -110,7 +110,7 @@ public function map(
$output = new NamespaceList();
$this->applyMap($namespace, $output);

foreach($this->aliases[$namespace] ?? [] as $alias) {
foreach ($this->aliases[$namespace] ?? [] as $alias) {
$this->applyMap($alias, $output);
}

Expand All @@ -125,7 +125,7 @@ protected function applyMap(
$inner = [];
$namespaces->add($namespace, -1);

while(!empty($parts)) {
while (!empty($parts)) {
$root = implode('\\', $parts);

if (isset($this->namespaces[$root])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Resolver/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function resolve(
$name = str_replace('/', '\\', $name);
$name = trim($name, '\\');

foreach($this->namespaces->map($this->interface) as $namespace) {
foreach ($this->namespaces->map($this->interface) as $namespace) {
$class = $namespace . '\\' . $name;

if (class_exists($class)) {
Expand Down
2 changes: 1 addition & 1 deletion src/ResolverTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function setNamespaceMap(

public function getNamespaceMap(): NamespaceMap
{
if(!isset($this->namespaces)) {
if (!isset($this->namespaces)) {
$this->namespaces = new NamespaceMap();
}

Expand Down

0 comments on commit 6688a34

Please sign in to comment.