{"record":{"id":"109d19a188eac8d8","repo":"Intervention/image","slug":"option-key-does-not-exist-on-this-class","errorCode":null,"errorMessage":"Option ${key} does not exist on {this::class}","messagePattern":"Option (.+?) does not exist on (.+?)","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Drivers/AbstractEncoder.php","lineNumber":69,"sourceCode":"    {\n        $stream = self::buildStreamOrFail();\n        $callback($stream);\n\n        return is_string($mediaType) ? new EncodedImage($stream, $mediaType) : new EncodedImage($stream);\n    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @see EncoderInterface::setOptions()\n     *\n     * @throws InvalidArgumentException\n     */\n    public function setOptions(mixed ...$options): self\n    {\n        foreach ($options as $key => $value) {\n            if (!property_exists($this, (string) $key)) {\n                throw new InvalidArgumentException(\n                    'Option $' . $key . ' does not exist on ' . $this::class,\n                );\n            }\n            $this->{$key} = $value;\n        }\n\n        return $this;\n    }\n}\n","sourceCodeStart":51,"sourceCodeEnd":79,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/AbstractEncoder.php#L51-L79","documentation":"Encoder options map directly to public properties of the concrete encoder class. setOptions() rejects any key that is not a property of that specific encoder: JpegEncoder has quality/progressive (plus inherited fields), PngEncoder has interlaced/indexed - and they do not share options.","triggerScenarios":"$image->toPng(quality: 90) (PNG encoder has no quality property), $image->toJpg(indexed: true) (JPEG encoder has no indexed property), or any format-specific option passed to a different format's encoder via setOptions().","commonSituations":"Copy-pasting encode options between formats; assuming all encoders accept quality; options renamed or moved between major versions.","solutions":["Use only options defined as public properties on the target encoder class (check e.g. src/Encoders/JpegEncoder.php)","Drop format-specific options when switching formats - quality applies to JPEG/WebP, not PNG","For smaller PNGs use the PNG-specific options (e.g. indexed) instead of quality"],"exampleFix":"// before\n$encoded = $image->toPng(quality: 90);\n\n// after\n$encoded = $image->toPng(); // or: ->toPng(indexed: true)","handlingStrategy":"validation","validationCode":"$allowed = array_keys(get_class_vars($encoder::class)); // public encoder options\n$options = array_intersect_key($userOptions, array_flip($allowed));\n$encoder->setOptions($options);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Consult the concrete encoder's public properties before passing options","Do not share one options array across formats","Re-check encoder options after major-version upgrades"],"tags":["encoder","options","validation","format-specific"],"backgroundTag":"invalid-encoder-option","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}