/home/techb158/ileadtechnology.com/vendor/mockery/mockery/library/Mockery
NameSizeModeActions
Adapter/-0755rm
CountValidator/-0755rm
Exception/-0755rm
Generator/-0755rm
Loader/-0755rm
Matcher/-0755rm
ClosureWrapper.php10180644editdlrm
CompositeExpectation.php40010644editdlrm
Configuration.php55980644editdlrm
Container.php160340644editdlrm
Exception.php7570644editdlrm
Expectation.php229080644editdlrm
ExpectationDirector.php57020644editdlrm
ExpectationInterface.php10870644editdlrm
ExpectsHigherOrderMessage.php10840644editdlrm
HigherOrderMessage.php13290644editdlrm
Instantiator.php49070644editdlrm
LegacyMockInterface.php61100644editdlrm
MethodCall.php10330644editdlrm
Mock.php285230644editdlrm
MockInterface.php12590644editdlrm
ReceivedMethodCalls.php13220644editdlrm
Reflector.php98680644editdlrm
Undefined.php11620644editdlrm
VerificationDirector.php31210644editdlrm
VerificationExpectation.php9580644editdlrm
Edit: /home/techb158/ileadtechnology.com/vendor/mockery/mockery/library/Mockery/Instantiator.php (4907B)
. */ namespace Mockery; use Closure; use ReflectionClass; use UnexpectedValueException; use InvalidArgumentException; /** * This is a trimmed down version of https://github.com/doctrine/instantiator, * basically without the caching * * @author Marco Pivetta */ final class Instantiator { /** * {@inheritDoc} */ public function instantiate($className) { $factory = $this->buildFactory($className); $instance = $factory(); return $instance; } /** * Builds a {@see \Closure} capable of instantiating the given $className without * invoking its constructor. * * @param string $className * * @return Closure */ private function buildFactory($className) { $reflectionClass = $this->getReflectionClass($className); if ($this->isInstantiableViaReflection($reflectionClass)) { return function () use ($reflectionClass) { return $reflectionClass->newInstanceWithoutConstructor(); }; } $serializedString = sprintf( 'O:%d:"%s":0:{}', strlen($className), $className ); $this->attemptInstantiationViaUnSerialization($reflectionClass, $serializedString); return function () use ($serializedString) { return unserialize($serializedString); }; } /** * @param string $className * * @return ReflectionClass * * @throws InvalidArgumentException */ private function getReflectionClass($className) { if (! class_exists($className)) { throw new InvalidArgumentException("Class:$className does not exist"); } $reflection = new ReflectionClass($className); if ($reflection->isAbstract()) { throw new InvalidArgumentException("Class:$className is an abstract class"); } return $reflection; } /** * @param ReflectionClass $reflectionClass * @param string $serializedString * * @throws UnexpectedValueException * * @return void */ private function attemptInstantiationViaUnSerialization(ReflectionClass $reflectionClass, $serializedString) { set_error_handler(function ($code, $message, $file, $line) use ($reflectionClass, & $error) { $msg = sprintf( 'Could not produce an instance of "%s" via un-serialization, since an error was triggered in file "%s" at line "%d"', $reflectionClass->getName(), $file, $line ); $error = new UnexpectedValueException($msg, 0, new \Exception($message, $code)); }); try { unserialize($serializedString); } catch (\Exception $exception) { restore_error_handler(); throw new UnexpectedValueException("An exception was raised while trying to instantiate an instance of \"{$reflectionClass->getName()}\" via un-serialization", 0, $exception); } restore_error_handler(); if ($error) { throw $error; } } /** * @param ReflectionClass $reflectionClass * * @return bool */ private function isInstantiableViaReflection(ReflectionClass $reflectionClass) { return ! ($reflectionClass->isInternal() && $reflectionClass->isFinal()); } /** * Verifies whether the given class is to be considered internal * * @param ReflectionClass $reflectionClass * * @return bool */ private function hasInternalAncestors(ReflectionClass $reflectionClass) { do { if ($reflectionClass->isInternal()) { return true; } } while ($reflectionClass = $reflectionClass->getParentClass()); return false; } }