1. Go to this page and download the library: Download christopheraue/phpspy library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
class VIP
{
private $_secret;
public function learnSecret($secret)
{
$this->_secret = $secret;
}
}
$vip = new VIP();
$spy = new \christopheraue\phpspy\Spy("VIP", "learnSecret");
$vip->learnSecret("The cake is a lie.");
echo $spy->getCallCount(); //1
echo $spy->getCall(0)->getArg(0); //"The cake is a lie."
echo $spy->getCall(0)->getContext(); //$vip
class VIP
{
public static function id($in)
{
return $in;
}
}
$spy = new \christopheraue\phpspy\Spy("VIP", "id");
VIP::id("static, static, static.");
echo $spy->getCallCount(); //1
echo $spy->getCall(0)->getResult(); //"static, static, static."
echo $spy->getCall(0)->getContext(); //"VIP"
function id($in)
{
return $in;
}
$spy = new \christopheraue\phpspy\Spy("id");
//substitute for an anonymous function
$spy->actAs(function($in) {
//do something
});
//substitute for another function
$spy->actAs('functionName');
//substitute for a method
$spy->actAs(array($object, 'method'));
//call through again
$spy->actNaturally();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.