Skip to content

Commit

Permalink
[1.x] Fixes property/method forwarding.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGhostHunter committed Mar 3, 2024
1 parent 0bbee7c commit 5f1ed09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Discoverer.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,15 @@ public function getIterator(): Traversable
}

/**
* Handle dynamic calls to the retrieved classes.
* Handle dynamic property access to the retrieved classes Collection.
*/
public function __get(string $name): mixed
{
return $this->classes()->{$name}();
}

/**
* Handle dynamic calls to the retrieved classes Collection.
*/
public function __call(string $name, array $arguments): mixed
{
Expand Down
7 changes: 7 additions & 0 deletions tests/DiscoverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,11 @@ public function test_iterator_is_collection(): void

static::assertInstanceOf(Collection::class, Discover::in('Events')->getIterator());
}

public function test_forwards_call_to_collection(): void
{
$this->mockAllFiles();

static::assertInstanceOf(Collection::class, Discover::in('Events')->map->name);
}
}

0 comments on commit 5f1ed09

Please sign in to comment.