Skip to content

Commit

Permalink
Fix Closure::bind() with $newScope = null
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanvelzen authored and ondrejmirtes committed Jun 20, 2022
1 parent 7a922a5 commit 3926ff8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion resources/functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@
'closelog' => ['bool'],
'Closure::__construct' => ['void'],
'Closure::__invoke' => ['', '...args='=>''],
'Closure::bind' => ['Closure', 'old'=>'Closure', 'to'=>'?object', 'scope='=>'object|string'],
'Closure::bind' => ['Closure', 'old'=>'Closure', 'to'=>'?object', 'scope='=>'object|string|null'],
'Closure::bindTo' => ['Closure', 'new'=>'?object', 'newscope='=>'object|string'],
'Closure::call' => ['', 'to'=>'object', '...parameters='=>''],
'Closure::fromCallable' => ['Closure', 'callable'=>'callable'],
Expand Down
7 changes: 7 additions & 0 deletions tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,4 +524,11 @@ public function testTemplateTypeInOneBranchOfConditional(): void
]);
}

public function testBug7489(): void
{
$this->checkThisOnly = false;
$this->checkExplicitMixed = true;
$this->analyse([__DIR__ . '/data/bug-7489.php'], []);
}

}
6 changes: 6 additions & 0 deletions tests/PHPStan/Rules/Methods/data/bug-7489.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php declare(strict_types = 1);

namespace Bug7489;

\Closure::bind(function () {
}, null, null)();

0 comments on commit 3926ff8

Please sign in to comment.