1. Go to this page and download the library: Download mjr/util-member-accessor 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/ */
mjr / util-member-accessor example snippets
composer
class SomeClass
{
private $somePrivateProperty = 'some private property';
private function somePrivateMethod()
{
return 'some private method';
}
private function somePrivateMethodWithParam($paramA, $paramB)
{
return 'some private method with param \"$paramA\" and \"$paramB\"';
}
private function somePrivateProcedureMethod($paramA, &$paramB)
{
$paramB = 'baz';
}
}
use Kassko\Util\MemberAccessor\ObjectMemberAccessor;
$someObject = new SomeClass;
$accessor = new ObjectMemberAccessor;
$fooPropertyValue = $accessor->getPropertyValue($someObject, 'somePrivateProperty');
echo $fooPropertyValue;//Display 'some private property'.
$accessor->setPropertyValue($someObject, 'somePrivateProperty', 'foo');
//Set the value 'foo' in $somePrivateProperty.
$fooMethodValue = $accessor->getMethodValue($someObject, 'somePrivateMethod');
echo $fooMethodValue;//Display 'some private method'.
$fooMethodValue = $accessor->getMethodValue($someObject, 'somePrivateMethodWithParam', ['foo', 'bar']);
echo $fooMethodValue;//Display 'some private method with param "foo" and "bar"'.
$bar = 'bar';
$params = ['foo', &$bar];
$accessor->executeMethod($someObject, 'somePrivateProcedureMethod', [&$params]);
echo $params[0];//Display "foo".
echo $params[1];//Display "baz".
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.