PHP code example of tasoft / value-injector

1. Go to this page and download the library: Download tasoft/value-injector 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/ */

    

tasoft / value-injector example snippets



use TASoft\Util\ValueInjector;

class PrivateClass {
    private $value;
    public function getValue() {
        return $this->value;
    }
}

$myObject = new PrivateClass();
echo $myObject->value; // Will fail
echo $myObject->getValue(); // Works

// But if you want to set the value, use my value injector:
$vi = new ValueInjector($myObject);
$vi->value = 23;

echo $myObject->getValue(); // 23