Skip to content

Route::clone #169

@bkdotcom

Description

@bkdotcom

Route::__clone

    /**
     *
     * When cloning the Route, reset the `$attributes` to an empty array, and
     * clear the `$failedRule`.
     *
     */
    public function __clone()
    {
        // $this is the cloned instance, not the original
        $this->attributes = $this->defaults;
        $this->failedRule = null;
    }

comment says one thing / code does another

$map->allows(['GET', 'HEAD', 'POST'])->defaults(array(
    'action' => 'foo',
));
$route = $map->route('test', '/test');
$route->defaults(array('action'=>'not foo'));
var_dump($route->attributes);   // array('action'=>'foo')...  I would expect empty array()
var_dump($route->defaults);     // array('action'=>'not foo')

when dealing with routes I don't know if attribute came from url, or some inherited default
If I use Generator to build this new route it's going to use the inherited default over the new default

$this->attributes = $this->defaults;    // this does NOT reset `$attributes` to an empty array!!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions