{"id":"0eb6cdc7ae8fe9bc","repo":"laravel/framework","slug":"invalid-binding-type-type","errorCode":null,"errorMessage":"Invalid binding type: {$type}.","messagePattern":"Invalid binding type: (.+?)\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Query/Builder.php","lineNumber":4662,"sourceCode":"     */\n    public function getRawBindings()\n    {\n        return $this->bindings;\n    }\n\n    /**\n     * Set the bindings on the query builder.\n     *\n     * @param  list<mixed>  $bindings\n     * @param  \"select\"|\"from\"|\"join\"|\"where\"|\"groupBy\"|\"having\"|\"order\"|\"union\"|\"unionOrder\"  $type\n     * @return $this\n     *\n     * @throws \\InvalidArgumentException\n     */\n    public function setBindings(array $bindings, $type = 'where')\n    {\n        if (! array_key_exists($type, $this->bindings)) {\n            throw new InvalidArgumentException(\"Invalid binding type: {$type}.\");\n        }\n\n        $this->bindings[$type] = $bindings;\n\n        return $this;\n    }\n\n    /**\n     * Add a binding to the query.\n     *\n     * @param  mixed  $value\n     * @param  \"select\"|\"from\"|\"join\"|\"where\"|\"groupBy\"|\"having\"|\"order\"|\"union\"|\"unionOrder\"  $type\n     * @return $this\n     *\n     * @throws \\InvalidArgumentException\n     */\n    public function addBinding($value, $type = 'where')\n    {","sourceCodeStart":4644,"sourceCodeEnd":4680,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Database/Query/Builder.php#L4644-L4680","documentation":"Thrown by setBindings when $type is not one of the nine valid binding buckets: 'select', 'from', 'join', 'where', 'groupBy', 'having', 'order', 'union', 'unionOrder'. setBindings replaces the entire binding list for that bucket; an unknown type would leave orphan bindings that never get rendered, so the request is rejected up front.","triggerScenarios":"`->setBindings([1,2], 'orderBy')` (typo for 'order'). Passing `'limit'` or `'offset'` which are not binding buckets. Passing a computed string that resolves to a non-bucket name.","commonSituations":"Refactoring from positional to typed bindings with a wrong bucket name; code that builds the type from a column-friendly name; copy-paste between setBindings and addBinding with inconsistent enum sets.","solutions":["Use one of the nine valid types: select, from, join, where, groupBy, having, order, union, unionOrder.","Whitelist before calling: `$valid = ['select','from','join','where','groupBy','having','order','union','unionOrder']; in_array($type, $valid) or throw ...`.","Avoid setBindings unless you are reconstructing a query from cached SQL; prefer addBinding/where etc. which manage buckets for you.","Check the message: it echoes the bad type so the typo is visible."],"exampleFix":"// before\n$query->setBindings([1, 2], 'orderBy');\n// => Invalid binding type: orderBy.\n\n// after\n$query->setBindings([1, 2], 'order');","handlingStrategy":"type-guard","validationCode":"$valid = ['select','from','join','where','groupBy','having','order','union','unionOrder'];\nif (! in_array($type, $valid, true)) {\n    throw new \\InvalidArgumentException('setBindings type must be one of: '.implode(',', $valid));\n}","typeGuard":"/** @param 'select'|'from'|'join'|'where'|'groupBy'|'having'|'order'|'union'|'unionOrder' $t */\nfunction isValidBindingType(string $t): bool\n{\n    return in_array($t, ['select','from','join','where','groupBy','having','order','union','unionOrder'], true);\n}","tryCatchPattern":"// Validate the type before calling; setBindings is a low-level API, prefer fluent builders.","preventionTips":["Prefer where()/orderBy()/groupBy() helpers over manual setBindings.","Keep a const array of valid binding buckets and reuse it for validation.","Use PHPStan/@phpstan-param to constrain the type literal."],"tags":["query-builder","bindings","invalid-argument"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}