{"record":{"id":"d3d525a58c6dc90b","repo":"Intervention/image","slug":"image-source-must-be-of-type-splfileinfo-d3d525","errorCode":null,"errorMessage":"Image source must be of type SplFileInfo","messagePattern":"Image source must be of type SplFileInfo","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/Decoders/SplFileInfoImageDecoder.php","lineNumber":49,"sourceCode":"    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @see DecoderInterface::decode()\n     *\n     * @throws InvalidArgumentException\n     * @throws DirectoryNotFoundException\n     * @throws FileNotFoundException\n     * @throws FileNotReadableException\n     * @throws ImageDecoderException\n     * @throws DriverException\n     * @throws StateException\n     */\n    public function decode(mixed $input): ImageInterface\n    {\n        if (!$input instanceof SplFileInfo) {\n            throw new InvalidArgumentException('Image source must be of type ' . SplFileInfo::class);\n        }\n\n        try {\n            return parent::decode(self::filePathFromSplFileInfoOrFail($input));\n        } catch (DecoderException) {\n            throw new ImageDecoderException(SplFileInfo::class . ' contains unsupported image type');\n        }\n    }\n}\n","sourceCodeStart":31,"sourceCodeEnd":59,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/Decoders/SplFileInfoImageDecoder.php#L31-L59","documentation":"SplFileInfoImageDecoder::decode() was called with a value that is not an SplFileInfo. Normally ImageManager::read() routes input via supports() (instanceof SplFileInfo), so this only fires when the decoder is invoked directly with a wrong type. Symfony's File and UploadedFile extend SplFileInfo and pass the check.","triggerScenarios":"Manually calling the decoder with a plain string path, an SplFileObject-less resource, or an object that only duck-types a file path; custom pipelines bypassing the manager.","commonSituations":"Wrappers that normalize sources to strings but hand them to the SplFileInfo decoder; refactors from path strings to file objects done only at the call site.","solutions":["Use ImageManager::read($file) and let the chain route - Symfony File/UploadedFile instances are supported natively","If calling decode() directly, guard with instanceof SplFileInfo or supports() first","For plain path strings, pass the string itself - the FilePathImageDecoder handles it"],"exampleFix":"// before\n$decoder = new SplFileInfoImageDecoder($driver);\n$image = $decoder->decode('/path/to/image.jpg'); // string, not SplFileInfo\n\n// after\n$image = $manager->read(new SplFileInfo('/path/to/image.jpg'));\n// or simply: $manager->read('/path/to/image.jpg');","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isSplFileInfo(mixed $value): bool\n{\n    return $value instanceof \\SplFileInfo; // Symfony File/UploadedFile also pass\n}","tryCatchPattern":null,"preventionTips":["Route file objects through ImageManager::read() so supports() dispatches correctly","Pass plain strings directly - the path decoder handles them without wrapping"],"tags":["splfileinfo","type-error","decoder","invalid-argument"],"backgroundTag":"invalid-argument-type","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}