MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / php_class_route_handler

Function php_class_route_handler

internal/cbm/extract_calls.c:3099–3122  ·  view source on GitHub ↗

Laravel's class-based route handlers (#1146), as "Ns\Class::method": * [UserController::class, 'show'] -> App\Http\Controllers\UserController::show * GetCurrentUserController::class -> App\...\GetCurrentUserController::__invoke * with the class qualified through the file's `use` imports; the route passes * place it on a method QN (cbm_registry_resolve_handler). NULL for any other * exp

Source from the content-addressed store, hash-verified

3097 * place it on a method QN (cbm_registry_resolve_handler). NULL for any other
3098 * expression. */
3099static const char *php_class_route_handler(CBMExtractCtx *ctx, TSNode arg) {
3100 const char *kind = ts_node_type(arg);
3101 if (strcmp(kind, "class_constant_access_expression") == 0) {
3102 const char *cls = php_class_literal_fqn(ctx, arg);
3103 return cls ? cbm_arena_sprintf(ctx->arena, "%s::__invoke", cls) : NULL;
3104 }
3105 if (strcmp(kind, "array_creation_expression") != 0 ||
3106 ts_node_named_child_count(arg) != PAIR_LEN) {
3107 return NULL;
3108 }
3109 TSNode cls_node = php_unkeyed_element_value(ts_node_named_child(arg, 0));
3110 TSNode method_node = php_unkeyed_element_value(ts_node_named_child(arg, SKIP_ONE));
3111 if (ts_node_is_null(cls_node) || ts_node_is_null(method_node)) {
3112 return NULL;
3113 }
3114 const char *cls = php_class_literal_fqn(ctx, cls_node);
3115 const char *mk = ts_node_type(method_node);
3116 if (!cls || (strcmp(mk, "string") != 0 && strcmp(mk, "encapsed_string") != 0)) {
3117 return NULL;
3118 }
3119 const char *method =
3120 strip_quotes(ctx->arena, cbm_node_text(ctx->arena, method_node, ctx->source));
3121 return php_is_identifier(method) ? cbm_arena_sprintf(ctx->arena, "%s::%s", cls, method) : NULL;
3122}
3123
3124static const char *extract_handler_arg(CBMExtractCtx *ctx, TSNode args) {
3125 /* The LAST eligible argument wins, and every argument is examined.

Callers 1

extract_handler_argFunction · 0.85

Calls 6

php_class_literal_fqnFunction · 0.85
cbm_node_textFunction · 0.85
php_is_identifierFunction · 0.85
cbm_arena_sprintfFunction · 0.70
strip_quotesFunction · 0.70

Tested by

no test coverage detected