-
-
Save czukowski/8181ff90a7271a3f9bab9c5dc83a62a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Cz\Test\CompletionInClosure; | |
class Form | |
{ | |
public function validate(\Closure $then): void | |
{ | |
$then(); | |
} | |
} | |
class Service | |
{ | |
public function process(): void | |
{} | |
} | |
class Example | |
{ | |
/** | |
* @var Form | |
*/ | |
private $form; | |
/** | |
* @var Service | |
*/ | |
private $service; | |
public function __construct() | |
{ | |
$this->form = new Form; | |
$this->service = new Service; | |
} | |
public function run(): void | |
{ | |
// I'm going to uncomment each line `$this->service->` | |
// and try to invoke completion for `process()` method. | |
$this->form->validate( | |
function () { | |
// $this->service-> | |
// ----------------^ autocompletion here will NOT work | |
}, | |
); | |
// $this->service-> | |
// ----------------^ autocompletion here will work | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment