@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | return false; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - $keyScores = array_map(array($this->key,'scoreArgument'), array_keys($argument)); |
|
| 62 | - $valueScores = array_map(array($this->value,'scoreArgument'), $argument); |
|
| 63 | - $scoreEntry = function ($value, $key) { |
|
| 64 | - return $value && $key ? min(8, ($key + $value) / 2) : false; |
|
| 61 | + $keyScores = array_map(array($this->key, 'scoreArgument'), array_keys($argument)); |
|
| 62 | + $valueScores = array_map(array($this->value, 'scoreArgument'), $argument); |
|
| 63 | + $scoreEntry = function($value, $key) { |
|
| 64 | + return $value && $key ? min(8, ($key + $value)/2) : false; |
|
| 65 | 65 | }; |
| 66 | 66 | |
| 67 | 67 | return max(array_map($scoreEntry, $valueScores, $keyScores)); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | { |
| 131 | 131 | if (!$this->key instanceof ExactValueToken) { |
| 132 | 132 | throw new InvalidArgumentException(sprintf( |
| 133 | - 'You can only use exact value tokens to match key of ArrayAccess object'.PHP_EOL. |
|
| 133 | + 'You can only use exact value tokens to match key of ArrayAccess object' . PHP_EOL . |
|
| 134 | 134 | 'But you used `%s`.', |
| 135 | 135 | $this->key |
| 136 | 136 | )); |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | return false; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - return array_sum($scores) / count($scores); |
|
| 56 | + return array_sum($scores)/count($scores); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -83,8 +83,8 @@ |
||
| 83 | 83 | public function __toString() |
| 84 | 84 | { |
| 85 | 85 | if (null === $this->string) { |
| 86 | - $this->string = implode(', ', array_map(function ($token) { |
|
| 87 | - return (string) $token; |
|
| 86 | + $this->string = implode(', ', array_map(function($token) { |
|
| 87 | + return (string)$token; |
|
| 88 | 88 | }, $this->tokens)); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // Sort matches by their score value |
| 93 | - @usort($matches, function ($match1, $match2) { return $match2[0] - $match1[0]; }); |
|
| 93 | + @usort($matches, function($match1, $match2) { return $match2[0] - $match1[0]; }); |
|
| 94 | 94 | |
| 95 | 95 | $score = $matches[0][0]; |
| 96 | 96 | // If Highest rated method prophecy has a promise - execute it or return null instead |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $methodName = strtolower($methodName); |
| 138 | 138 | |
| 139 | 139 | return array_values( |
| 140 | - array_filter($this->recordedCalls, function (Call $call) use ($methodName, $wildcard) { |
|
| 140 | + array_filter($this->recordedCalls, function(Call $call) use ($methodName, $wildcard) { |
|
| 141 | 141 | return $methodName === strtolower($call->getMethodName()) |
| 142 | 142 | && 0 < $call->getScore($wildcard) |
| 143 | 143 | ; |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | return new UnexpectedCallException( |
| 196 | 196 | sprintf( |
| 197 | - "Unexpected method call on %s:\n". |
|
| 198 | - " - %s(\n". |
|
| 199 | - "%s\n". |
|
| 200 | - " )\n". |
|
| 201 | - "expected calls were:\n". |
|
| 197 | + "Unexpected method call on %s:\n" . |
|
| 198 | + " - %s(\n" . |
|
| 199 | + "%s\n" . |
|
| 200 | + " )\n" . |
|
| 201 | + "expected calls were:\n" . |
|
| 202 | 202 | "%s", |
| 203 | 203 | |
| 204 | 204 | $classname, $methodName, $argstring, implode("\n", $expected) |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | { |
| 213 | 213 | return preg_replace_callback( |
| 214 | 214 | '/^/m', |
| 215 | - function () use ($indentationLength) { |
|
| 215 | + function() use ($indentationLength) { |
|
| 216 | 216 | return str_repeat(' ', $indentationLength); |
| 217 | 217 | }, |
| 218 | 218 | $arguments |
@@ -42,18 +42,18 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | if (is_array($value)) { |
| 44 | 44 | if (range(0, count($value) - 1) === array_keys($value)) { |
| 45 | - return '['.implode(', ', array_map(array($this, __FUNCTION__), $value)).']'; |
|
| 45 | + return '[' . implode(', ', array_map(array($this, __FUNCTION__), $value)) . ']'; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $stringify = array($this, __FUNCTION__); |
| 49 | 49 | |
| 50 | - return '['.implode(', ', array_map(function ($item, $key) use ($stringify) { |
|
| 51 | - return (is_integer($key) ? $key : '"'.$key.'"'). |
|
| 52 | - ' => '.call_user_func($stringify, $item); |
|
| 53 | - }, $value, array_keys($value))).']'; |
|
| 50 | + return '[' . implode(', ', array_map(function($item, $key) use ($stringify) { |
|
| 51 | + return (is_integer($key) ? $key : '"' . $key . '"') . |
|
| 52 | + ' => ' . call_user_func($stringify, $item); |
|
| 53 | + }, $value, array_keys($value))) . ']'; |
|
| 54 | 54 | } |
| 55 | 55 | if (is_resource($value)) { |
| 56 | - return get_resource_type($value).':'.$value; |
|
| 56 | + return get_resource_type($value) . ':' . $value; |
|
| 57 | 57 | } |
| 58 | 58 | if (is_object($value)) { |
| 59 | 59 | return $exportObject ? ExportUtil::export($value) : sprintf('%s:%s', get_class($value), spl_object_hash($value)); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $str = sprintf('"%s"', str_replace("\n", '\\n', $value)); |
| 66 | 66 | |
| 67 | 67 | if (!$this->verbose && 50 <= strlen($str)) { |
| 68 | - return substr($str, 0, 50).'"...'; |
|
| 68 | + return substr($str, 0, 50) . '"...'; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | return $str; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | return 'null'; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - return (string) $value; |
|
| 77 | + return (string)$value; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | { |
| 89 | 89 | $self = $this; |
| 90 | 90 | |
| 91 | - return implode(PHP_EOL, array_map(function (Call $call) use ($self) { |
|
| 91 | + return implode(PHP_EOL, array_map(function(Call $call) use ($self) { |
|
| 92 | 92 | return sprintf(' - %s(%s) @ %s', |
| 93 | 93 | $call->getMethodName(), |
| 94 | 94 | implode(', ', array_map(array($self, 'stringify'), $call->getArguments())), |
| 95 | - str_replace(GETCWD().DIRECTORY_SEPARATOR, '', $call->getCallPlace()) |
|
| 95 | + str_replace(GETCWD() . DIRECTORY_SEPARATOR, '', $call->getCallPlace()) |
|
| 96 | 96 | ); |
| 97 | 97 | }, $calls)); |
| 98 | 98 | } |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | public static function toArray($value) |
| 53 | 53 | { |
| 54 | 54 | if (!is_object($value)) { |
| 55 | - return (array) $value; |
|
| 55 | + return (array)$value; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $array = array(); |
| 59 | 59 | |
| 60 | - foreach ((array) $value as $key => $val) { |
|
| 60 | + foreach ((array)$value as $key => $val) { |
|
| 61 | 61 | // properties are transformed to keys in the following way: |
| 62 | 62 | // private $property => "\0Classname\0property" |
| 63 | 63 | // protected $property => "\0*\0property" |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | "'"; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - $whitespace = str_repeat(' ', 4 * $indentation); |
|
| 150 | + $whitespace = str_repeat(' ', 4*$indentation); |
|
| 151 | 151 | |
| 152 | 152 | if (!$processed) { |
| 153 | 153 | $processed = new Context; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | if (null === $double || !$double instanceof ProphecySubjectInterface) { |
| 117 | 117 | throw new ObjectProphecyException( |
| 118 | - "Generated double must implement ProphecySubjectInterface, but it does not.\n". |
|
| 118 | + "Generated double must implement ProphecySubjectInterface, but it does not.\n" . |
|
| 119 | 119 | 'It seems you have wrongly configured doubler without required ClassPatch.', |
| 120 | 120 | $this |
| 121 | 121 | ); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $argumentsWildcard = $methodProphecy->getArgumentsWildcard(); |
| 140 | 140 | if (null === $argumentsWildcard) { |
| 141 | 141 | throw new MethodProphecyException(sprintf( |
| 142 | - "Can not add prophecy for a method `%s::%s()`\n". |
|
| 142 | + "Can not add prophecy for a method `%s::%s()`\n" . |
|
| 143 | 143 | "as you did not specify arguments wildcard for it.", |
| 144 | 144 | get_class($this->reveal()), |
| 145 | 145 | $methodProphecy->getMethodName() |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $reflectedMethod = new \ReflectionMethod($double, $methodName); |
| 63 | 63 | if ($reflectedMethod->isFinal()) { |
| 64 | 64 | throw new MethodProphecyException(sprintf( |
| 65 | - "Can not add prophecy for a method `%s::%s()`\n". |
|
| 65 | + "Can not add prophecy for a method `%s::%s()`\n" . |
|
| 66 | 66 | "as it is a final method.", |
| 67 | 67 | get_class($double), |
| 68 | 68 | $methodName |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | return class_exists($type) || interface_exists($type); |
| 107 | 107 | }; |
| 108 | 108 | |
| 109 | - if($isObject($type1) && !$isObject($type2)) { |
|
| 109 | + if ($isObject($type1) && !$isObject($type2)) { |
|
| 110 | 110 | return -1; |
| 111 | 111 | } |
| 112 | - elseif(!$isObject($type1) && $isObject($type2)) |
|
| 112 | + elseif (!$isObject($type1) && $isObject($type2)) |
|
| 113 | 113 | { |
| 114 | 114 | return 1; |
| 115 | 115 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $this->voidReturnType = true; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $this->will(function () use ($defaultType) { |
|
| 128 | + $this->will(function() use ($defaultType) { |
|
| 129 | 129 | switch ($defaultType) { |
| 130 | 130 | case 'void': return; |
| 131 | 131 | case 'string': return ''; |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | case 'callable': |
| 138 | 138 | case 'Closure': |
| 139 | - return function () {}; |
|
| 139 | + return function() {}; |
|
| 140 | 140 | |
| 141 | 141 | case 'Traversable': |
| 142 | 142 | case 'Generator': |
| 143 | - return (function () { yield; })(); |
|
| 143 | + return (function() { yield; })(); |
|
| 144 | 144 | |
| 145 | 145 | default: |
| 146 | 146 | $prophet = new Prophet; |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | if (!$arguments instanceof Argument\ArgumentsWildcard) { |
| 169 | 169 | throw new InvalidArgumentException(sprintf( |
| 170 | - "Either an array or an instance of ArgumentsWildcard expected as\n". |
|
| 170 | + "Either an array or an instance of ArgumentsWildcard expected as\n" . |
|
| 171 | 171 | 'a `MethodProphecy::withArguments()` argument, but got %s.', |
| 172 | 172 | gettype($arguments) |
| 173 | 173 | )); |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | )); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - $generator = function() use ($items) { |
|
| 251 | + $generator = function() use ($items) { |
|
| 252 | 252 | foreach ($items as $key => $value) { |
| 253 | 253 | yield $key => $value; |
| 254 | 254 | } |
@@ -21,10 +21,10 @@ |
||
| 21 | 21 | public function append(PredictionException $exception) |
| 22 | 22 | { |
| 23 | 23 | $message = $exception->getMessage(); |
| 24 | - $message = strtr($message, array("\n" => "\n "))."\n"; |
|
| 24 | + $message = strtr($message, array("\n" => "\n ")) . "\n"; |
|
| 25 | 25 | $message = empty($this->exceptions) ? $message : "\n" . $message; |
| 26 | 26 | |
| 27 | - $this->message = rtrim($this->message.$message); |
|
| 27 | + $this->message = rtrim($this->message . $message); |
|
| 28 | 28 | $this->exceptions[] = $exception; |
| 29 | 29 | } |
| 30 | 30 | |