Skip to content

Instantly share code, notes, and snippets.

@romanzaycev
Last active February 13, 2020 16:37
Show Gist options
  • Save romanzaycev/4d99570a1b4c232a825b404010cf6a23 to your computer and use it in GitHub Desktop.
Save romanzaycev/4d99570a1b4c232a825b404010cf6a23 to your computer and use it in GitHub Desktop.
[PHP 7] Call protected method with Closure proxy
<?php
class Foo
{
protected function bar($param)
{
var_dump($param);
}
}
$param = 'Text param';
$instance = new Foo();
$proxy = function () use ($instance, $param) {
$instance->bar($param);
};
$proxy->call($instance);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment