Skip to content

Instantly share code, notes, and snippets.

@rasismeiro
Forked from samsamm777/gist:7230159
Created December 16, 2015 22:19
Show Gist options
  • Save rasismeiro/df6161ecfda3f75f800b to your computer and use it in GitHub Desktop.
Save rasismeiro/df6161ecfda3f75f800b to your computer and use it in GitHub Desktop.

Revisions

  1. @samsamm777 samsamm777 revised this gist Oct 30, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    <?php

    $a = new A();
    $reflection = new \ReflectionClass($a);
    $property = $reflection->getProperty('privateProperty');
    $property->setAccessible(true);
    $property->setValue($a, 'new-value');
  2. @samsamm777 samsamm777 created this gist Oct 30, 2013.
    10 changes: 10 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    <?php

    $a = new A();
    $property = $reflection->getProperty('privateProperty');
    $property->setAccessible(true);
    $property->setValue($a, 'new-value');

    echo $a->getPrivateProperty();
    //outputs:
    //new-value