{"record":{"id":"a68ba727878031af","repo":"getgrav/grav","slug":"identifier-s-does-not-contain-an-object-definit","errorCode":null,"errorMessage":"Identifier \"%s\" does not contain an object definition.","messagePattern":"Identifier \"(.+?)\" does not contain an object definition\\.","errorType":"exception","errorClass":"Pimple\\Exception\\InvalidServiceIdentifierException","httpStatus":null,"severity":"error","filePath":"system/src/Pimple/Container.php","lineNumber":126,"sourceCode":"        }\n\n        $this->values[$id] = $value;\n        $this->keys[$id] = true;\n    }\n\n    /**\n     * Gets a parameter or an object.\n     *\n     * @param string $id The unique identifier for the parameter or object\n     *\n     * @return mixed The value of the parameter or an object\n     *\n     * @throws UnknownIdentifierException If the identifier is not defined\n     */\n    public function offsetGet(mixed $id): mixed\n    {\n        if (!is_string($id)) {\n            throw new InvalidServiceIdentifierException($id);\n        }\n\n        if (!isset($this->keys[$id])) {\n            throw new UnknownIdentifierException($id);\n        }\n\n        if (\n            isset($this->raw[$id])\n            || !is_object($this->values[$id])\n            || isset($this->protected[$this->values[$id]])\n            || !method_exists($this->values[$id], '__invoke')\n        ) {\n            return $this->values[$id];\n        }\n\n        if (isset($this->factories[$this->values[$id]])) {\n            return $this->values[$id]($this);\n        }","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/getgrav/grav/blob/6040efed04efa69b8209448ed81308e7c24147c2/system/src/Pimple/Container.php#L108-L144","documentation":"Container::offsetGet() accepts a mixed offset because Container implements ArrayAccess, but it immediately requires the service ID to be a string. A non-string offset throws InvalidServiceIdentifierException; the exception text about an object definition is generic and can be misleading because the actual check at Container.php:125-127 is only is_string($id).","triggerScenarios":"Calling $container[$id] where $id is an integer, null, boolean, array, or object. Common shapes are $container[0], $container[$config['service'] ?? null], or an ID taken from a YAML map whose PHP key was converted to an integer.","commonSituations":"Dynamic service names loaded from configuration or request arrays, numeric YAML keys, a missing environment variable becoming null, or code written for a plain PHP array being reused against the DI container.","solutions":["Check or cast the variable before access: use $container[(string) $id] only after confirming it is a non-empty string.","Fail early when the configured service name is missing instead of passing null to the container.","Store service names in configuration as quoted strings.","Use a known literal service name when possible."],"exampleFix":"// before\n$id = $settings['service'] ?? null;\n$service = $container[$id]; // Identifier \"\" does not contain...\n\n// after\n$id = $settings['service'] ?? null;\nif (!is_string($id) || $id === '') {\n    throw new InvalidArgumentException('settings.service must be a service ID string');\n}\n$service = $container[$id];","handlingStrategy":"type-guard","validationCode":"if (!is_string($id)) {\n    throw new InvalidArgumentException(sprintf('Container ID must be a string, got %s.', get_debug_type($id)));\n}\n$service = $container[$id];","typeGuard":"function isContainerServiceId(mixed $id): bool\n{\n    return is_string($id);\n}","tryCatchPattern":"try {\n    $service = $container[$id];\n} catch (InvalidServiceIdentifierException $e) {\n    throw new InvalidArgumentException(sprintf('Invalid dynamic container ID type: %s', get_debug_type($id)), 0, $e);\n}","preventionTips":["Normalize configuration-derived service names to non-empty strings.","Fail on missing IDs instead of passing null to the container.","Quote numeric or symbolic IDs in YAML.","Enable static analysis on code that uses dynamic ArrayAccess offsets."],"tags":["pimple","dependency-injection","php","arrayaccess","type-error"],"backgroundTag":"invalid-container-key-type","analyzedSha":"6040efed04efa69b8209448ed81308e7c24147c2","analyzedAt":"2026-08-17T05:07:31.593Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}