Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Core_Std_DefaultObject___trait_IDefaultObject_shallowCopy()
- {
- $A = new SPLReflectionObject($this);
- $B = new SPLReflectionClass(static::class);
- $C = $B->newInstanceWithoutConstructor();
- $propertiesA = $A->getProperties();
- $propertiesB = $B->getProperties();
- foreach(array_keys($propertiesB) as $k)
- {
- if($propertiesB[$k]->isStatic()) //! it's PHP... http://stackoverflow.com/questions/15783984/reflection-properties-filter
- continue;
- $propertiesA[$k]->setAccessible(TRUE);
- $propertiesB[$k]->setAccessible(TRUE);
- $value = $propertiesA[$k]->getValue($this);
- $value = $this->__Core_Std_DefaultObject___trait_IDefaultObject___copyRecursive($C, FALSE, $value);
- $propertiesB[$k]->setValue($C, $value);
- }
- return $C;
- }
- private function __Core_Std_DefaultObject___trait_IDefaultObject___copyRecursive(IDefaultObject $__Context, $__isDeep = FALSE, $__data)
- {
- if($__data === $__Context)
- return $__data;
- if(is_array($__data))
- {
- foreach($__data as $k => $value)
- $__data[$k] = $this->{__FUNCTION__}($__Context, $__isDeep, $value);
- return $__data;
- }
- if(FALSE === is_object($__data))
- return $__data;
- if(TRUE === $__isDeep)
- {
- switch(TRUE):
- case $__data instanceOf IDefaultObject:
- $__data = $__data->deepCopy();
- break;
- case $__data instanceOf SPLClosure:
- $__data = $__data->bindTo($__Context, $__Context);
- break;
- case $__data instanceOf Fn:
- $__data = $__data->bind($__Context, $__Context);
- break;
- default:
- $__data = clone $__data;
- endswitch;
- }
- else
- {
- switch(TRUE):
- case $__data instanceOf SPLClosure:
- $__data = $__data->bindTo($__Context, $__Context);
- break;
- case $__data instanceOf Fn:
- $__data = $__data->bind($__Context, $__Context);
- break;
- endswitch;
- }
- return $__data;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement