{"record":{"id":"415f89d9ad43eea0","repo":"Intervention/image","slug":"division-by-zero","errorCode":null,"errorMessage":"Division by zero","messagePattern":"Division by zero","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Geometry/Rectangle.php","lineNumber":180,"sourceCode":"    public function setSize(int $width, int $height): self\n    {\n        return $this->setWidth($width)->setHeight($height);\n    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @deprecated Use Intervention\\Image\\Size::class instead.\n     * @see SizeInterface::aspectRatio()\n     *\n     * @throws RuntimeException\n     */\n    public function aspectRatio(): float\n    {\n        try {\n            return $this->width() / $this->height();\n        } catch (DivisionByZeroError) {\n            throw new RuntimeException('Division by zero');\n        }\n    }\n\n    /**\n     * {@inheritdoc}\n     *\n     * @deprecated Use Intervention\\Image\\Size::class instead.\n     * @see SizeInterface::fitsWithin()\n     */\n    public function fitsWithin(SizeInterface $size): bool\n    {\n        if ($this->width() > $size->width()) {\n            return false;\n        }\n\n        if ($this->height() > $size->height()) {\n            return false;\n        }","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Geometry/Rectangle.php#L162-L198","documentation":"Error \"Division by zero\" thrown in Intervention/image.","triggerScenarios":"Thrown at src/Geometry/Rectangle.php:180 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the divisor (usually an aspect-ratio denominator derived from width or height) is not zero before the division","Guard calls that compute ratios with a check for zero dimensions, e.g. if ($height === 0)","Use the library's resize helpers which handle degenerate dimensions instead of computing ratios manually"],"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"}