{"record":{"id":"5f79bbead1411c1e","repo":"Intervention/image","slug":"width-of-this-class-must-be-greater-than-or-eq","errorCode":null,"errorMessage":"Width of {$this::class} must be greater than or equal to 0","messagePattern":"Width of (.+?) must be greater than or equal to 0","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Geometry/Rectangle.php","lineNumber":34,"sourceCode":"use Intervention\\Image\\Interfaces\\DrawableInterface;\nuse Intervention\\Image\\Interfaces\\PointInterface;\nuse Intervention\\Image\\Interfaces\\SizeInterface;\nuse Traversable;\n\nclass Rectangle extends Polygon implements DrawableInterface, SizeInterface\n{\n    /**\n     * Create new rectangle.\n     *\n     * @throws InvalidArgumentException\n     */\n    public function __construct(\n        int $width,\n        int $height,\n        protected PointInterface $pivot = new Point(),\n    ) {\n        if ($width < 0) {\n            throw new InvalidArgumentException(\n                'Width of ' . $this::class . ' must be greater than or equal to 0',\n            );\n        }\n\n        if ($height < 0) {\n            throw new InvalidArgumentException(\n                'Height of ' . $this::class . ' must be greater than or equal to 0',\n            );\n        }\n\n        parent::__construct([\n            new Point(0, 0),\n            new Point($width, 0),\n            new Point($width, $height * -1),\n            new Point(0, $height * -1),\n        ], $pivot);\n    }\n","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Geometry/Rectangle.php#L16-L52","documentation":"Error \"Width of {$this::class} must be greater than or equal to 0\" thrown in Intervention/image.","triggerScenarios":"Thrown at src/Geometry/Rectangle.php:34 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a width of 0 or more when constructing the Rectangle","Clamp negative computed widths with max(0, $width) before constructing the object","Validate user input that feeds the width so negative values are rejected early"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}