spiral / framework

High-Performance PHP Framework
https://spiral.dev
MIT License
1.82k stars 89 forks source link

[spiral/router] Required parameters are not required for uri generation #1162

Open MartkCz opened 1 month ago

MartkCz commented 1 month ago

Description

When a parameter is not passed, even though it is required in a route, it is ignored without raising an error.

How To Reproduce

$routes->add('articles.list', '/articles')
    ->callable(fn () => new Response());
$routes->add('articles.detail', '/articles/<id>')
    ->callable(fn () => new Response());

var_dump($router->uri('articles.detail')->getPath()); // == /articles - Better solution is exception or warning
var_dump($router->uri('articles.list')->getPath()); // == /articles
var_dump($router->uri('articles.detail', ['id' => 1])->getPath()); // == /articles/1 
roxblnfk commented 4 weeks ago

@butschster hi Could you comment the issue? Is it a bug or a feature?