{"record":{"id":"b2d183f295f97607","repo":"moodle/moodle","slug":"call-to-undefined-method-method","errorCode":null,"errorMessage":"Call to undefined method $method","messagePattern":"Call to undefined method \\$method","errorType":"exception","errorClass":"BadMethodCallException","httpStatus":null,"severity":"error","filePath":"public/lib/jmespath/src/Parser.php","lineNumber":517,"sourceCode":"    public function __call($method, $args)\n    {\n        $prefix = substr($method, 0, 4);\n        if ($prefix == 'nud_' || $prefix == 'led_') {\n            $token = substr($method, 4);\n            $message = \"Unexpected \\\"$token\\\" token ($method). Expected one of\"\n                . \" the following tokens: \"\n                . implode(', ', array_map(function ($i) {\n                    return '\"' . substr($i, 4) . '\"';\n                }, array_filter(\n                    get_class_methods($this),\n                    function ($i) use ($prefix) {\n                        return strpos($i, $prefix) === 0;\n                    }\n                )));\n            throw $this->syntax($message);\n        }\n\n        throw new \\BadMethodCallException(\"Call to undefined method $method\");\n    }\n}\n","sourceCodeStart":499,"sourceCodeEnd":520,"githubUrl":"https://github.com/moodle/moodle/blob/48ea8c33227277e916cdd4079dbecef448b37f2c/public/lib/jmespath/src/Parser.php#L499-L520","documentation":"Parser::__call throws BadMethodCallException 'Call to undefined method $method' when an internal parse-state method is invoked that the parser does not implement. This is an internal invariant violation: the parser's state table dispatched to a handler (typically a r_* parsing rule) that does not exist in the installed version — usually caused by a mismatched/corrupted installation or custom parse states.","triggerScenarios":"The parser's transition table references a rule method absent from Parser.php; typically triggered during compilation (JmesPath\\Env::compile / search with AST caching) of an expression whose parse path hits a missing handler, or after partially upgrading/copying library files.","commonSituations":"Mixed library versions (e.g. a copied src/ folder missing files), custom subclasses overriding parse state handlers, or bytecode/cached ASTs from a different jmespath.php version.","solutions":["Reinstall the jmespath.php package cleanly (composer update / vendor:publish, delete vendor/ and reinstall)","Clear any cached compiled ASTs from a different library version","Check for local modifications or subclassing of JmesPath\\Parser and revert them","If reproducible on a stock install, report the expression as a bug with your library version"],"exampleFix":"// before (partial manual copy of src/)\nrequire 'lib/jmespath/src/Parser.php';\n// after\ncomposer require mtdowling/jmespath.php\nrequire 'vendor/autoload.php';","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { $result = JmesPath\\search($expr, $data); } catch (\\BadMethodCallException $e) { if (strpos($e->getMessage(), 'Call to undefined method') === 0) { // library install/version issue: reinstall, clear compiled caches, disable AST cache dir } else { throw $e; } }","preventionTips":["Always install jmespath.php via composer; never hand-copy individual src/ files","Pin the package version and clear cache directories when upgrading","Avoid subclassing or monkey-patching JmesPath\\Parser internals","Reproduce failing expressions in a clean vendor install before filing bugs"],"tags":["php","jmespath","bad-method-call","internal","parser"],"backgroundTag":"internal-invariant-violation","analyzedSha":"48ea8c33227277e916cdd4079dbecef448b37f2c","analyzedAt":"2026-09-14T20:34:48.527Z","contentChangedAt":"2026-09-14T20:34:48.527Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}