@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | if (count($methodCalls)) { |
| 62 | 62 | throw new NoCallsException(sprintf( |
| 63 | - "No calls have been made that match:\n". |
|
| 64 | - " %s->%s(%s)\n". |
|
| 65 | - "but expected at least one.\n". |
|
| 63 | + "No calls have been made that match:\n" . |
|
| 64 | + " %s->%s(%s)\n" . |
|
| 65 | + "but expected at least one.\n" . |
|
| 66 | 66 | "Recorded `%s(...)` calls:\n%s", |
| 67 | 67 | |
| 68 | 68 | get_class($object->reveal()), |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | throw new NoCallsException(sprintf( |
| 77 | - "No calls have been made that match:\n". |
|
| 78 | - " %s->%s(%s)\n". |
|
| 77 | + "No calls have been made that match:\n" . |
|
| 78 | + " %s->%s(%s)\n" . |
|
| 79 | 79 | "but expected at least one.", |
| 80 | 80 | |
| 81 | 81 | get_class($object->reveal()), |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if (count($calls)) { |
| 66 | 66 | $message = sprintf( |
| 67 | - "Expected exactly %d calls that match:\n". |
|
| 68 | - " %s->%s(%s)\n". |
|
| 67 | + "Expected exactly %d calls that match:\n" . |
|
| 68 | + " %s->%s(%s)\n" . |
|
| 69 | 69 | "but %d were made:\n%s", |
| 70 | 70 | |
| 71 | 71 | $this->times, |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | ); |
| 78 | 78 | } elseif (count($methodCalls)) { |
| 79 | 79 | $message = sprintf( |
| 80 | - "Expected exactly %d calls that match:\n". |
|
| 81 | - " %s->%s(%s)\n". |
|
| 82 | - "but none were made.\n". |
|
| 80 | + "Expected exactly %d calls that match:\n" . |
|
| 81 | + " %s->%s(%s)\n" . |
|
| 82 | + "but none were made.\n" . |
|
| 83 | 83 | "Recorded `%s(...)` calls:\n%s", |
| 84 | 84 | |
| 85 | 85 | $this->times, |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | ); |
| 92 | 92 | } else { |
| 93 | 93 | $message = sprintf( |
| 94 | - "Expected exactly %d calls that match:\n". |
|
| 95 | - " %s->%s(%s)\n". |
|
| 94 | + "Expected exactly %d calls that match:\n" . |
|
| 95 | + " %s->%s(%s)\n" . |
|
| 96 | 96 | "but none were made.", |
| 97 | 97 | |
| 98 | 98 | $this->times, |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | public function __construct(ClassMirror $mirror = null, ClassCreator $creator = null, |
| 51 | 51 | NameGenerator $namer = null) |
| 52 | 52 | { |
| 53 | - $this->mirror = $mirror ?: new ClassMirror; |
|
| 53 | + $this->mirror = $mirror ?: new ClassMirror; |
|
| 54 | 54 | $this->creator = $creator ?: new ClassCreator; |
| 55 | - $this->namer = $namer ?: new NameGenerator; |
|
| 55 | + $this->namer = $namer ?: new NameGenerator; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | $this->patches[] = $patch; |
| 76 | 76 | |
| 77 | - @usort($this->patches, function (ClassPatchInterface $patch1, ClassPatchInterface $patch2) { |
|
| 77 | + @usort($this->patches, function(ClassPatchInterface $patch1, ClassPatchInterface $patch2) { |
|
| 78 | 78 | return $patch2->getPriority() - $patch1->getPriority(); |
| 79 | 79 | }); |
| 80 | 80 | } |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | foreach ($interfaces as $interface) { |
| 96 | 96 | if (!$interface instanceof ReflectionClass) { |
| 97 | 97 | throw new InvalidArgumentException(sprintf( |
| 98 | - "[ReflectionClass \$interface1 [, ReflectionClass \$interface2]] array expected as\n". |
|
| 98 | + "[ReflectionClass \$interface1 [, ReflectionClass \$interface2]] array expected as\n" . |
|
| 99 | 99 | "a second argument to `Doubler::double(...)`, but got %s.", |
| 100 | - is_object($interface) ? get_class($interface).' class' : gettype($interface) |
|
| 100 | + is_object($interface) ? get_class($interface) . ' class' : gettype($interface) |
|
| 101 | 101 | )); |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | if (null !== $class) { |
| 57 | 57 | if (true === $class->isInterface()) { |
| 58 | 58 | throw new InvalidArgumentException(sprintf( |
| 59 | - "Could not reflect %s as a class, because it\n". |
|
| 59 | + "Could not reflect %s as a class, because it\n" . |
|
| 60 | 60 | "is interface - use the second argument instead.", |
| 61 | 61 | $class->getName() |
| 62 | 62 | )); |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | foreach ($interfaces as $interface) { |
| 69 | 69 | if (!$interface instanceof ReflectionClass) { |
| 70 | 70 | throw new InvalidArgumentException(sprintf( |
| 71 | - "[ReflectionClass \$interface1 [, ReflectionClass \$interface2]] array expected as\n". |
|
| 71 | + "[ReflectionClass \$interface1 [, ReflectionClass \$interface2]] array expected as\n" . |
|
| 72 | 72 | "a second argument to `ClassMirror::reflect(...)`, but got %s.", |
| 73 | - is_object($interface) ? get_class($interface).' class' : gettype($interface) |
|
| 73 | + is_object($interface) ? get_class($interface) . ' class' : gettype($interface) |
|
| 74 | 74 | )); |
| 75 | 75 | } |
| 76 | 76 | if (false === $interface->isInterface()) { |
| 77 | 77 | throw new InvalidArgumentException(sprintf( |
| 78 | - "Could not reflect %s as an interface, because it\n". |
|
| 78 | + "Could not reflect %s as an interface, because it\n" . |
|
| 79 | 79 | "is class - use the first argument instead.", |
| 80 | 80 | $interface->getName() |
| 81 | 81 | )); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | public function setStatic($static = true) |
| 76 | 76 | { |
| 77 | - $this->static = (bool) $static; |
|
| 77 | + $this->static = (bool)$static; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public function returnsReference() |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function hasReturnType() |
| 113 | 113 | { |
| 114 | - return (bool) $this->returnTypeNode->getNonNullTypes(); |
|
| 114 | + return (bool)$this->returnTypeNode->getNonNullTypes(); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public function setReturnTypeNode(ReturnTypeNode $returnTypeNode): void |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | return "throw new \Prophecy\Exception\Doubler\ReturnByReferenceException('Returning by reference not supported', get_class(\$this), '{$this->name}');"; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - return (string) $this->code; |
|
| 188 | + return (string)$this->code; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | public function useParentCode() |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | private function generateArgument(ArgumentNode $arg) |
| 201 | 201 | { |
| 202 | - $argument = '$'.$arg->getName(); |
|
| 202 | + $argument = '$' . $arg->getName(); |
|
| 203 | 203 | |
| 204 | 204 | if ($arg->isVariadic()) { |
| 205 | - $argument = '...'.$argument; |
|
| 205 | + $argument = '...' . $argument; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | return $argument; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @var MethodNode[] |
| 31 | 31 | */ |
| 32 | - private $methods = array(); |
|
| 32 | + private $methods = array(); |
|
| 33 | 33 | |
| 34 | 34 | public function getParentClass() |
| 35 | 35 | { |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | public function addMethod(MethodNode $method, $force = false) |
| 104 | 104 | { |
| 105 | - if (!$this->isExtendable($method->getName())){ |
|
| 105 | + if (!$this->isExtendable($method->getName())) { |
|
| 106 | 106 | $message = sprintf( |
| 107 | 107 | 'Method `%s` is not extendable, so can not be added.', $method->getName() |
| 108 | 108 | ); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function addUnextendableMethod($unextendableMethod) |
| 154 | 154 | { |
| 155 | - if (!$this->isExtendable($unextendableMethod)){ |
|
| 155 | + if (!$this->isExtendable($unextendableMethod)) { |
|
| 156 | 156 | return; |
| 157 | 157 | } |
| 158 | 158 | $this->unextendableMethods[] = $unextendableMethod; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $code = sprintf("class %s extends \%s implements %s {\n", |
| 44 | 44 | $classname, $class->getParentClass(), implode(', ', |
| 45 | - array_map(function ($interface) {return '\\'.$interface;}, $class->getInterfaces()) |
|
| 45 | + array_map(function($interface) {return '\\' . $interface; }, $class->getInterfaces()) |
|
| 46 | 46 | ) |
| 47 | 47 | ); |
| 48 | 48 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $code .= "\n"; |
| 53 | 53 | |
| 54 | 54 | foreach ($class->getMethods() as $method) { |
| 55 | - $code .= $this->generateMethod($method)."\n"; |
|
| 55 | + $code .= $this->generateMethod($method) . "\n"; |
|
| 56 | 56 | } |
| 57 | 57 | $code .= "\n}"; |
| 58 | 58 | |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | $php = sprintf("%s %s function %s%s(%s)%s {\n", |
| 65 | 65 | $method->getVisibility(), |
| 66 | 66 | $method->isStatic() ? 'static' : '', |
| 67 | - $method->returnsReference() ? '&':'', |
|
| 67 | + $method->returnsReference() ? '&' : '', |
|
| 68 | 68 | $method->getName(), |
| 69 | 69 | implode(', ', $this->generateArguments($method->getArguments())), |
| 70 | - ($ret = $this->generateTypes($method->getReturnTypeNode())) ? ': '.$ret : '' |
|
| 70 | + ($ret = $this->generateTypes($method->getReturnTypeNode())) ? ': ' . $ret : '' |
|
| 71 | 71 | ); |
| 72 | - $php .= $method->getCode()."\n"; |
|
| 72 | + $php .= $method->getCode() . "\n"; |
|
| 73 | 73 | |
| 74 | - return $php.'}'; |
|
| 74 | + return $php . '}'; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | private function generateTypes(TypeNodeAbstract $typeNode): string |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | // When we require PHP 8 we can stop generating ?foo nullables and remove this first block |
| 84 | 84 | if ($typeNode->canUseNullShorthand()) { |
| 85 | - return sprintf( '?%s', $typeNode->getNonNullTypes()[0]); |
|
| 85 | + return sprintf('?%s', $typeNode->getNonNullTypes()[0]); |
|
| 86 | 86 | } else { |
| 87 | 87 | return join('|', $typeNode->getTypes()); |
| 88 | 88 | } |
@@ -90,18 +90,18 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | private function generateArguments(array $arguments) |
| 92 | 92 | { |
| 93 | - return array_map(function (Node\ArgumentNode $argument){ |
|
| 93 | + return array_map(function(Node\ArgumentNode $argument) { |
|
| 94 | 94 | |
| 95 | 95 | $php = $this->generateTypes($argument->getTypeNode()); |
| 96 | 96 | |
| 97 | - $php .= ' '.($argument->isPassedByReference() ? '&' : ''); |
|
| 97 | + $php .= ' ' . ($argument->isPassedByReference() ? '&' : ''); |
|
| 98 | 98 | |
| 99 | 99 | $php .= $argument->isVariadic() ? '...' : ''; |
| 100 | 100 | |
| 101 | - $php .= '$'.$argument->getName(); |
|
| 101 | + $php .= '$' . $argument->getName(); |
|
| 102 | 102 | |
| 103 | 103 | if ($argument->isOptional() && !$argument->isVariadic()) { |
| 104 | - $php .= ' = '.var_export($argument->getDefault(), true); |
|
| 104 | + $php .= ' = ' . var_export($argument->getDefault(), true); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return $php; |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | */ |
| 52 | 52 | public function apply(ClassNode $node) |
| 53 | 53 | { |
| 54 | - $types = array_filter($node->getInterfaces(), function ($interface) { |
|
| 54 | + $types = array_filter($node->getInterfaces(), function($interface) { |
|
| 55 | 55 | return 0 !== strpos($interface, 'Prophecy\\'); |
| 56 | 56 | }); |
| 57 | 57 | $types[] = $node->getParentClass(); |
@@ -60,15 +60,15 @@ |
||
| 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 | } |