Skip to content

Instantly share code, notes, and snippets.

@toby-griffiths
Last active October 13, 2015 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toby-griffiths/1d0e85d33f3092a42d54 to your computer and use it in GitHub Desktop.
Save toby-griffiths/1d0e85d33f3092a42d54 to your computer and use it in GitHub Desktop.
Change to clone argument objects
<?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;
}
//...
}
@toby-griffiths
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment