Last active
February 13, 2020 16:37
-
-
Save romanzaycev/4d99570a1b4c232a825b404010cf6a23 to your computer and use it in GitHub Desktop.
[PHP 7] Call protected method with Closure proxy
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 | |
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