{"record":{"id":"5018106d0eb75297","repo":"doctrine/orm","slug":"unknown-field-name-field","errorCode":null,"errorMessage":"Unknown field: {name} ::${field}","messagePattern":"Unknown field: (.+?) ::(.+?)","errorType":"exception","errorClass":"OutOfBoundsException","httpStatus":null,"severity":"error","filePath":"src/Mapping/LegacyReflectionFields.php","lineNumber":116,"sourceCode":"                    } else {\n                        $parentClass = $this->classMetadata->fieldMappings[$parentField]->originalClass;\n                    }\n\n                    /** @psalm-var class-string $parentClass */\n                    /** @psalm-var class-string $originalClass */\n\n                    $this->reflFields[$field] = new ReflectionEmbeddedProperty(\n                        $this->getAccessibleProperty($parentClass, $parentField),\n                        $this->reflFields[$field],\n                        $originalClass,\n                    );\n                }\n            }\n\n            return $this->reflFields[$field];\n        }\n\n        throw new OutOfBoundsException('Unknown field: ' . $this->classMetadata->name . ' ::$' . $field);\n    }\n\n    /**\n     * @param string             $offset\n     * @param ReflectionProperty $value\n     */\n    public function offsetSet($offset, $value): void // phpcs:ignore\n    {\n        $this->reflFields[$offset] = $value;\n    }\n\n    /** @param string $offset */\n    public function offsetUnset($offset): void // phpcs:ignore\n    {\n        unset($this->reflFields[$offset]);\n    }\n\n    /** @psalm-param class-string $class */","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/doctrine/orm/blob/d9b9ff73016bf598ae07515f97289ce8074e97a5/src/Mapping/LegacyReflectionFields.php#L98-L134","documentation":"LegacyReflectionFields is an ArrayAccess wrapper around a ClassMetadata's map of ReflectionProperty objects, keyed by field names, association names and embedded sub-paths like 'parent.child'. offsetGet() throws OutOfBoundsException when the requested name is not in that map, i.e. it is not a mapped field of that class.","triggerScenarios":"Reading $classMetadata->reflFields['someName'] (or LegacyReflectionFields offsetGet) where 'someName' is not a mapped field/association/embedded path of the class — typos, a field removed from the mapping, or querying the metadata of the wrong entity class.","commonSituations":"Custom hydrators, entity listeners or fixtures that reach into ClassMetadata::reflFields directly; accessing an association's target field on the source class metadata; code that keeps working by accident until a property is renamed.","solutions":["Use the public API: $metadata->getReflectionProperty($field) / $metadata->getAssociationMapping(...) instead of raw array access.","Guard lookups with in_array($field, $metadata->getFieldNames(), true) or array_key_exists($field, $metadata->reflFields) first.","For embedded sub-fields, use the dotted path ('address.city') that the map is keyed by."],"exampleFix":"// before\n$prop = $metadata->reflFields['emial']; // typo -> OutOfBoundsException\n\n// after\n$field = 'email';\n$prop  = array_key_exists($field, $metadata->reflFields)\n    ? $metadata->reflFields[$field]\n    : throw new RuntimeException(\"Unknown field {$field} on {$metadata->name}\");","handlingStrategy":"validation","validationCode":"$field = 'email';\nif (! array_key_exists($field, $metadata->reflFields)\n    && ! $metadata->hasField($field) && ! $metadata->hasAssociation($field)\n) {\n    throw new OutOfBoundsException(\"Unknown field '{$field}' on {$metadata->name}\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer $metadata->getReflectionProperty($field) over raw reflFields array access.","Derive field names from the metadata (fieldNames/associationNames), not string literals.","Add tests for custom hydrators/listeners so renamed fields fail fast."],"tags":["doctrine-orm","reflection","class-metadata","field-access"],"backgroundTag":"unknown-field-name","analyzedSha":"d9b9ff73016bf598ae07515f97289ce8074e97a5","analyzedAt":"2026-08-21T06:13:15.863Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}