Skip to content

Instantly share code, notes, and snippets.

@pgilad pgilad/test.php
Created Oct 24, 2018

Embed
What would you like to do?
Php instance property mutation
<?php
class State {
public $foo = 0;
}
class Mutator {
public function mutateState(State $state) {
$state->foo = 4;
}
}
$state = new State();
echo $state->foo . "\n";
$state->foo = 2;
echo $state->foo . "\n";
$mutator = new Mutator();
$mutator->mutateState($state);
echo $state->foo . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.