Skip to content

m4y4-dev/php-property-reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

php-property-reader

A simple class implementation of a property reader introduced/suggested by Marco Pivetta (Ocramius) here: https://ocramius.github.io/blog/accessing-private-php-class-members-without-reflection/

Example

<?php

require 'PropertyReader.php';

use PropertyReader\PropertyReader;

class Greeter
{
    private $greeting = 'Hi there!';

    public function getGreeting()
    {
        return $this->greeting;
    }
}

$greeter = new Greeter;

echo $greeter->getGreeting(); // Hi there!

$greeting = & PropertyReader::read($greeter, 'greeting');
$greeting = 'Nice to meet you!';

echo $greeter->getGreeting(); // Nice to meet you!

For php version < 7

$geeting = & PropertyReader::newInstance()->read($greeter, 'greeting');

About

A simple class implementation of a property reader introduced/suggested by Marco Pivetta (Ocramius) here: https://ocramius.github.io/blog/accessing-private-php-class-members-without-reflection/

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages