3 * This file is part of the PHPUnit_MockObject package.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 use SebastianBergmann\Exporter\Exporter;
14 * Represents a static invocation.
16 * @since Class available since Release 1.0.0
18 class PHPUnit_Framework_MockObject_Invocation_Static implements PHPUnit_Framework_MockObject_Invocation, PHPUnit_Framework_SelfDescribing
23 protected static $uncloneableExtensions = array(
35 protected static $uncloneableClasses = array(
39 'RecursiveIteratorIterator',
61 * @param string $className
62 * @param string $methodname
63 * @param array $parameters
64 * @param bool $cloneObjects
66 public function __construct($className, $methodName, array $parameters, $cloneObjects = false)
68 $this->className = $className;
69 $this->methodName = $methodName;
70 $this->parameters = $parameters;
76 foreach ($this->parameters as $key => $value) {
77 if (is_object($value)) {
78 $this->parameters[$key] = $this->cloneObject($value);
86 public function toString()
88 $exporter = new Exporter;
97 array($exporter, 'shortenedExport'),
105 * @param object $original
108 protected function cloneObject($original)
111 $object = new ReflectionObject($original);
113 // Check the blacklist before asking PHP reflection to work around
114 // https://bugs.php.net/bug.php?id=53967
115 if ($object->isInternal() &&
116 isset(self::$uncloneableExtensions[$object->getExtensionName()])) {
120 if ($cloneable === null) {
121 foreach (self::$uncloneableClasses as $class) {
122 if ($original instanceof $class) {
129 if ($cloneable === null && method_exists($object, 'isCloneable')) {
130 $cloneable = $object->isCloneable();
133 if ($cloneable === null && $object->hasMethod('__clone')) {
134 $method = $object->getMethod('__clone');
135 $cloneable = $method->isPublic();
138 if ($cloneable === null) {
144 return clone $original;
145 } catch (Exception $e) {