{"record":{"id":"6e640f2a8d94b1e6","repo":"Intervention/image","slug":"no-modifier-for-drawable-class-found","errorCode":null,"errorMessage":"No modifier for {$drawable::class} found","messagePattern":"No modifier for (.+?) found","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Image.php","lineNumber":1142,"sourceCode":"    /**\n     * {@inheritdoc}\n     *\n     * @see ImageInterface::draw()\n     *\n     * @throws InvalidArgumentException\n     * @throws NotSupportedException\n     * @throws ModifierException\n     * @throws ColorDecoderException\n     */\n    public function draw(DrawableInterface $drawable): ImageInterface\n    {\n        return $this->modify(match ($drawable::class) {\n            Rectangle::class => new DrawRectangleModifier($drawable),\n            Circle::class, Ellipse::class => new DrawEllipseModifier($drawable),\n            Bezier::class => new DrawBezierModifier($drawable),\n            Line::class => new DrawLineModifier($drawable),\n            Polygon::class => new DrawPolygonModifier($drawable),\n            default => throw new NotSupportedException('No modifier for ' . $drawable::class . ' found'),\n        });\n    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @see ImageInterface::encode()\n     *\n     * @throws EncoderException\n     */\n    public function encode(?EncoderInterface $encoder = null): EncodedImageInterface\n    {\n        return $this->driver()->specializeEncoder(\n            $encoder ?: new AutoEncoder(),\n        )->encode($this);\n    }\n\n    /**","sourceCodeStart":1124,"sourceCodeEnd":1160,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Image.php#L1124-L1160","documentation":"Image::draw() dispatches to a modifier via a match on the concrete drawable class: Rectangle, Circle/Ellipse, Bezier, Line and Polygon are supported. Any other DrawableInterface implementation — including subclasses of the built-in ones, since the match is on ::class, not instanceof — falls to the default arm and throws NotSupportedException. Custom drawable shapes are not extensible through this entry point.","triggerScenarios":"$image->draw(new MyCustomShape()) where MyCustomShape implements DrawableInterface but is none of the five known classes; also new class RectangleSubclass() (match on $drawable::class does not match the parent case).","commonSituations":"Upgrading custom code from older Intervention versions where shapes were extensible, or writing a custom drawable expecting polymorphic dispatch. Version changes that introduce new drawable classes not present in the installed release can also surface this.","solutions":["Use the built-in drawable classes (Rectangle, Ellipse, Circle, Bezier, Line, Polygon) and configure them via their setters instead of subclassing","If you need custom rendering, write a custom Modifier and invoke it via $image->modify(new MyModifier()) directly","Pass the exact built-in class, not a subclass, to draw()","Pin/upgrade the intervention/image version so the drawable classes you reference exist in the match list"],"exampleFix":"// before\n$image->draw(new class extends Rectangle { /* ... */ }); // NotSupportedException\n\n// after\n$image->draw((new Rectangle(100, 100))->setBackgroundColor('f00'));\n// or custom rendering:\n$image->modify(new DrawCustomShapeModifier($customData));","handlingStrategy":"type-guard","validationCode":"$supported = [Rectangle::class, Ellipse::class, Circle::class, Bezier::class, Line::class, Polygon::class];\nif (!in_array($drawable::class, $supported, true)) {\n    throw new InvalidArgumentException('Unsupported drawable: ' . $drawable::class);\n}\n$image->draw($drawable);","typeGuard":"function isBuiltInDrawable(object $drawable): bool\n{\n    return in_array($drawable::class, [\n        \\Intervention\\Image\\Geometry\\Rectangle::class,\n        \\Intervention\\Image\\Geometry\\Ellipse::class,\n        \\Intervention\\Image\\Geometry\\Circle::class,\n        \\Intervention\\Image\\Geometry\\Bezier::class,\n        \\Intervention\\Image\\Geometry\\Line::class,\n        \\Intervention\\Image\\Geometry\\Polygon::class,\n    ], true); // exact class match — subclasses are NOT supported\n}","tryCatchPattern":"try {\n    $image->draw($shape);\n} catch (NotSupportedException $e) {\n    // programming error: switch to a built-in shape or a custom Modifier\n}","preventionTips":["Do not subclass drawables — the dispatch matches the exact class name","For custom rendering, implement a Modifier and call $image->modify()","Cover the drawable list with a unit test after upgrading intervention/image"],"tags":["draw","drawable","modifier","unsupported","polymorphism"],"backgroundTag":"unsupported-type","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}