Skip to content

Unable to use _remap without default method in controller #1928

Description

@krishnan57474

Describe the bug
A controller with method other than _remap
creates error in routes toolbar collector.

CodeIgniter 4 version
CodeIgniter4 Beta 0.0.2

Affected module(s)
system\Debug\Toolbar\Collectors\Routes.php

Expected behavior, and steps to reproduce if appropriate

  1. Set CodeIgniter environment to development
  2. Rename index method to _remap in app/Controllers/Home.php
  3. run

You get method not exists error.

The following statement in system\Debug\Toolbar\Collectors\Routes.php:

    $method    = is_callable($router->controllerName()) ? new \ReflectionFunction($router->controllerName()) : new \ReflectionMethod($router->controllerName(), $router->methodName());

Calling \ReflectionMethod($router->controllerName(), $router->methodName()) without method_exists check
causes method not exists error.

Fix

    $method    = is_callable($router->controllerName()) ? new \ReflectionFunction($router->controllerName()) : new \ReflectionMethod($router->controllerName(), method_exists($router->controllerName(), '_remap') ? '_remap' : $router->methodName());

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions