Skip to content

[TwigBridge] Fix casing of getCurrentRoute/getCurrentRouteParameters methods #48434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Twig/AppVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function getFlashes(string|array $types = null): array
return $result;
}

public function getCurrent_Route(): ?string
public function getCurrent_route(): ?string
{
if (!isset($this->requestStack)) {
throw new \RuntimeException('The "app.current_route" variable is not available.');
Expand All @@ -171,7 +171,7 @@ public function getCurrent_Route(): ?string
/**
* @return array<string, mixed>
*/
public function getCurrent_Route_Parameters(): array
public function getCurrent_route_parameters(): array
{
if (!isset($this->requestStack)) {
throw new \RuntimeException('The "app.current_route_parameters" variable is not available.');
Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Bridge/Twig/Tests/AppVariableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,34 +232,34 @@ public function testGetCurrentRoute()
{
$this->setRequestStack(new Request(attributes: ['_route' => 'some_route']));

$this->assertSame('some_route', $this->appVariable->getCurrent_Route());
$this->assertSame('some_route', $this->appVariable->getCurrent_route());
}

public function testGetCurrentRouteWithRequestStackNotSet()
{
$this->expectException(\RuntimeException::class);
$this->appVariable->getCurrent_Route();
$this->appVariable->getCurrent_route();
}

public function testGetCurrentRouteParameters()
{
$routeParams = ['some_param' => true];
$this->setRequestStack(new Request(attributes: ['_route_params' => $routeParams]));

$this->assertSame($routeParams, $this->appVariable->getCurrent_Route_Parameters());
$this->assertSame($routeParams, $this->appVariable->getCurrent_route_parameters());
}

public function testGetCurrentRouteParametersWithoutAttribute()
{
$this->setRequestStack(new Request());

$this->assertSame([], $this->appVariable->getCurrent_Route_Parameters());
$this->assertSame([], $this->appVariable->getCurrent_route_parameters());
}

public function testGetCurrentRouteParametersWithRequestStackNotSet()
{
$this->expectException(\RuntimeException::class);
$this->appVariable->getCurrent_Route_Parameters();
$this->appVariable->getCurrent_route_parameters();
}

protected function setRequestStack($request)
Expand Down