{"record":{"id":"46891f0661019050","repo":"doctrine/orm","slug":"class-s-does-not-exist","errorCode":null,"errorMessage":"Class \"%s\" does not exist","messagePattern":"Class \"(.+?)\" does not exist","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Mapping/Driver/XmlDriver.php","lineNumber":724,"sourceCode":"     * @param SimpleXMLElement $objectElement The XML element.\n     *\n     * @return object The instantiated object.\n     *\n     * @throws MappingException If the object specification is invalid.\n     * @throws InvalidArgumentException If the class does not exist.\n     */\n    private function parseObjectElement(SimpleXMLElement $objectElement): object\n    {\n        $attributes = $objectElement->attributes();\n\n        if (! isset($attributes->class)) {\n            throw MappingException::missingRequiredOption('object', 'class');\n        }\n\n        $className = (string) $attributes->class;\n\n        if (! class_exists($className)) {\n            throw new InvalidArgumentException(sprintf('Class \"%s\" does not exist', $className));\n        }\n\n        return new $className();\n    }\n\n    /**\n     * Constructs a joinColumn mapping array based on the information\n     * found in the given SimpleXMLElement.\n     *\n     * @param SimpleXMLElement $joinColumnElement The XML element.\n     *\n     * @return mixed[] The mapping array.\n     * @phpstan-return array{\n     *                   name: string,\n     *                   referencedColumnName: string,\n     *                   unique?: bool,\n     *                   nullable?: bool,\n     *                   onDelete?: string,","sourceCodeStart":706,"sourceCodeEnd":742,"githubUrl":"https://github.com/doctrine/orm/blob/d9b9ff73016bf598ae07515f97289ce8074e97a5/src/Mapping/Driver/XmlDriver.php#L706-L742","documentation":"Inside the <options> block of an XML field mapping, Doctrine supports an embedded <object class=\"...\"/> element whose class is instantiated (new $className()) to provide a default value object. XmlDriver::parseObjectElement() requires the class attribute and calls class_exists() on it; a class that cannot be loaded throws InvalidArgumentException naming it.","triggerScenarios":"A mapping like <field ...><options><option name=\"default\"><object class=\"App\\Value\\MyDefault\"/></option></options></field> where App\\Value\\MyDefault was renamed, deleted, moved to another namespace, or is not autoloadable in the current project.","commonSituations":"Refactoring/renaming a value class and forgetting the XML mapping; .dcm.xml files copied between projects; composer autoload maps out of date after moving classes (need dump-autoload).","solutions":["Correct the class attribute to the current fully-qualified class name.","Ensure the class is autoloadable: run composer dump-autoload and check PSR-4 mapping covers its namespace.","If the default-value object is no longer needed, remove the whole <option> entry."],"exampleFix":"<!-- before -->\n<option name=\"default\"><object class=\"App\\Util\\Money\"/></option>\n\n<!-- after (class moved) -->\n<option name=\"default\"><object class=\"App\\Value\\Money\"/></option>","handlingStrategy":"validation","validationCode":"$class = (string) $objectElement['class'];\nif (! class_exists($class)) {\n    throw new InvalidArgumentException(\"Object option references unknown class {$class}\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep XML object-option class names in sync during refactors (IDE-supported rename won't touch XML).","Run composer dump-autoload after moving classes.","Warm the metadata cache in CI so class-resolution problems fail the build."],"tags":["doctrine-orm","xml-mapping","class-not-found","options"],"backgroundTag":"class-not-found","analyzedSha":"d9b9ff73016bf598ae07515f97289ce8074e97a5","analyzedAt":"2026-08-21T06:13:15.863Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}