Skip to content

A controller parameter without default value creates ReflectionException error #1948

Description

@krishnan57474

Describe the bug
A controller parameter without default value creates error in routes collector toolbar.

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. Create parameter ( public function index(...$params) ) in index method
  3. run

You get

ReflectionException Internal error: Failed to retrieve the default value

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

    '<empty>&nbsp| default: ' . var_export($param->getDefaultValue(), true),

Calling $param->getDefaultValue() without isDefaultValueAvailable check causes this exists error.

Fix

    '<empty>&nbsp| default: ' . var_export($param->isDefaultValueAvailable() ? $param->getDefaultValue() : null, true),

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