minor #32648 Remove hack to access class scope inside closures (carusogabriel)

This PR was merged into the 4.4 branch.

Discussion
----------

Remove hack to access class scope inside closures

This is possible since 5.4.

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | -   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | - <!-- required for new features -->

<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against branch 4.4.
 - Legacy code removals go to the master branch.
-->

Commits
-------

f84c71b582 Remove hack to access class scope inside closures
This commit is contained in:
Tobias Schultze 2019-07-22 22:36:48 +02:00
commit e726161ad3
2 changed files with 5 additions and 9 deletions

View File

@ -192,11 +192,9 @@ class ProgressIndicator
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];

View File

@ -843,10 +843,8 @@ class HttpCacheTest extends HttpCacheTestCase
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