public function getPropertyAccessor($propertyName, $newValue) { return function () use($propertyName, $newValue) { $this->{$propertyName} = $newValue; }; }