You are here

private function Instantiator::isSafeToClone in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/instantiator/src/Doctrine/Instantiator/Instantiator.php \Doctrine\Instantiator\Instantiator::isSafeToClone()

Checks if a class is cloneable

Parameters

ReflectionClass $reflection:

Return value

bool

1 call to Instantiator::isSafeToClone()
Instantiator::buildAndCacheFromFactory in vendor/doctrine/instantiator/src/Doctrine/Instantiator/Instantiator.php
Builds the requested object and caches it in static properties for performance

File

vendor/doctrine/instantiator/src/Doctrine/Instantiator/Instantiator.php, line 264

Class

Instantiator
@author Marco Pivetta <ocramius@gmail.com>

Namespace

Doctrine\Instantiator

Code

private function isSafeToClone(ReflectionClass $reflection) {
  if (method_exists($reflection, 'isCloneable') && !$reflection
    ->isCloneable()) {
    return false;
  }

  // not cloneable if it implements `__clone`, as we want to avoid calling it
  return !$reflection
    ->hasMethod('__clone');
}