Skip to content

Commit 1507c8e

Browse files
committed
fixing Call to undefined method ReflectionUnionType::isBuiltin
1 parent 3a8a6f5 commit 1507c8e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Support/DependencyResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function resolve(Closure|SerializableClosure $closure, array $arguments =
6464
/** @var ReflectionParameter|ReflectionNamedType $type */
6565
$type = $parameter->getType();
6666

67-
if ($type && ! $type->isBuiltin()) {
67+
if ($type && (method_exists($type, 'isBuiltin') && ! $type->isBuiltin())) {
6868
$resolved[] = $this->application->make($type->getName());
6969
} elseif ($parameter->isDefaultValueAvailable()) {
7070
$resolved[] = $parameter->getDefaultValue();

tests/Feature/Support/DependencyResolver.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Fraction\Exceptions\DependencyUnresolvable;
66
use Fraction\Support\DependencyResolver;
7+
use Illuminate\Database\Eloquent\Model;
78

89
test('can serialize and resolve dependencies', function () {
910
$function = function (string $foo = 'bar') {
@@ -25,6 +26,16 @@
2526
expect($dependency->resolve($function))->toBe('bar');
2627
});
2728

29+
test('can resolve multiples types', function () {
30+
execute('one', function (array|Model|null $foo = null) {
31+
return $foo;
32+
})->rescued();
33+
34+
$test = run('one');
35+
36+
expect($test)->toBeNull();
37+
});
38+
2839
test('cannot serialize and resolve dependencies', function () {
2940
$function = function ($foo) {
3041
return $foo;

0 commit comments

Comments
 (0)