{"record":{"id":"0f8a8e870a5fd3cf","repo":"symfony/http-foundation","slug":"an-uploaded-file-must-be-an-array-or-an-instance-of","errorCode":null,"errorMessage":"An uploaded file must be an array or an instance of UploadedFile.","messagePattern":"An uploaded file must be an array or an instance of UploadedFile\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"FileBag.php","lineNumber":43,"sourceCode":"    public function set(string $key, mixed $value): void\n    {\n        if (!\\is_array($value) && !$value instanceof UploadedFile) {\n            throw new \\InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.');\n        }\n\n        parent::set($key, $this->convertFileInformation($value));\n    }\n\n    public function add(array $files = []): void\n    {\n        foreach ($files as $key => $file) {\n            $this->set($key, $file);\n        }\n    }","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/symfony/http-foundation/blob/5aea19cd678fa4140f6108406f1096de5e9ed6e4/FileBag.php#L25-L61","documentation":"An InvalidArgumentException from a type guard in FileBag::set(). Every value stored in the file bag must be either a nested array (for PHP's multi-dimensional $_FILES structure) or an UploadedFile instance; any other value (string, int, object of another class) passed via set(), add(), replace() or the constructor is rejected before storage.","triggerScenarios":"Thrown at FileBag.php:43 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass only arrays or UploadedFile instances into FileBag::set/add/replace or its constructor","Convert raw $_FILES-style arrays of file metadata into UploadedFile objects before injecting them","Validate the value type (is_array($v) || $v instanceof UploadedFile) before calling set()"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5aea19cd678fa4140f6108406f1096de5e9ed6e4","analyzedAt":"2026-09-13T01:52:22.855Z","contentChangedAt":"2026-09-13T01:52:22.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}