Open Abhishektharu opened 8 months ago
@Abhishektharu
When declared in the context of a class, the current class is automatically bound to it, making
$this
available inside of the function's scope.
— Anonymous functions, PHP.net
For example:
- $that = $this;
-
$dir = $this->fixtureDir(__FUNCTION__);
$root = $this->rootFromJson("{$dir}/composer.json");
$root->setRequires(Argument::type('array'))->will(
- function ($args) use ($that) {
+ function ($args) {
$requires = $args[0];
- $that->assertCount(1, $requires);
- $that->assertArrayHasKey('monolog/monolog', $requires);
+ $this->assertCount(1, $requires);
+ $this->assertArrayHasKey('monolog/monolog', $requires);
}
);
I removed $that = $this