Skip to content

Instantly share code, notes, and snippets.

@czukowski
Created August 15, 2019 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czukowski/8181ff90a7271a3f9bab9c5dc83a62a1 to your computer and use it in GitHub Desktop.
Save czukowski/8181ff90a7271a3f9bab9c5dc83a62a1 to your computer and use it in GitHub Desktop.
<?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