14
14
use Symfony \Component \HttpFoundation \Request ;
15
15
use Symfony \Component \HttpKernel \ControllerMetadata \ArgumentMetadata ;
16
16
use Symfony \Component \HttpKernel \Exception \HttpException ;
17
+ use Symfony \Component \Validator \ConstraintViolationList ;
17
18
use Symfony \Component \Validator \Validator \ValidatorInterface ;
18
19
use Symfony \Contracts \Service \ServiceProviderInterface ;
19
20
use Zenstruck \Filesystem \Attribute \UploadedFile ;
27
28
trait PendingFileValueResolverTrait
28
29
{
29
30
public function __construct (
30
- /** @var ServiceProviderInterface<RequestFilesExtractor> $locator */
31
31
private ServiceProviderInterface $ locator
32
32
) {
33
33
}
@@ -41,9 +41,9 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
41
41
42
42
$ files = $ this ->extractor ()->extractFilesFromRequest (
43
43
$ request ,
44
- $ attribute ->path ,
45
- $ attribute ->multiple ,
46
- $ attribute ->image ,
44
+ ( string ) $ attribute ->path ,
45
+ ( bool ) $ attribute ->multiple ,
46
+ ( bool ) $ attribute ->image ,
47
47
);
48
48
49
49
if ($ files && $ attribute ->constraints ) {
@@ -53,7 +53,9 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
53
53
);
54
54
55
55
if (\count ($ errors )) {
56
- throw new HttpException ($ attribute ->errorStatus , (string ) $ errors );
56
+ \assert ($ errors instanceof ConstraintViolationList);
57
+
58
+ throw new HttpException ((int ) $ attribute ->errorStatus , (string ) $ errors );
57
59
}
58
60
}
59
61
0 commit comments