Skip to content

Commit

Permalink
Remove hack to access class scope inside closures
Browse files Browse the repository at this point in the history
This is possible since 5.4
  • Loading branch information
carusogabriel committed Jul 22, 2019
1 parent 7dfc97b commit f84c71b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 3 additions & 5 deletions src/Symfony/Component/Console/Helper/ProgressIndicator.php
Expand Up @@ -192,11 +192,9 @@ private function display()
return;
}

$self = $this;

$this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) {
if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
return $formatter($self);
$this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) {
if ($formatter = self::getPlaceholderFormatterDefinition($matches[1])) {
return $formatter($this);
}

return $matches[0];
Expand Down
Expand Up @@ -843,10 +843,8 @@ public function testValidatesCachedResponsesWithLastModifiedAndNoFreshnessInform

public function testValidatesCachedResponsesUseSameHttpMethod()
{
$test = $this;

$this->setNextResponse(200, [], 'Hello World', function ($request, $response) use ($test) {
$test->assertSame('OPTIONS', $request->getMethod());
$this->setNextResponse(200, [], 'Hello World', function ($request, $response) {
$this->assertSame('OPTIONS', $request->getMethod());
});

// build initial request
Expand Down

0 comments on commit f84c71b

Please sign in to comment.