@@ -26,80 +26,80 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class MagicCallPatch implements ClassPatchInterface |
| 28 | 28 | { |
| 29 | - const MAGIC_METHODS_WITH_ARGUMENTS = ['__call', '__callStatic', '__get', '__isset', '__set', '__set_state', '__unserialize', '__unset']; |
|
| 30 | - |
|
| 31 | - private $tagRetriever; |
|
| 32 | - |
|
| 33 | - public function __construct(MethodTagRetrieverInterface $tagRetriever = null) |
|
| 34 | - { |
|
| 35 | - $this->tagRetriever = null === $tagRetriever ? new ClassAndInterfaceTagRetriever() : $tagRetriever; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Support any class |
|
| 40 | - * |
|
| 41 | - * @param ClassNode $node |
|
| 42 | - * |
|
| 43 | - * @return boolean |
|
| 44 | - */ |
|
| 45 | - public function supports(ClassNode $node) |
|
| 46 | - { |
|
| 47 | - return true; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Discover Magical API |
|
| 52 | - * |
|
| 53 | - * @param ClassNode $node |
|
| 54 | - */ |
|
| 55 | - public function apply(ClassNode $node) |
|
| 56 | - { |
|
| 57 | - $types = array_filter($node->getInterfaces(), function ($interface) { |
|
| 58 | - return 0 !== strpos($interface, 'Prophecy\\'); |
|
| 59 | - }); |
|
| 60 | - $types[] = $node->getParentClass(); |
|
| 61 | - |
|
| 62 | - foreach ($types as $type) { |
|
| 63 | - $reflectionClass = new \ReflectionClass($type); |
|
| 64 | - |
|
| 65 | - while ($reflectionClass) { |
|
| 66 | - $tagList = $this->tagRetriever->getTagList($reflectionClass); |
|
| 67 | - |
|
| 68 | - foreach ($tagList as $tag) { |
|
| 69 | - $methodName = $tag->getMethodName(); |
|
| 70 | - |
|
| 71 | - if (empty($methodName)) { |
|
| 72 | - continue; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - if (!$reflectionClass->hasMethod($methodName)) { |
|
| 76 | - $methodNode = new MethodNode($methodName); |
|
| 77 | - |
|
| 78 | - // only magic methods can have a contract that needs to be enforced |
|
| 79 | - if (in_array($methodName, self::MAGIC_METHODS_WITH_ARGUMENTS)) { |
|
| 80 | - foreach($tag->getArguments() as $argument) { |
|
| 81 | - $argumentNode = new ArgumentNode($argument['name']); |
|
| 82 | - $methodNode->addArgument($argumentNode); |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - $methodNode->setStatic($tag->isStatic()); |
|
| 87 | - $node->addMethod($methodNode); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - $reflectionClass = $reflectionClass->getParentClass(); |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Returns patch priority, which determines when patch will be applied. |
|
| 98 | - * |
|
| 99 | - * @return integer Priority number (higher - earlier) |
|
| 100 | - */ |
|
| 101 | - public function getPriority() |
|
| 102 | - { |
|
| 103 | - return 50; |
|
| 104 | - } |
|
| 29 | + const MAGIC_METHODS_WITH_ARGUMENTS = ['__call', '__callStatic', '__get', '__isset', '__set', '__set_state', '__unserialize', '__unset']; |
|
| 30 | + |
|
| 31 | + private $tagRetriever; |
|
| 32 | + |
|
| 33 | + public function __construct(MethodTagRetrieverInterface $tagRetriever = null) |
|
| 34 | + { |
|
| 35 | + $this->tagRetriever = null === $tagRetriever ? new ClassAndInterfaceTagRetriever() : $tagRetriever; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Support any class |
|
| 40 | + * |
|
| 41 | + * @param ClassNode $node |
|
| 42 | + * |
|
| 43 | + * @return boolean |
|
| 44 | + */ |
|
| 45 | + public function supports(ClassNode $node) |
|
| 46 | + { |
|
| 47 | + return true; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Discover Magical API |
|
| 52 | + * |
|
| 53 | + * @param ClassNode $node |
|
| 54 | + */ |
|
| 55 | + public function apply(ClassNode $node) |
|
| 56 | + { |
|
| 57 | + $types = array_filter($node->getInterfaces(), function ($interface) { |
|
| 58 | + return 0 !== strpos($interface, 'Prophecy\\'); |
|
| 59 | + }); |
|
| 60 | + $types[] = $node->getParentClass(); |
|
| 61 | + |
|
| 62 | + foreach ($types as $type) { |
|
| 63 | + $reflectionClass = new \ReflectionClass($type); |
|
| 64 | + |
|
| 65 | + while ($reflectionClass) { |
|
| 66 | + $tagList = $this->tagRetriever->getTagList($reflectionClass); |
|
| 67 | + |
|
| 68 | + foreach ($tagList as $tag) { |
|
| 69 | + $methodName = $tag->getMethodName(); |
|
| 70 | + |
|
| 71 | + if (empty($methodName)) { |
|
| 72 | + continue; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + if (!$reflectionClass->hasMethod($methodName)) { |
|
| 76 | + $methodNode = new MethodNode($methodName); |
|
| 77 | + |
|
| 78 | + // only magic methods can have a contract that needs to be enforced |
|
| 79 | + if (in_array($methodName, self::MAGIC_METHODS_WITH_ARGUMENTS)) { |
|
| 80 | + foreach($tag->getArguments() as $argument) { |
|
| 81 | + $argumentNode = new ArgumentNode($argument['name']); |
|
| 82 | + $methodNode->addArgument($argumentNode); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + $methodNode->setStatic($tag->isStatic()); |
|
| 87 | + $node->addMethod($methodNode); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + $reflectionClass = $reflectionClass->getParentClass(); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Returns patch priority, which determines when patch will be applied. |
|
| 98 | + * |
|
| 99 | + * @return integer Priority number (higher - earlier) |
|
| 100 | + */ |
|
| 101 | + public function getPriority() |
|
| 102 | + { |
|
| 103 | + return 50; |
|
| 104 | + } |
|
| 105 | 105 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function apply(ClassNode $node) |
| 56 | 56 | { |
| 57 | - $types = array_filter($node->getInterfaces(), function ($interface) { |
|
| 57 | + $types = array_filter($node->getInterfaces(), function($interface) { |
|
| 58 | 58 | return 0 !== strpos($interface, 'Prophecy\\'); |
| 59 | 59 | }); |
| 60 | 60 | $types[] = $node->getParentClass(); |
@@ -72,12 +72,12 @@ discard block |
||
| 72 | 72 | continue; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if (!$reflectionClass->hasMethod($methodName)) { |
|
| 75 | + if ( ! $reflectionClass->hasMethod($methodName)) { |
|
| 76 | 76 | $methodNode = new MethodNode($methodName); |
| 77 | 77 | |
| 78 | 78 | // only magic methods can have a contract that needs to be enforced |
| 79 | 79 | if (in_array($methodName, self::MAGIC_METHODS_WITH_ARGUMENTS)) { |
| 80 | - foreach($tag->getArguments() as $argument) { |
|
| 80 | + foreach ($tag->getArguments() as $argument) { |
|
| 81 | 81 | $argumentNode = new ArgumentNode($argument['name']); |
| 82 | 82 | $methodNode->addArgument($argumentNode); |
| 83 | 83 | } |
@@ -22,102 +22,102 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class SplFileInfoPatch implements ClassPatchInterface |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * Supports everything that extends SplFileInfo. |
|
| 27 | - * |
|
| 28 | - * @param ClassNode $node |
|
| 29 | - * |
|
| 30 | - * @return bool |
|
| 31 | - */ |
|
| 32 | - public function supports(ClassNode $node) |
|
| 33 | - { |
|
| 34 | - if (null === $node->getParentClass()) { |
|
| 35 | - return false; |
|
| 36 | - } |
|
| 37 | - return 'SplFileInfo' === $node->getParentClass() |
|
| 38 | - || is_subclass_of($node->getParentClass(), 'SplFileInfo') |
|
| 39 | - ; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Updated constructor code to call parent one with dummy file argument. |
|
| 44 | - * |
|
| 45 | - * @param ClassNode $node |
|
| 46 | - */ |
|
| 47 | - public function apply(ClassNode $node) |
|
| 48 | - { |
|
| 49 | - if ($node->hasMethod('__construct')) { |
|
| 50 | - $constructor = $node->getMethod('__construct'); |
|
| 51 | - } else { |
|
| 52 | - $constructor = new MethodNode('__construct'); |
|
| 53 | - $node->addMethod($constructor); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - if ($this->nodeIsDirectoryIterator($node)) { |
|
| 57 | - $constructor->setCode('return parent::__construct("' . __DIR__ . '");'); |
|
| 58 | - |
|
| 59 | - return; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - if ($this->nodeIsSplFileObject($node)) { |
|
| 63 | - $filePath = str_replace('\\','\\\\',__FILE__); |
|
| 64 | - $constructor->setCode('return parent::__construct("' . $filePath .'");'); |
|
| 65 | - |
|
| 66 | - return; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - if ($this->nodeIsSymfonySplFileInfo($node)) { |
|
| 70 | - $filePath = str_replace('\\','\\\\',__FILE__); |
|
| 71 | - $constructor->setCode('return parent::__construct("' . $filePath .'", "", "");'); |
|
| 72 | - |
|
| 73 | - return; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - $constructor->useParentCode(); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Returns patch priority, which determines when patch will be applied. |
|
| 81 | - * |
|
| 82 | - * @return int Priority number (higher - earlier) |
|
| 83 | - */ |
|
| 84 | - public function getPriority() |
|
| 85 | - { |
|
| 86 | - return 50; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @param ClassNode $node |
|
| 91 | - * @return boolean |
|
| 92 | - */ |
|
| 93 | - private function nodeIsDirectoryIterator(ClassNode $node) |
|
| 94 | - { |
|
| 95 | - $parent = $node->getParentClass(); |
|
| 96 | - |
|
| 97 | - return 'DirectoryIterator' === $parent |
|
| 98 | - || is_subclass_of($parent, 'DirectoryIterator'); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * @param ClassNode $node |
|
| 103 | - * @return boolean |
|
| 104 | - */ |
|
| 105 | - private function nodeIsSplFileObject(ClassNode $node) |
|
| 106 | - { |
|
| 107 | - $parent = $node->getParentClass(); |
|
| 108 | - |
|
| 109 | - return 'SplFileObject' === $parent |
|
| 110 | - || is_subclass_of($parent, 'SplFileObject'); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * @param ClassNode $node |
|
| 115 | - * @return boolean |
|
| 116 | - */ |
|
| 117 | - private function nodeIsSymfonySplFileInfo(ClassNode $node) |
|
| 118 | - { |
|
| 119 | - $parent = $node->getParentClass(); |
|
| 120 | - |
|
| 121 | - return 'Symfony\\Component\\Finder\\SplFileInfo' === $parent; |
|
| 122 | - } |
|
| 25 | + /** |
|
| 26 | + * Supports everything that extends SplFileInfo. |
|
| 27 | + * |
|
| 28 | + * @param ClassNode $node |
|
| 29 | + * |
|
| 30 | + * @return bool |
|
| 31 | + */ |
|
| 32 | + public function supports(ClassNode $node) |
|
| 33 | + { |
|
| 34 | + if (null === $node->getParentClass()) { |
|
| 35 | + return false; |
|
| 36 | + } |
|
| 37 | + return 'SplFileInfo' === $node->getParentClass() |
|
| 38 | + || is_subclass_of($node->getParentClass(), 'SplFileInfo') |
|
| 39 | + ; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Updated constructor code to call parent one with dummy file argument. |
|
| 44 | + * |
|
| 45 | + * @param ClassNode $node |
|
| 46 | + */ |
|
| 47 | + public function apply(ClassNode $node) |
|
| 48 | + { |
|
| 49 | + if ($node->hasMethod('__construct')) { |
|
| 50 | + $constructor = $node->getMethod('__construct'); |
|
| 51 | + } else { |
|
| 52 | + $constructor = new MethodNode('__construct'); |
|
| 53 | + $node->addMethod($constructor); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + if ($this->nodeIsDirectoryIterator($node)) { |
|
| 57 | + $constructor->setCode('return parent::__construct("' . __DIR__ . '");'); |
|
| 58 | + |
|
| 59 | + return; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + if ($this->nodeIsSplFileObject($node)) { |
|
| 63 | + $filePath = str_replace('\\','\\\\',__FILE__); |
|
| 64 | + $constructor->setCode('return parent::__construct("' . $filePath .'");'); |
|
| 65 | + |
|
| 66 | + return; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + if ($this->nodeIsSymfonySplFileInfo($node)) { |
|
| 70 | + $filePath = str_replace('\\','\\\\',__FILE__); |
|
| 71 | + $constructor->setCode('return parent::__construct("' . $filePath .'", "", "");'); |
|
| 72 | + |
|
| 73 | + return; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + $constructor->useParentCode(); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Returns patch priority, which determines when patch will be applied. |
|
| 81 | + * |
|
| 82 | + * @return int Priority number (higher - earlier) |
|
| 83 | + */ |
|
| 84 | + public function getPriority() |
|
| 85 | + { |
|
| 86 | + return 50; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @param ClassNode $node |
|
| 91 | + * @return boolean |
|
| 92 | + */ |
|
| 93 | + private function nodeIsDirectoryIterator(ClassNode $node) |
|
| 94 | + { |
|
| 95 | + $parent = $node->getParentClass(); |
|
| 96 | + |
|
| 97 | + return 'DirectoryIterator' === $parent |
|
| 98 | + || is_subclass_of($parent, 'DirectoryIterator'); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * @param ClassNode $node |
|
| 103 | + * @return boolean |
|
| 104 | + */ |
|
| 105 | + private function nodeIsSplFileObject(ClassNode $node) |
|
| 106 | + { |
|
| 107 | + $parent = $node->getParentClass(); |
|
| 108 | + |
|
| 109 | + return 'SplFileObject' === $parent |
|
| 110 | + || is_subclass_of($parent, 'SplFileObject'); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * @param ClassNode $node |
|
| 115 | + * @return boolean |
|
| 116 | + */ |
|
| 117 | + private function nodeIsSymfonySplFileInfo(ClassNode $node) |
|
| 118 | + { |
|
| 119 | + $parent = $node->getParentClass(); |
|
| 120 | + |
|
| 121 | + return 'Symfony\\Component\\Finder\\SplFileInfo' === $parent; |
|
| 122 | + } |
|
| 123 | 123 | } |
@@ -54,21 +54,21 @@ |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | if ($this->nodeIsDirectoryIterator($node)) { |
| 57 | - $constructor->setCode('return parent::__construct("' . __DIR__ . '");'); |
|
| 57 | + $constructor->setCode('return parent::__construct("'.__DIR__.'");'); |
|
| 58 | 58 | |
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | if ($this->nodeIsSplFileObject($node)) { |
| 63 | - $filePath = str_replace('\\','\\\\',__FILE__); |
|
| 64 | - $constructor->setCode('return parent::__construct("' . $filePath .'");'); |
|
| 63 | + $filePath = str_replace('\\', '\\\\', __FILE__); |
|
| 64 | + $constructor->setCode('return parent::__construct("'.$filePath.'");'); |
|
| 65 | 65 | |
| 66 | 66 | return; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | if ($this->nodeIsSymfonySplFileInfo($node)) { |
| 70 | - $filePath = str_replace('\\','\\\\',__FILE__); |
|
| 71 | - $constructor->setCode('return parent::__construct("' . $filePath .'", "", "");'); |
|
| 70 | + $filePath = str_replace('\\', '\\\\', __FILE__); |
|
| 71 | + $constructor->setCode('return parent::__construct("'.$filePath.'", "", "");'); |
|
| 72 | 72 | |
| 73 | 73 | return; |
| 74 | 74 | } |
@@ -21,46 +21,46 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class CachedDoubler extends Doubler |
| 23 | 23 | { |
| 24 | - private static $classes = array(); |
|
| 24 | + private static $classes = array(); |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * {@inheritdoc} |
|
| 28 | - */ |
|
| 29 | - protected function createDoubleClass(ReflectionClass $class = null, array $interfaces) |
|
| 30 | - { |
|
| 31 | - $classId = $this->generateClassId($class, $interfaces); |
|
| 32 | - if (isset(self::$classes[$classId])) { |
|
| 33 | - return self::$classes[$classId]; |
|
| 34 | - } |
|
| 26 | + /** |
|
| 27 | + * {@inheritdoc} |
|
| 28 | + */ |
|
| 29 | + protected function createDoubleClass(ReflectionClass $class = null, array $interfaces) |
|
| 30 | + { |
|
| 31 | + $classId = $this->generateClassId($class, $interfaces); |
|
| 32 | + if (isset(self::$classes[$classId])) { |
|
| 33 | + return self::$classes[$classId]; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - return self::$classes[$classId] = parent::createDoubleClass($class, $interfaces); |
|
| 37 | - } |
|
| 36 | + return self::$classes[$classId] = parent::createDoubleClass($class, $interfaces); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param ReflectionClass $class |
|
| 41 | - * @param ReflectionClass[] $interfaces |
|
| 42 | - * |
|
| 43 | - * @return string |
|
| 44 | - */ |
|
| 45 | - private function generateClassId(ReflectionClass $class = null, array $interfaces) |
|
| 46 | - { |
|
| 47 | - $parts = array(); |
|
| 48 | - if (null !== $class) { |
|
| 49 | - $parts[] = $class->getName(); |
|
| 50 | - } |
|
| 51 | - foreach ($interfaces as $interface) { |
|
| 52 | - $parts[] = $interface->getName(); |
|
| 53 | - } |
|
| 54 | - foreach ($this->getClassPatches() as $patch) { |
|
| 55 | - $parts[] = get_class($patch); |
|
| 56 | - } |
|
| 57 | - sort($parts); |
|
| 39 | + /** |
|
| 40 | + * @param ReflectionClass $class |
|
| 41 | + * @param ReflectionClass[] $interfaces |
|
| 42 | + * |
|
| 43 | + * @return string |
|
| 44 | + */ |
|
| 45 | + private function generateClassId(ReflectionClass $class = null, array $interfaces) |
|
| 46 | + { |
|
| 47 | + $parts = array(); |
|
| 48 | + if (null !== $class) { |
|
| 49 | + $parts[] = $class->getName(); |
|
| 50 | + } |
|
| 51 | + foreach ($interfaces as $interface) { |
|
| 52 | + $parts[] = $interface->getName(); |
|
| 53 | + } |
|
| 54 | + foreach ($this->getClassPatches() as $patch) { |
|
| 55 | + $parts[] = get_class($patch); |
|
| 56 | + } |
|
| 57 | + sort($parts); |
|
| 58 | 58 | |
| 59 | - return md5(implode('', $parts)); |
|
| 60 | - } |
|
| 59 | + return md5(implode('', $parts)); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - public function resetCache() |
|
| 63 | - { |
|
| 64 | - self::$classes = array(); |
|
| 65 | - } |
|
| 62 | + public function resetCache() |
|
| 63 | + { |
|
| 64 | + self::$classes = array(); |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -24,104 +24,104 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | class LazyDouble |
| 26 | 26 | { |
| 27 | - private $doubler; |
|
| 28 | - private $class; |
|
| 29 | - private $interfaces = array(); |
|
| 30 | - private $arguments = null; |
|
| 31 | - private $double; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Initializes lazy double. |
|
| 35 | - * |
|
| 36 | - * @param Doubler $doubler |
|
| 37 | - */ |
|
| 38 | - public function __construct(Doubler $doubler) |
|
| 39 | - { |
|
| 40 | - $this->doubler = $doubler; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Tells doubler to use specific class as parent one for double. |
|
| 45 | - * |
|
| 46 | - * @param string|ReflectionClass $class |
|
| 47 | - * |
|
| 48 | - * @throws \Prophecy\Exception\Doubler\ClassNotFoundException |
|
| 49 | - * @throws \Prophecy\Exception\Doubler\DoubleException |
|
| 50 | - */ |
|
| 51 | - public function setParentClass($class) |
|
| 52 | - { |
|
| 53 | - if (null !== $this->double) { |
|
| 54 | - throw new DoubleException('Can not extend class with already instantiated double.'); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - if (!$class instanceof ReflectionClass) { |
|
| 58 | - if (!class_exists($class)) { |
|
| 59 | - throw new ClassNotFoundException(sprintf('Class %s not found.', $class), $class); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - $class = new ReflectionClass($class); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - $this->class = $class; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Tells doubler to implement specific interface with double. |
|
| 70 | - * |
|
| 71 | - * @param string|ReflectionClass $interface |
|
| 72 | - * |
|
| 73 | - * @throws \Prophecy\Exception\Doubler\InterfaceNotFoundException |
|
| 74 | - * @throws \Prophecy\Exception\Doubler\DoubleException |
|
| 75 | - */ |
|
| 76 | - public function addInterface($interface) |
|
| 77 | - { |
|
| 78 | - if (null !== $this->double) { |
|
| 79 | - throw new DoubleException( |
|
| 80 | - 'Can not implement interface with already instantiated double.' |
|
| 81 | - ); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - if (!$interface instanceof ReflectionClass) { |
|
| 85 | - if (!interface_exists($interface)) { |
|
| 86 | - throw new InterfaceNotFoundException( |
|
| 87 | - sprintf('Interface %s not found.', $interface), |
|
| 88 | - $interface |
|
| 89 | - ); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - $interface = new ReflectionClass($interface); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - $this->interfaces[] = $interface; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Sets constructor arguments. |
|
| 100 | - * |
|
| 101 | - * @param array $arguments |
|
| 102 | - */ |
|
| 103 | - public function setArguments(array $arguments = null) |
|
| 104 | - { |
|
| 105 | - $this->arguments = $arguments; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Creates double instance or returns already created one. |
|
| 110 | - * |
|
| 111 | - * @return DoubleInterface |
|
| 112 | - */ |
|
| 113 | - public function getInstance() |
|
| 114 | - { |
|
| 115 | - if (null === $this->double) { |
|
| 116 | - if (null !== $this->arguments) { |
|
| 117 | - return $this->double = $this->doubler->double( |
|
| 118 | - $this->class, $this->interfaces, $this->arguments |
|
| 119 | - ); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - $this->double = $this->doubler->double($this->class, $this->interfaces); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - return $this->double; |
|
| 126 | - } |
|
| 27 | + private $doubler; |
|
| 28 | + private $class; |
|
| 29 | + private $interfaces = array(); |
|
| 30 | + private $arguments = null; |
|
| 31 | + private $double; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Initializes lazy double. |
|
| 35 | + * |
|
| 36 | + * @param Doubler $doubler |
|
| 37 | + */ |
|
| 38 | + public function __construct(Doubler $doubler) |
|
| 39 | + { |
|
| 40 | + $this->doubler = $doubler; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Tells doubler to use specific class as parent one for double. |
|
| 45 | + * |
|
| 46 | + * @param string|ReflectionClass $class |
|
| 47 | + * |
|
| 48 | + * @throws \Prophecy\Exception\Doubler\ClassNotFoundException |
|
| 49 | + * @throws \Prophecy\Exception\Doubler\DoubleException |
|
| 50 | + */ |
|
| 51 | + public function setParentClass($class) |
|
| 52 | + { |
|
| 53 | + if (null !== $this->double) { |
|
| 54 | + throw new DoubleException('Can not extend class with already instantiated double.'); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + if (!$class instanceof ReflectionClass) { |
|
| 58 | + if (!class_exists($class)) { |
|
| 59 | + throw new ClassNotFoundException(sprintf('Class %s not found.', $class), $class); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + $class = new ReflectionClass($class); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + $this->class = $class; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Tells doubler to implement specific interface with double. |
|
| 70 | + * |
|
| 71 | + * @param string|ReflectionClass $interface |
|
| 72 | + * |
|
| 73 | + * @throws \Prophecy\Exception\Doubler\InterfaceNotFoundException |
|
| 74 | + * @throws \Prophecy\Exception\Doubler\DoubleException |
|
| 75 | + */ |
|
| 76 | + public function addInterface($interface) |
|
| 77 | + { |
|
| 78 | + if (null !== $this->double) { |
|
| 79 | + throw new DoubleException( |
|
| 80 | + 'Can not implement interface with already instantiated double.' |
|
| 81 | + ); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + if (!$interface instanceof ReflectionClass) { |
|
| 85 | + if (!interface_exists($interface)) { |
|
| 86 | + throw new InterfaceNotFoundException( |
|
| 87 | + sprintf('Interface %s not found.', $interface), |
|
| 88 | + $interface |
|
| 89 | + ); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + $interface = new ReflectionClass($interface); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + $this->interfaces[] = $interface; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Sets constructor arguments. |
|
| 100 | + * |
|
| 101 | + * @param array $arguments |
|
| 102 | + */ |
|
| 103 | + public function setArguments(array $arguments = null) |
|
| 104 | + { |
|
| 105 | + $this->arguments = $arguments; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Creates double instance or returns already created one. |
|
| 110 | + * |
|
| 111 | + * @return DoubleInterface |
|
| 112 | + */ |
|
| 113 | + public function getInstance() |
|
| 114 | + { |
|
| 115 | + if (null === $this->double) { |
|
| 116 | + if (null !== $this->arguments) { |
|
| 117 | + return $this->double = $this->doubler->double( |
|
| 118 | + $this->class, $this->interfaces, $this->arguments |
|
| 119 | + ); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + $this->double = $this->doubler->double($this->class, $this->interfaces); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + return $this->double; |
|
| 126 | + } |
|
| 127 | 127 | } |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | throw new DoubleException('Can not extend class with already instantiated double.'); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if (!$class instanceof ReflectionClass) { |
|
| 58 | - if (!class_exists($class)) { |
|
| 57 | + if ( ! $class instanceof ReflectionClass) { |
|
| 58 | + if ( ! class_exists($class)) { |
|
| 59 | 59 | throw new ClassNotFoundException(sprintf('Class %s not found.', $class), $class); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | ); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if (!$interface instanceof ReflectionClass) { |
|
| 85 | - if (!interface_exists($interface)) { |
|
| 84 | + if ( ! $interface instanceof ReflectionClass) { |
|
| 85 | + if ( ! interface_exists($interface)) { |
|
| 86 | 86 | throw new InterfaceNotFoundException( |
| 87 | 87 | sprintf('Interface %s not found.', $interface), |
| 88 | 88 | $interface |
@@ -19,13 +19,13 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class ProphecyComparator extends ObjectComparator |
| 21 | 21 | { |
| 22 | - public function accepts($expected, $actual): bool |
|
| 23 | - { |
|
| 24 | - return is_object($expected) && is_object($actual) && $actual instanceof ProphecyInterface; |
|
| 25 | - } |
|
| 22 | + public function accepts($expected, $actual): bool |
|
| 23 | + { |
|
| 24 | + return is_object($expected) && is_object($actual) && $actual instanceof ProphecyInterface; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array()): void |
|
| 28 | - { |
|
| 29 | - parent::assertEquals($expected, $actual->reveal(), $delta, $canonicalize, $ignoreCase, $processed); |
|
| 30 | - } |
|
| 27 | + public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array()): void |
|
| 28 | + { |
|
| 29 | + parent::assertEquals($expected, $actual->reveal(), $delta, $canonicalize, $ignoreCase, $processed); |
|
| 30 | + } |
|
| 31 | 31 | } |
@@ -20,28 +20,28 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | final class Factory extends BaseFactory |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var Factory |
|
| 25 | - */ |
|
| 26 | - private static $instance; |
|
| 27 | - |
|
| 28 | - public function __construct() |
|
| 29 | - { |
|
| 30 | - parent::__construct(); |
|
| 31 | - |
|
| 32 | - $this->register(new ClosureComparator()); |
|
| 33 | - $this->register(new ProphecyComparator()); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @return Factory |
|
| 38 | - */ |
|
| 39 | - public static function getInstance() |
|
| 40 | - { |
|
| 41 | - if (self::$instance === null) { |
|
| 42 | - self::$instance = new Factory; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - return self::$instance; |
|
| 46 | - } |
|
| 23 | + /** |
|
| 24 | + * @var Factory |
|
| 25 | + */ |
|
| 26 | + private static $instance; |
|
| 27 | + |
|
| 28 | + public function __construct() |
|
| 29 | + { |
|
| 30 | + parent::__construct(); |
|
| 31 | + |
|
| 32 | + $this->register(new ClosureComparator()); |
|
| 33 | + $this->register(new ProphecyComparator()); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @return Factory |
|
| 38 | + */ |
|
| 39 | + public static function getInstance() |
|
| 40 | + { |
|
| 41 | + if (self::$instance === null) { |
|
| 42 | + self::$instance = new Factory; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + return self::$instance; |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -21,24 +21,24 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | final class ClosureComparator extends Comparator |
| 23 | 23 | { |
| 24 | - public function accepts($expected, $actual): bool |
|
| 25 | - { |
|
| 26 | - return is_object($expected) && $expected instanceof \Closure |
|
| 27 | - && is_object($actual) && $actual instanceof \Closure; |
|
| 28 | - } |
|
| 24 | + public function accepts($expected, $actual): bool |
|
| 25 | + { |
|
| 26 | + return is_object($expected) && $expected instanceof \Closure |
|
| 27 | + && is_object($actual) && $actual instanceof \Closure; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array()): void |
|
| 31 | - { |
|
| 32 | - if ($expected !== $actual) { |
|
| 33 | - throw new ComparisonFailure( |
|
| 34 | - $expected, |
|
| 35 | - $actual, |
|
| 36 | - // we don't need a diff |
|
| 37 | - '', |
|
| 38 | - '', |
|
| 39 | - false, |
|
| 40 | - 'all closures are different if not identical' |
|
| 41 | - ); |
|
| 42 | - } |
|
| 43 | - } |
|
| 30 | + public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false, array &$processed = array()): void |
|
| 31 | + { |
|
| 32 | + if ($expected !== $actual) { |
|
| 33 | + throw new ComparisonFailure( |
|
| 34 | + $expected, |
|
| 35 | + $actual, |
|
| 36 | + // we don't need a diff |
|
| 37 | + '', |
|
| 38 | + '', |
|
| 39 | + false, |
|
| 40 | + 'all closures are different if not identical' |
|
| 41 | + ); |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -24,77 +24,77 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | class ThrowPromise implements PromiseInterface |
| 26 | 26 | { |
| 27 | - private $exception; |
|
| 27 | + private $exception; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var \Doctrine\Instantiator\Instantiator |
|
| 31 | - */ |
|
| 32 | - private $instantiator; |
|
| 29 | + /** |
|
| 30 | + * @var \Doctrine\Instantiator\Instantiator |
|
| 31 | + */ |
|
| 32 | + private $instantiator; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Initializes promise. |
|
| 36 | - * |
|
| 37 | - * @param string|\Exception|\Throwable $exception Exception class name or instance |
|
| 38 | - * |
|
| 39 | - * @throws \Prophecy\Exception\InvalidArgumentException |
|
| 40 | - */ |
|
| 41 | - public function __construct($exception) |
|
| 42 | - { |
|
| 43 | - if (is_string($exception)) { |
|
| 44 | - if ((!class_exists($exception) && !interface_exists($exception)) || !$this->isAValidThrowable($exception)) { |
|
| 45 | - throw new InvalidArgumentException(sprintf( |
|
| 46 | - 'Exception / Throwable class or instance expected as argument to ThrowPromise, but got %s.', |
|
| 47 | - $exception |
|
| 48 | - )); |
|
| 49 | - } |
|
| 50 | - } elseif (!$exception instanceof \Exception && !$exception instanceof \Throwable) { |
|
| 51 | - throw new InvalidArgumentException(sprintf( |
|
| 52 | - 'Exception / Throwable class or instance expected as argument to ThrowPromise, but got %s.', |
|
| 53 | - is_object($exception) ? get_class($exception) : gettype($exception) |
|
| 54 | - )); |
|
| 55 | - } |
|
| 34 | + /** |
|
| 35 | + * Initializes promise. |
|
| 36 | + * |
|
| 37 | + * @param string|\Exception|\Throwable $exception Exception class name or instance |
|
| 38 | + * |
|
| 39 | + * @throws \Prophecy\Exception\InvalidArgumentException |
|
| 40 | + */ |
|
| 41 | + public function __construct($exception) |
|
| 42 | + { |
|
| 43 | + if (is_string($exception)) { |
|
| 44 | + if ((!class_exists($exception) && !interface_exists($exception)) || !$this->isAValidThrowable($exception)) { |
|
| 45 | + throw new InvalidArgumentException(sprintf( |
|
| 46 | + 'Exception / Throwable class or instance expected as argument to ThrowPromise, but got %s.', |
|
| 47 | + $exception |
|
| 48 | + )); |
|
| 49 | + } |
|
| 50 | + } elseif (!$exception instanceof \Exception && !$exception instanceof \Throwable) { |
|
| 51 | + throw new InvalidArgumentException(sprintf( |
|
| 52 | + 'Exception / Throwable class or instance expected as argument to ThrowPromise, but got %s.', |
|
| 53 | + is_object($exception) ? get_class($exception) : gettype($exception) |
|
| 54 | + )); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - $this->exception = $exception; |
|
| 58 | - } |
|
| 57 | + $this->exception = $exception; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Throws predefined exception. |
|
| 62 | - * |
|
| 63 | - * @param array $args |
|
| 64 | - * @param ObjectProphecy $object |
|
| 65 | - * @param MethodProphecy $method |
|
| 66 | - * |
|
| 67 | - * @throws object |
|
| 68 | - */ |
|
| 69 | - public function execute(array $args, ObjectProphecy $object, MethodProphecy $method) |
|
| 70 | - { |
|
| 71 | - if (is_string($this->exception)) { |
|
| 72 | - $classname = $this->exception; |
|
| 73 | - $reflection = new ReflectionClass($classname); |
|
| 74 | - $constructor = $reflection->getConstructor(); |
|
| 60 | + /** |
|
| 61 | + * Throws predefined exception. |
|
| 62 | + * |
|
| 63 | + * @param array $args |
|
| 64 | + * @param ObjectProphecy $object |
|
| 65 | + * @param MethodProphecy $method |
|
| 66 | + * |
|
| 67 | + * @throws object |
|
| 68 | + */ |
|
| 69 | + public function execute(array $args, ObjectProphecy $object, MethodProphecy $method) |
|
| 70 | + { |
|
| 71 | + if (is_string($this->exception)) { |
|
| 72 | + $classname = $this->exception; |
|
| 73 | + $reflection = new ReflectionClass($classname); |
|
| 74 | + $constructor = $reflection->getConstructor(); |
|
| 75 | 75 | |
| 76 | - if ($constructor->isPublic() && 0 == $constructor->getNumberOfRequiredParameters()) { |
|
| 77 | - throw $reflection->newInstance(); |
|
| 78 | - } |
|
| 76 | + if ($constructor->isPublic() && 0 == $constructor->getNumberOfRequiredParameters()) { |
|
| 77 | + throw $reflection->newInstance(); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - if (!$this->instantiator) { |
|
| 81 | - $this->instantiator = new Instantiator(); |
|
| 82 | - } |
|
| 80 | + if (!$this->instantiator) { |
|
| 81 | + $this->instantiator = new Instantiator(); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - throw $this->instantiator->instantiate($classname); |
|
| 85 | - } |
|
| 84 | + throw $this->instantiator->instantiate($classname); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - throw $this->exception; |
|
| 88 | - } |
|
| 87 | + throw $this->exception; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * @param string $exception |
|
| 92 | - * |
|
| 93 | - * @return bool |
|
| 94 | - */ |
|
| 95 | - private function isAValidThrowable($exception) |
|
| 96 | - { |
|
| 97 | - return is_a($exception, 'Exception', true) |
|
| 98 | - || is_a($exception, 'Throwable', true); |
|
| 99 | - } |
|
| 90 | + /** |
|
| 91 | + * @param string $exception |
|
| 92 | + * |
|
| 93 | + * @return bool |
|
| 94 | + */ |
|
| 95 | + private function isAValidThrowable($exception) |
|
| 96 | + { |
|
| 97 | + return is_a($exception, 'Exception', true) |
|
| 98 | + || is_a($exception, 'Throwable', true); |
|
| 99 | + } |
|
| 100 | 100 | } |
@@ -41,13 +41,13 @@ discard block |
||
| 41 | 41 | public function __construct($exception) |
| 42 | 42 | { |
| 43 | 43 | if (is_string($exception)) { |
| 44 | - if ((!class_exists($exception) && !interface_exists($exception)) || !$this->isAValidThrowable($exception)) { |
|
| 44 | + if (( ! class_exists($exception) && ! interface_exists($exception)) || ! $this->isAValidThrowable($exception)) { |
|
| 45 | 45 | throw new InvalidArgumentException(sprintf( |
| 46 | 46 | 'Exception / Throwable class or instance expected as argument to ThrowPromise, but got %s.', |
| 47 | 47 | $exception |
| 48 | 48 | )); |
| 49 | 49 | } |
| 50 | - } elseif (!$exception instanceof \Exception && !$exception instanceof \Throwable) { |
|
| 50 | + } elseif ( ! $exception instanceof \Exception && ! $exception instanceof \Throwable) { |
|
| 51 | 51 | throw new InvalidArgumentException(sprintf( |
| 52 | 52 | 'Exception / Throwable class or instance expected as argument to ThrowPromise, but got %s.', |
| 53 | 53 | is_object($exception) ? get_class($exception) : gettype($exception) |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | throw $reflection->newInstance(); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if (!$this->instantiator) { |
|
| 80 | + if ( ! $this->instantiator) { |
|
| 81 | 81 | $this->instantiator = new Instantiator(); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -22,40 +22,40 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class ReturnArgumentPromise implements PromiseInterface |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * @var int |
|
| 27 | - */ |
|
| 28 | - private $index; |
|
| 25 | + /** |
|
| 26 | + * @var int |
|
| 27 | + */ |
|
| 28 | + private $index; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Initializes callback promise. |
|
| 32 | - * |
|
| 33 | - * @param int $index The zero-indexed number of the argument to return |
|
| 34 | - * |
|
| 35 | - * @throws \Prophecy\Exception\InvalidArgumentException |
|
| 36 | - */ |
|
| 37 | - public function __construct($index = 0) |
|
| 38 | - { |
|
| 39 | - if (!is_int($index) || $index < 0) { |
|
| 40 | - throw new InvalidArgumentException(sprintf( |
|
| 41 | - 'Zero-based index expected as argument to ReturnArgumentPromise, but got %s.', |
|
| 42 | - $index |
|
| 43 | - )); |
|
| 44 | - } |
|
| 45 | - $this->index = $index; |
|
| 46 | - } |
|
| 30 | + /** |
|
| 31 | + * Initializes callback promise. |
|
| 32 | + * |
|
| 33 | + * @param int $index The zero-indexed number of the argument to return |
|
| 34 | + * |
|
| 35 | + * @throws \Prophecy\Exception\InvalidArgumentException |
|
| 36 | + */ |
|
| 37 | + public function __construct($index = 0) |
|
| 38 | + { |
|
| 39 | + if (!is_int($index) || $index < 0) { |
|
| 40 | + throw new InvalidArgumentException(sprintf( |
|
| 41 | + 'Zero-based index expected as argument to ReturnArgumentPromise, but got %s.', |
|
| 42 | + $index |
|
| 43 | + )); |
|
| 44 | + } |
|
| 45 | + $this->index = $index; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Returns nth argument if has one, null otherwise. |
|
| 50 | - * |
|
| 51 | - * @param array $args |
|
| 52 | - * @param ObjectProphecy $object |
|
| 53 | - * @param MethodProphecy $method |
|
| 54 | - * |
|
| 55 | - * @return null|mixed |
|
| 56 | - */ |
|
| 57 | - public function execute(array $args, ObjectProphecy $object, MethodProphecy $method) |
|
| 58 | - { |
|
| 59 | - return count($args) > $this->index ? $args[$this->index] : null; |
|
| 60 | - } |
|
| 48 | + /** |
|
| 49 | + * Returns nth argument if has one, null otherwise. |
|
| 50 | + * |
|
| 51 | + * @param array $args |
|
| 52 | + * @param ObjectProphecy $object |
|
| 53 | + * @param MethodProphecy $method |
|
| 54 | + * |
|
| 55 | + * @return null|mixed |
|
| 56 | + */ |
|
| 57 | + public function execute(array $args, ObjectProphecy $object, MethodProphecy $method) |
|
| 58 | + { |
|
| 59 | + return count($args) > $this->index ? $args[$this->index] : null; |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | public function __construct($index = 0) |
| 38 | 38 | { |
| 39 | - if (!is_int($index) || $index < 0) { |
|
| 39 | + if ( ! is_int($index) || $index < 0) { |
|
| 40 | 40 | throw new InvalidArgumentException(sprintf( |
| 41 | 41 | 'Zero-based index expected as argument to ReturnArgumentPromise, but got %s.', |
| 42 | 42 | $index |