{"record":{"id":"bd71b39c2868a960","repo":"w7corp/easywechat","slug":"the-method-s-is-not-supported","errorCode":null,"errorMessage":"The method \"%s\" is not supported.","messagePattern":"The method \"(.+?)\" is not supported\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Kernel/HttpClient/RequestWithPresets.php","lineNumber":167,"sourceCode":"            $options['headers'] = array_merge($this->prependHeaders, $options['headers'] ?? []);\n        }\n\n        $this->prependParts = [];\n        $this->prependHeaders = [];\n\n        return $options;\n    }\n\n    /**\n     * @throws InvalidArgumentException\n     */\n    public function handleMagicWithCall(string $method, mixed $value = null): static\n    {\n        // $client->withAppid();\n        // $client->withAppid('wxf8b4f85f3a794e77');\n        // $client->withAppidAs('sub_appid');\n        if (! str_starts_with($method, 'with')) {\n            throw new InvalidArgumentException(sprintf('The method \"%s\" is not supported.', $method));\n        }\n\n        $key = Str::snakeCase(substr($method, 4));\n\n        // $client->withAppidAs('sub_appid');\n        if (str_ends_with($key, '_as')) {\n            $key = substr($key, 0, -3);\n\n            [$key, $value] = [is_string($value) ? $value : $key, $this->presets[$key] ?? null];\n        }\n\n        return $this->with($key, $value);\n    }\n}\n","sourceCodeStart":149,"sourceCodeEnd":182,"githubUrl":"https://github.com/w7corp/easywechat/blob/f0cf0a8b8361417ed683b8246d0ecbaf0aafcaa8/src/Kernel/HttpClient/RequestWithPresets.php#L149-L182","documentation":"RequestWithPresets::handleMagicWithCall() powers fluent magic setters on API clients — withAppid('wx...'), withAppidAs('sub_appid') — by convention: the method name must start with 'with', the remainder is snake_cased into a preset key. Any name that does not start with 'with' is rejected with InvalidArgumentException listing the unsupported method.","triggerScenarios":"Calling $client->handleMagicWithCall('setAppid', ...) or similar directly, or a client's __call forwarding a non-'with' method (e.g. $client->appid('wx...') instead of $client->withAppid('wx...')) into the preset handler.","commonSituations":"Assuming generic magic setters exist (set/get style) on EasyWeChat request clients, copy-pasting code from other SDKs with different conventions.","solutions":["Use the 'with' prefix: $client->withFoo($value) — the part after 'with' becomes the preset key 'foo'","To alias a preset to a custom key use withFooAs('custom_key')","For arbitrary keys bypass magic entirely: $client->with('sub_appid', $value)"],"exampleFix":"// before\n$client->appid('wxf8b4f85f3a794e77'); // routed to handleMagicWithCall -> throws\n\n// after\n$client->withAppid('wxf8b4f85f3a794e77');\n// or explicit\n$client->with('appid', 'wxf8b4f85f3a794e77');","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Only route 'with'-prefixed calls to the preset handler\nif (method_exists($client, $method) || ! str_starts_with($method, 'with')) {\n    return $client->$method(...$args); // normal call, not a preset\n}\nreturn $client->handleMagicWithCall($method, ...$args);","tryCatchPattern":null,"preventionTips":["Use the withXxx naming convention for fluent preset setters","Use ->with('key', $value) for arbitrary keys"],"tags":["php","easywechat","http-client","magic-methods","api-misuse"],"backgroundTag":"unsupported-method-call","analyzedSha":"f0cf0a8b8361417ed683b8246d0ecbaf0aafcaa8","analyzedAt":"2026-08-21T05:29:19.565Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}