Skip to content

Commit

Permalink
Merge pull request #80 from TheDragonCode/3.x
Browse files Browse the repository at this point in the history
Fixed a bug when working with text values like function names
  • Loading branch information
andrey-helldar authored Jan 15, 2024
2 parents 3fee304 + 3eea010 commit 5988fe6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/Concerns/Call.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ trait Call

protected function call(mixed $callback = null): mixed
{
return $this->isCallable($callback) ? $callback() : $callback;
return $this->isCallable($callback) && ! $this->isFunction($callback) ? $callback() : $callback;
}

protected function makeCallable($value): callable
{
if ($this->isCallable($value)) {
if ($this->isCallable($value) && ! $this->isFunction($value)) {
return $value;
}

Expand All @@ -28,4 +28,9 @@ protected function isCallable($value): bool
{
return is_callable($value);
}

protected function isFunction($value): bool
{
return is_string($value) && function_exists($value);
}
}
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ abstract class TestCase extends BaseTestCase

protected array $keys = ['Foo', 'Bar', 'Baz'];

protected mixed $value = 'Foo';
protected mixed $value = 'value';

protected string $value_second = 'Bar';
protected string $value_second = 'Foo';

protected function getPackageProviders($app): array
{
Expand Down

0 comments on commit 5988fe6

Please sign in to comment.