2017 © Pedro Peláez
 

library util-member-accessor

Access to non public properties and methods

image

mjr/util-member-accessor

Access to non public properties and methods

  • Sunday, March 26, 2017
  • by cwesterfield
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Library MemberAccessor

This library allows to generate test code from a test description., (*1)

Installation

You can install this library with composer., (*2)

composer require 'kassko/util-member-accessor:master'

Usage

Given:, (*3)

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';
    }
}

Accessing SomeClass members:, (*4)

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".

The Versions

26/03 2017

dev-master

9999999-dev

Access to non public properties and methods

  Sources   Download

MIT

The Requires

  • php >=5.5

 

reflection accessor member private protected

26/03 2017

1.0.3

1.0.3.0

Access to non public properties and methods

  Sources   Download

MIT

The Requires

  • php >=5.5

 

reflection accessor member private protected