Last active
October 13, 2015 12:09
-
-
Save toby-griffiths/1d0e85d33f3092a42d54 to your computer and use it in GitHub Desktop.
Change to clone argument objects
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 | |
class Unwrapper implements RevealerInterface | |
{ | |
// ... | |
/** | |
* @param mixed $argument | |
* | |
* @return mixed | |
*/ | |
public function unwrapOne($argument) | |
{ | |
// ... | |
if ($argument instanceof ProphecyInterface) { | |
$argument = $argument->reveal(); | |
} | |
// Adding this bit! | |
$r = new \ReflectionObject($argument); | |
if ($r->isCloneable()) { | |
$argument = clone $argument; | |
} | |
return $argument; | |
} | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Having tried this against the PHPSpec tests, it appears to only break one test…
spec/PhpSpec/Exception/ExceptionFactorySpec::85 - it creates a property not found exception