{"record":{"id":"ef7066a7d695b969","repo":"briannesbitt/Carbon","slug":"classname-has-not-the-instance-method-needed-to-ef7066","errorCode":null,"errorMessage":"$className has not the instance() method needed to cast the date.","messagePattern":"\\$className has not the instance\\(\\) method needed to cast the date\\.","errorType":"exception","errorClass":"Carbon\\Exceptions\\InvalidCastException","httpStatus":null,"severity":"error","filePath":"src/Carbon/CarbonTimeZone.php","lineNumber":77,"sourceCode":"\n        return $timezone;\n    }\n\n    /**\n     * Cast the current instance into the given class.\n     *\n     * @param class-string<DateTimeZone> $className The $className::instance() method will be called to cast the current object.\n     *\n     * @return DateTimeZone|mixed\n     */\n    public function cast(string $className): mixed\n    {\n        if (!method_exists($className, 'instance')) {\n            if (is_a($className, DateTimeZone::class, true)) {\n                return new $className($this->getName());\n            }\n\n            throw new InvalidCastException(\"$className has not the instance() method needed to cast the date.\");\n        }\n\n        return $className::instance($this);\n    }\n\n    /**\n     * Create a CarbonTimeZone from mixed input.\n     *\n     * @param DateTimeZone|string|int|false|null $object     original value to get CarbonTimeZone from it.\n     * @param DateTimeZone|string|int|false|null $objectDump dump of the object for error messages.\n     *\n     * @throws InvalidTimeZoneException\n     *\n     * @return static|null\n     */\n    public static function instance(\n        DateTimeZone|string|int|false|null $object,\n        DateTimeZone|string|int|false|null $objectDump = null,","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/briannesbitt/Carbon/blob/b13f05955dcfd7da71d60af745fd148cbdb73505/src/Carbon/CarbonTimeZone.php#L59-L95","documentation":"Error \"$className has not the instance() method needed to cast the date.\" thrown in briannesbitt/Carbon.","triggerScenarios":"Thrown at src/Carbon/CarbonTimeZone.php:77 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b13f05955dcfd7da71d60af745fd148cbdb73505","analyzedAt":"2026-08-17T04:40:56.953Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}