public function instanceHandle($mock, $label = null)
{
if ($mock instanceof InstanceHandle) {
return $mock;
}
if (!$mock instanceof Mock) {
throw new InvalidMockException($mock);
}
$class = new ReflectionClass($mock);
$handleProperty = $class->getProperty('_handle');
$handleProperty->setAccessible(true);
$handle = @$handleProperty->getValue($mock);
if ($handle) {
return $handle;
}
$handle = new InstanceHandle($mock, (object) array('defaultAnswerCallback' => 'Eloquent\\Phony\\Stub\\StubData::returnsEmptyAnswerCallback', 'stubs' => (object) array(), 'isRecording' => true, 'label' => $label), $this->stubFactory, $this->stubVerifierFactory, $this->assertionRenderer, $this->assertionRecorder, $this->invoker);
@$handleProperty->setValue($mock, $handle);
return $handle;
}