1414use Symfony \Component \HttpFoundation \Request ;
1515use Symfony \Component \HttpKernel \ControllerMetadata \ArgumentMetadata ;
1616use Symfony \Component \HttpKernel \Exception \HttpException ;
17+ use Symfony \Component \Validator \ConstraintViolationList ;
1718use Symfony \Component \Validator \Validator \ValidatorInterface ;
1819use Symfony \Contracts \Service \ServiceProviderInterface ;
1920use Zenstruck \Filesystem \Attribute \UploadedFile ;
2728trait PendingFileValueResolverTrait
2829{
2930 public function __construct (
30- /** @var ServiceProviderInterface<RequestFilesExtractor> $locator */
3131 private ServiceProviderInterface $ locator
3232 ) {
3333 }
@@ -41,9 +41,9 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
4141
4242 $ files = $ this ->extractor ()->extractFilesFromRequest (
4343 $ request ,
44- $ attribute ->path ,
45- $ attribute ->multiple ,
46- $ attribute ->image ,
44+ ( string ) $ attribute ->path ,
45+ ( bool ) $ attribute ->multiple ,
46+ ( bool ) $ attribute ->image ,
4747 );
4848
4949 if ($ files && $ attribute ->constraints ) {
@@ -53,7 +53,9 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
5353 );
5454
5555 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 );
5759 }
5860 }
5961
0 commit comments