{"record":{"id":"b799ae5ba055d832","repo":"briannesbitt/Carbon","slug":"translator-does-not-implement-symfony-contracts-tr","errorCode":null,"errorMessage":"Translator does not implement Symfony\\Contracts\\Translation\\TranslatorInterface and Symfony\\Component\\Translation\\TranslatorBagInterface. {translator} has been given.","messagePattern":"Translator does not implement Symfony\\\\Contracts\\\\Translation\\\\TranslatorInterface and Symfony\\\\Component\\\\Translation\\\\TranslatorBagInterface\\. (.+?) has been given\\.","errorType":"exception","errorClass":"Carbon\\Exceptions\\InvalidTypeException","httpStatus":null,"severity":"error","filePath":"src/Carbon/Traits/Localization.php","lineNumber":80,"sourceCode":"        $this->localTranslator = $translator;\n\n        return $this;\n    }\n\n    /**\n     * Returns raw translation message for a given key.\n     *\n     * @param TranslatorInterface|null $translator the translator to use\n     * @param string                   $key        key to find\n     * @param string|null              $locale     current locale used if null\n     * @param string|null              $default    default value if translation returns the key\n     *\n     * @return string|Closure|null\n     */\n    public static function getTranslationMessageWith($translator, string $key, ?string $locale = null, ?string $default = null)\n    {\n        if (!($translator instanceof TranslatorBagInterface && $translator instanceof TranslatorInterface)) {\n            throw new InvalidTypeException(\n                'Translator does not implement '.TranslatorInterface::class.' and '.TranslatorBagInterface::class.'. '.\n                (\\is_object($translator) ? \\get_class($translator) : \\gettype($translator)).' has been given.',\n            );\n        }\n\n        if (!$locale && $translator instanceof LocaleAwareInterface) {\n            $locale = $translator->getLocale();\n        }\n\n        $result = self::getFromCatalogue($translator, $translator->getCatalogue($locale), $key);\n\n        return $result === $key ? $default : $result;\n    }\n\n    /**\n     * Returns raw translation message for a given key.\n     *\n     * @param string              $key        key to find","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/briannesbitt/Carbon/blob/b13f05955dcfd7da71d60af745fd148cbdb73505/src/Carbon/Traits/Localization.php#L62-L98","documentation":"Error \"Translator does not implement Symfony\\Contracts\\Translation\\TranslatorInterface and Symfony\\Component\\Translation\\TranslatorBagInterface. {translator} has been given.\" thrown in briannesbitt/Carbon.","triggerScenarios":"Thrown at src/Carbon/Traits/Localization.php:80 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"}