property-accessor.php

Simple property accessor library
git clone git://git.finwo.net/lib/property-accessor.php
Log | Files | Refs

commit 72522e2cfd910e5227ad33af773d4e100eb6f879
parent 7af45b988ab5d3615cf9fade61243f7f29326b09
Author: finwo <finwo@pm.me>
Date:   Fri, 22 Apr 2016 22:32:36 +0200

Referenced variables

Diffstat:
Msrc/PropertyAccessor.php | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/PropertyAccessor.php b/src/PropertyAccessor.php @@ -101,7 +101,7 @@ class PropertyAccessor * @return PropertyAccessor * @throws \Exception */ - public function set(&$subject, $path = '', $value, $pathSplit = '|') + public function set(&$subject, $path = '', &$value, $pathSplit = '|') { // try array for legacy mapper if (is_array($subject)) { @@ -168,7 +168,7 @@ class PropertyAccessor $rc = new \ReflectionObject($subject); foreach ($rc->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { if ($property->getName() == $path) { - $subject->{$path} = $value; + $subject->{$path} = &$value; return $this; } } @@ -187,10 +187,10 @@ class PropertyAccessor protected function getArrayProperty($input = array(), $path = array(), $splitChar = '|') { - $target = $input; + $target = &$input; foreach($path as $key) { if(isset($target[$key])) { - $target = $target[$key]; + $target = &$target[$key]; } else { if ($this->debug) return null; throw new \Exception(sprintf( @@ -253,7 +253,7 @@ class PropertyAccessor return; } - protected function setArrayProperty(&$input = array(), $path = array(), $value) + protected function setArrayProperty(&$input = array(), $path = array(), &$value) { $target = &$input; foreach($path as $key) {