-
-
Save Ocramius/e4f481dd1d4f93adffb0646a780d1217 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace ProxyManagerTest\Functional; | |
class Foo5731cbdb7cfb2968834795 extends \ProxyManagerTestAsset\ClassWithProtectedProperties implements \ProxyManager\Proxy\GhostObjectInterface | |
{ | |
/** | |
* @var \Closure|null initializer responsible for generating the wrapped object | |
*/ | |
private $initializer5731cbdb7cffb583775228 = null; | |
/** | |
* @var bool tracks initialization status - true while the object is initializing | |
*/ | |
private $initializationTracker5731cbdb7d001134221031 = false; | |
/** | |
* @var bool[] map of public properties of the parent class | |
*/ | |
private static $publicProperties5731cbdb7cfd6063402948 = array( | |
); | |
/** | |
* @var array[][] visibility and default value of defined properties, indexed by | |
* property name and class name | |
*/ | |
private static $privateProperties5731cbdb7cfe5357704282 = array( | |
); | |
/** | |
* @var string[][] declaring class name of defined protected properties, indexed by | |
* property name | |
*/ | |
private static $protectedProperties5731cbdb7cfed889038150 = array( | |
'property0' => 'ProxyManagerTestAsset\\ClassWithProtectedProperties', | |
'property1' => 'ProxyManagerTestAsset\\ClassWithProtectedProperties', | |
'property2' => 'ProxyManagerTestAsset\\ClassWithProtectedProperties', | |
'property3' => 'ProxyManagerTestAsset\\ClassWithProtectedProperties', | |
'property4' => 'ProxyManagerTestAsset\\ClassWithProtectedProperties', | |
'property5' => 'ProxyManagerTestAsset\\ClassWithProtectedProperties', | |
'property6' => 'ProxyManagerTestAsset\\ClassWithProtectedProperties', | |
'property7' => 'ProxyManagerTestAsset\\ClassWithProtectedProperties', | |
'property8' => 'ProxyManagerTestAsset\\ClassWithProtectedProperties', | |
'property9' => 'ProxyManagerTestAsset\\ClassWithProtectedProperties', | |
); | |
/** | |
* Triggers initialization logic for this ghost object | |
* | |
* @param string $methodName | |
* @param mixed[] $parameters | |
* | |
* @return mixed | |
*/ | |
private function callInitializer5731cbdb7d009166243431($methodName, array $parameters) | |
{ | |
if ($this->initializationTracker5731cbdb7d001134221031 || ! $this->initializer5731cbdb7cffb583775228) { | |
return; | |
} | |
$this->initializationTracker5731cbdb7d001134221031 = true; | |
$this->property0 = 'property0'; | |
$this->property1 = 'property1'; | |
$this->property2 = 'property2'; | |
$this->property3 = 'property3'; | |
$this->property4 = 'property4'; | |
$this->property5 = 'property5'; | |
$this->property6 = 'property6'; | |
$this->property7 = 'property7'; | |
$this->property8 = 'property8'; | |
$this->property9 = 'property9'; | |
$properties = [ | |
'' . "\0" . '*' . "\0" . 'property0' => & $this->property0, | |
'' . "\0" . '*' . "\0" . 'property1' => & $this->property1, | |
'' . "\0" . '*' . "\0" . 'property2' => & $this->property2, | |
'' . "\0" . '*' . "\0" . 'property3' => & $this->property3, | |
'' . "\0" . '*' . "\0" . 'property4' => & $this->property4, | |
'' . "\0" . '*' . "\0" . 'property5' => & $this->property5, | |
'' . "\0" . '*' . "\0" . 'property6' => & $this->property6, | |
'' . "\0" . '*' . "\0" . 'property7' => & $this->property7, | |
'' . "\0" . '*' . "\0" . 'property8' => & $this->property8, | |
'' . "\0" . '*' . "\0" . 'property9' => & $this->property9, | |
]; | |
$result = $this->initializer5731cbdb7cffb583775228->__invoke($this, $methodName, $parameters, $this->initializer5731cbdb7cffb583775228, $properties); | |
$this->initializationTracker5731cbdb7d001134221031 = false; | |
return $result; | |
} | |
/** | |
* Constructor for lazy initialization | |
* | |
* @param \Closure|null $initializer | |
*/ | |
public static function staticProxyConstructor($initializer) | |
{ | |
static $reflection; | |
$reflection = $reflection ?: $reflection = new \ReflectionClass(__CLASS__); | |
$instance = (new \ReflectionClass(get_class()))->newInstanceWithoutConstructor(); | |
unset($instance->property0, $instance->property1, $instance->property2, $instance->property3, $instance->property4, $instance->property5, $instance->property6, $instance->property7, $instance->property8, $instance->property9); | |
$instance->initializer5731cbdb7cffb583775228 = $initializer; | |
return $instance; | |
} | |
/** | |
* @param string $name | |
*/ | |
public function & __get($name) | |
{ | |
$this->initializer5731cbdb7cffb583775228 && ! $this->initializationTracker5731cbdb7d001134221031 && $this->callInitializer5731cbdb7d009166243431('__get', array('name' => $name)); | |
if (isset(self::$publicProperties5731cbdb7cfd6063402948[$name])) { | |
return $this->$name; | |
} | |
if (isset(self::$protectedProperties5731cbdb7cfed889038150[$name])) { | |
if ($this->initializationTracker5731cbdb7d001134221031) { | |
return $this->$name; | |
} | |
// check protected property access via compatible class | |
$callers = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); | |
$caller = isset($callers[1]) ? $callers[1] : []; | |
$object = isset($caller['object']) ? $caller['object'] : ''; | |
$expectedType = self::$protectedProperties5731cbdb7cfed889038150[$name]; | |
if ($object instanceof $expectedType) { | |
return $this->$name; | |
} | |
$class = isset($caller['class']) ? $caller['class'] : ''; | |
if ($class === $expectedType || is_subclass_of($class, $expectedType) || $class === 'ReflectionProperty') { | |
return $this->$name; | |
} | |
} elseif (isset(self::$privateProperties5731cbdb7cfe5357704282[$name])) { | |
// check private property access via same class | |
$callers = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); | |
$caller = isset($callers[1]) ? $callers[1] : []; | |
$class = isset($caller['class']) ? $caller['class'] : ''; | |
static $accessorCache = []; | |
if (isset(self::$privateProperties5731cbdb7cfe5357704282[$name][$class])) { | |
$cacheKey = $class . '#' . $name; | |
$accessor = isset($accessorCache[$cacheKey]) | |
? $accessorCache[$cacheKey] | |
: $accessorCache[$cacheKey] = \Closure::bind(function & ($instance) use ($name) { | |
return $instance->$name; | |
}, null, $class); | |
return $accessor($this); | |
} | |
if ($this->initializationTracker5731cbdb7d001134221031 || 'ReflectionProperty' === $class) { | |
$tmpClass = key(self::$privateProperties5731cbdb7cfe5357704282[$name]); | |
$cacheKey = $tmpClass . '#' . $name; | |
$accessor = isset($accessorCache[$cacheKey]) | |
? $accessorCache[$cacheKey] | |
: $accessorCache[$cacheKey] = \Closure::bind(function & ($instance) use ($name) { | |
return $instance->$name; | |
}, null, $tmpClass); | |
return $accessor($this); | |
} | |
} | |
$realInstanceReflection = new \ReflectionClass(get_parent_class($this)); | |
if (! $realInstanceReflection->hasProperty($name)) { | |
$targetObject = $this; | |
$backtrace = debug_backtrace(false); | |
trigger_error('Undefined property: ' . get_parent_class($this) . '::$' . $name . ' in ' . $backtrace[0]['file'] . ' on line ' . $backtrace[0]['line'], \E_USER_NOTICE); | |
return $targetObject->$name; | |
return; | |
} | |
$targetObject = unserialize(sprintf('O:%d:"%s":0:{}', strlen(get_parent_class($this)), get_parent_class($this))); | |
$accessor = function & () use ($targetObject, $name) { | |
return $targetObject->$name; | |
}; | |
$backtrace = debug_backtrace(true); | |
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub(); | |
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject)); | |
$returnValue = & $accessor(); | |
return $returnValue; | |
} | |
/** | |
* @param string $name | |
*/ | |
public function __set($name, $value) | |
{ | |
$this->initializer5731cbdb7cffb583775228 && $this->callInitializer5731cbdb7d009166243431('__set', array('name' => $name, 'value' => $value)); | |
if (isset(self::$publicProperties5731cbdb7cfd6063402948[$name])) { | |
return ($this->$name = $value); | |
} | |
if (isset(self::$protectedProperties5731cbdb7cfed889038150[$name])) { | |
// check protected property access via compatible class | |
$callers = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); | |
$caller = isset($callers[1]) ? $callers[1] : []; | |
$object = isset($caller['object']) ? $caller['object'] : ''; | |
$expectedType = self::$protectedProperties5731cbdb7cfed889038150[$name]; | |
if ($object instanceof $expectedType) { | |
return ($this->$name = $value); | |
} | |
$class = isset($caller['class']) ? $caller['class'] : ''; | |
if ($class === $expectedType || is_subclass_of($class, $expectedType) || $class === 'ReflectionProperty') { | |
return ($this->$name = $value); | |
} | |
} elseif (isset(self::$privateProperties5731cbdb7cfe5357704282[$name])) { | |
// check private property access via same class | |
$callers = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); | |
$caller = isset($callers[1]) ? $callers[1] : []; | |
$class = isset($caller['class']) ? $caller['class'] : ''; | |
static $accessorCache = []; | |
if (isset(self::$privateProperties5731cbdb7cfe5357704282[$name][$class])) { | |
$cacheKey = $class . '#' . $name; | |
$accessor = isset($accessorCache[$cacheKey]) | |
? $accessorCache[$cacheKey] | |
: $accessorCache[$cacheKey] = \Closure::bind(function ($instance, $value) use ($name) { | |
return ($instance->$name = $value); | |
}, null, $class); | |
return $accessor($this, $value); | |
} | |
if ('ReflectionProperty' === $class) { | |
$tmpClass = key(self::$privateProperties5731cbdb7cfe5357704282[$name]); | |
$cacheKey = $tmpClass . '#' . $name; | |
$accessor = isset($accessorCache[$cacheKey]) | |
? $accessorCache[$cacheKey] | |
: $accessorCache[$cacheKey] = \Closure::bind(function ($instance, $value) use ($name) { | |
return ($instance->$name = $value); | |
}, null, $tmpClass); | |
return $accessor($this, $value); | |
} | |
} | |
$realInstanceReflection = new \ReflectionClass(get_parent_class($this)); | |
if (! $realInstanceReflection->hasProperty($name)) { | |
$targetObject = $this; | |
return $targetObject->$name = $value; | |
return; | |
} | |
$targetObject = unserialize(sprintf('O:%d:"%s":0:{}', strlen(get_parent_class($this)), get_parent_class($this))); | |
$accessor = function & () use ($targetObject, $name, $value) { | |
return $targetObject->$name = $value; | |
}; | |
$backtrace = debug_backtrace(true); | |
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub(); | |
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject)); | |
$returnValue = & $accessor(); | |
return $returnValue; | |
} | |
/** | |
* @param string $name | |
*/ | |
public function __isset($name) | |
{ | |
$this->initializer5731cbdb7cffb583775228 && $this->callInitializer5731cbdb7d009166243431('__isset', array('name' => $name)); | |
if (isset(self::$publicProperties5731cbdb7cfd6063402948[$name])) { | |
return isset($this->$name); | |
} | |
if (isset(self::$protectedProperties5731cbdb7cfed889038150[$name])) { | |
// check protected property access via compatible class | |
$callers = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); | |
$caller = isset($callers[1]) ? $callers[1] : []; | |
$object = isset($caller['object']) ? $caller['object'] : ''; | |
$expectedType = self::$protectedProperties5731cbdb7cfed889038150[$name]; | |
if ($object instanceof $expectedType) { | |
return isset($this->$name); | |
} | |
$class = isset($caller['class']) ? $caller['class'] : ''; | |
if ($class === $expectedType || is_subclass_of($class, $expectedType)) { | |
return isset($this->$name); | |
} | |
} else { | |
// check private property access via same class | |
$callers = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); | |
$caller = isset($callers[1]) ? $callers[1] : []; | |
$class = isset($caller['class']) ? $caller['class'] : ''; | |
static $accessorCache = []; | |
if (isset(self::$privateProperties5731cbdb7cfe5357704282[$name][$class])) { | |
$cacheKey = $class . '#' . $name; | |
$accessor = isset($accessorCache[$cacheKey]) | |
? $accessorCache[$cacheKey] | |
: $accessorCache[$cacheKey] = \Closure::bind(function ($instance) use ($name) { | |
return isset($instance->$name); | |
}, null, $class); | |
return $accessor($this); | |
} | |
if ('ReflectionProperty' === $class) { | |
$tmpClass = key(self::$privateProperties5731cbdb7cfe5357704282[$name]); | |
$cacheKey = $tmpClass . '#' . $name; | |
$accessor = isset($accessorCache[$cacheKey]) | |
? $accessorCache[$cacheKey] | |
: $accessorCache[$cacheKey] = \Closure::bind(function ($instance) use ($name) { | |
return isset($instance->$name); | |
}, null, $tmpClass); | |
return $accessor($this); | |
} | |
} | |
$realInstanceReflection = new \ReflectionClass(get_parent_class($this)); | |
if (! $realInstanceReflection->hasProperty($name)) { | |
$targetObject = $this; | |
return isset($targetObject->$name); | |
return; | |
} | |
$targetObject = unserialize(sprintf('O:%d:"%s":0:{}', strlen(get_parent_class($this)), get_parent_class($this))); | |
$accessor = function () use ($targetObject, $name) { | |
return isset($targetObject->$name); | |
}; | |
$backtrace = debug_backtrace(true); | |
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub(); | |
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject)); | |
$returnValue = $accessor(); | |
return $returnValue; | |
} | |
/** | |
* @param string $name | |
*/ | |
public function __unset($name) | |
{ | |
$this->initializer5731cbdb7cffb583775228 && $this->callInitializer5731cbdb7d009166243431('__unset', array('name' => $name)); | |
if (isset(self::$publicProperties5731cbdb7cfd6063402948[$name])) { | |
unset($this->$name); | |
return; | |
} | |
if (isset(self::$protectedProperties5731cbdb7cfed889038150[$name])) { | |
// check protected property access via compatible class | |
$callers = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); | |
$caller = isset($callers[1]) ? $callers[1] : []; | |
$object = isset($caller['object']) ? $caller['object'] : ''; | |
$expectedType = self::$protectedProperties5731cbdb7cfed889038150[$name]; | |
if ($object instanceof $expectedType) { | |
unset($this->$name); | |
return; | |
} | |
$class = isset($caller['class']) ? $caller['class'] : ''; | |
if ($class === $expectedType || is_subclass_of($class, $expectedType) || $class === 'ReflectionProperty') { | |
unset($this->$name); | |
return; | |
} | |
} elseif (isset(self::$privateProperties5731cbdb7cfe5357704282[$name])) { | |
// check private property access via same class | |
$callers = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); | |
$caller = isset($callers[1]) ? $callers[1] : []; | |
$class = isset($caller['class']) ? $caller['class'] : ''; | |
static $accessorCache = []; | |
if (isset(self::$privateProperties5731cbdb7cfe5357704282[$name][$class])) { | |
$cacheKey = $class . '#' . $name; | |
$accessor = isset($accessorCache[$cacheKey]) | |
? $accessorCache[$cacheKey] | |
: $accessorCache[$cacheKey] = \Closure::bind(function ($instance) use ($name) { | |
unset($instance->$name); | |
}, null, $class); | |
return $accessor($this); | |
} | |
if ('ReflectionProperty' === $class) { | |
$tmpClass = key(self::$privateProperties5731cbdb7cfe5357704282[$name]); | |
$cacheKey = $tmpClass . '#' . $name; | |
$accessor = isset($accessorCache[$cacheKey]) | |
? $accessorCache[$cacheKey] | |
: $accessorCache[$cacheKey] = \Closure::bind(function ($instance) use ($name) { | |
unset($instance->$name); | |
}, null, $tmpClass); | |
return $accessor($this); | |
} | |
} | |
$realInstanceReflection = new \ReflectionClass(get_parent_class($this)); | |
if (! $realInstanceReflection->hasProperty($name)) { | |
$targetObject = $this; | |
unset($targetObject->$name); | |
return; | |
} | |
$targetObject = unserialize(sprintf('O:%d:"%s":0:{}', strlen(get_parent_class($this)), get_parent_class($this))); | |
$accessor = function () use ($targetObject, $name) { | |
unset($targetObject->$name); | |
}; | |
$backtrace = debug_backtrace(true); | |
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub(); | |
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject)); | |
$returnValue = $accessor(); | |
return $returnValue; | |
} | |
public function __clone() | |
{ | |
$this->initializer5731cbdb7cffb583775228 && $this->callInitializer5731cbdb7d009166243431('__clone', []); | |
} | |
public function __sleep() | |
{ | |
$this->initializer5731cbdb7cffb583775228 && $this->callInitializer5731cbdb7d009166243431('__sleep', []); | |
return array_keys((array) $this); | |
} | |
/** | |
* {@inheritDoc} | |
*/ | |
public function setProxyInitializer(\Closure $initializer = null) | |
{ | |
$this->initializer5731cbdb7cffb583775228 = $initializer; | |
} | |
/** | |
* {@inheritDoc} | |
*/ | |
public function getProxyInitializer() | |
{ | |
return $this->initializer5731cbdb7cffb583775228; | |
} | |
/** | |
* {@inheritDoc} | |
*/ | |
public function initializeProxy() : bool | |
{ | |
return $this->initializer5731cbdb7cffb583775228 && $this->callInitializer5731cbdb7d009166243431('initializeProxy', []); | |
} | |
/** | |
* {@inheritDoc} | |
*/ | |
public function isProxyInitialized() : bool | |
{ | |
return ! $this->initializer5731cbdb7cffb583775228; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cannot access private property ProxyManagerTest\Functional\Foo5731cbdb7cfb2968834795::$publicProperties5731cbdb7cfd6063402948 | |
/Users/ocramius/Documents/Projects/ProxyManager/tests/ProxyManagerTest/Functional/ProxyManagerTestFunctionalFoo5731cbdb7cfb2968834795.php:125 | |
/Users/ocramius/Documents/Projects/ProxyManager/tests/ProxyManagerTest/Functional/ProxyManagerTestFunctionalFoo5731cbdb7cfb2968834795.php:123 | |
/Users/ocramius/Documents/Projects/ProxyManager/tests/ProxyManagerTest/Functional/LazyLoadingGhostFunctionalTest.php:405 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment