@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | AnalysisResult $result, |
| 79 | 79 | $version = null, |
| 80 | 80 | $msg = null, |
| 81 | - $data = [] |
|
| 81 | + $data = [ ] |
|
| 82 | 82 | ) { |
| 83 | 83 | $this->reasonId = $reasonId; |
| 84 | 84 | $this->line = $line; |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | public function offsetExists($offset) |
| 158 | 158 | { |
| 159 | - return in_array($offset, ['data', 'reason', 'reasonName', 'line', 'msg', 'raw_msg', 'version', 'targetId']); |
|
| 159 | + return in_array($offset, [ 'data', 'reason', 'reasonName', 'line', 'msg', 'raw_msg', 'version', 'targetId' ]); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | /** |
| 31 | 31 | * @param array $options |
| 32 | 32 | */ |
| 33 | - public function __construct(array $options = []); |
|
| 33 | + public function __construct(array $options = [ ]); |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Generate a string representation of a `Result\Collection` |
@@ -44,10 +44,10 @@ |
||
| 44 | 44 | * |
| 45 | 45 | * @param array $options |
| 46 | 46 | */ |
| 47 | - public function __construct(array $options = []) |
|
| 47 | + public function __construct(array $options = [ ]) |
|
| 48 | 48 | { |
| 49 | - $this->options = isset($options['options']) ? $options['options'] : 0; |
|
| 50 | - $this->depth = isset($options['depth']) ? $options['depth'] : 512; |
|
| 49 | + $this->options = isset($options[ 'options' ]) ? $options[ 'options' ] : 0; |
|
| 50 | + $this->depth = isset($options[ 'depth' ]) ? $options[ 'depth' ] : 512; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @var \Pvra\AnalysisResult[] |
| 34 | 34 | */ |
| 35 | - private $results = []; |
|
| 35 | + private $results = [ ]; |
|
| 36 | 36 | /** |
| 37 | 37 | * The targetId of the currently highest demanding result |
| 38 | 38 | * |
@@ -190,11 +190,11 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public function jsonSerialize() |
| 192 | 192 | { |
| 193 | - $results = []; |
|
| 193 | + $results = [ ]; |
|
| 194 | 194 | foreach ($this->getIterator() as $result) { |
| 195 | - $reasonings = []; |
|
| 195 | + $reasonings = [ ]; |
|
| 196 | 196 | foreach ($result->getIterator() as $reason) { |
| 197 | - $reasonings[] = $reason->toArray(); |
|
| 197 | + $reasonings[ ] = $reason->toArray(); |
|
| 198 | 198 | } |
| 199 | 199 | $results[ $result->getAnalysisTargetId() ] = $reasonings; |
| 200 | 200 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * @var array |
| 48 | 48 | */ |
| 49 | - private $messageFormatters = []; |
|
| 49 | + private $messageFormatters = [ ]; |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * @param array|MessageLocator $locator |
@@ -72,14 +72,14 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | if ($addDefaultFormatter) { |
| 75 | - $this->addMessageFormatter(function ($id, $format) { |
|
| 75 | + $this->addMessageFormatter(function($id, $format) { |
|
| 76 | 76 | return sprintf('%s in :%s:::%s:', $format, MessageFormatter::FORMAT_KEY_TARGET_ID, |
| 77 | 77 | MessageFormatter::FORMAT_KEY_LINE); |
| 78 | 78 | }); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | if ($addDefaultExclusiveMissingMessageLocatorHandler) { |
| 82 | - $this->getLocator()->addMissingMessageHandler(function ($id, MessageLocator $locator) { |
|
| 82 | + $this->getLocator()->addMissingMessageHandler(function($id, MessageLocator $locator) { |
|
| 83 | 83 | $locator->terminateCallbackChain(); |
| 84 | 84 | $msg = 'Message for id "%s" %s could not be found.'; |
| 85 | 85 | $desc = ''; |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | * @return mixed |
| 117 | 117 | * @throws \Exception |
| 118 | 118 | */ |
| 119 | - public function getFormattedMessageFromId($msgId, array $data = []) |
|
| 119 | + public function getFormattedMessageFromId($msgId, array $data = [ ]) |
|
| 120 | 120 | { |
| 121 | - return $this->format(['id' => $msgId, 'template' => $this->getMessageTemplate($msgId)], $data); |
|
| 121 | + return $this->format([ 'id' => $msgId, 'template' => $this->getMessageTemplate($msgId) ], $data); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | * @param bool $runUserFormatters |
| 128 | 128 | * @return mixed |
| 129 | 129 | */ |
| 130 | - public function format($messageInfo, array $data = [], $runUserFormatters = true) |
|
| 130 | + public function format($messageInfo, array $data = [ ], $runUserFormatters = true) |
|
| 131 | 131 | { |
| 132 | 132 | if (is_string($messageInfo)) { |
| 133 | - $messageInfo = ['template' => $messageInfo, 'id' => 'unknown_message_id']; |
|
| 133 | + $messageInfo = [ 'template' => $messageInfo, 'id' => 'unknown_message_id' ]; |
|
| 134 | 134 | } |
| 135 | - $data += ['id' => $messageInfo['id']]; |
|
| 135 | + $data += [ 'id' => $messageInfo[ 'id' ] ]; |
|
| 136 | 136 | if ($runUserFormatters) { |
| 137 | 137 | $this->inCallbackChain(true); |
| 138 | 138 | /** @var callable $formatter */ |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | if ($this->isCallbackChainToBeTerminated()) { |
| 141 | 141 | break; |
| 142 | 142 | } |
| 143 | - $messageInfo['template'] = $formatter($messageInfo['id'], $messageInfo['template'], $this, $data); |
|
| 143 | + $messageInfo[ 'template' ] = $formatter($messageInfo[ 'id' ], $messageInfo[ 'template' ], $this, $data); |
|
| 144 | 144 | } |
| 145 | 145 | $this->markCallbackChainTerminated(); |
| 146 | 146 | } |
@@ -148,10 +148,10 @@ discard block |
||
| 148 | 148 | foreach ($data as $name => $value) { |
| 149 | 149 | // str_replace(array, array) would be better |
| 150 | 150 | // but this appears to be faster than iterating over the $data array and manipulating the keys |
| 151 | - $messageInfo['template'] = str_replace(':' . $name . ':', $value, $messageInfo['template']); |
|
| 151 | + $messageInfo[ 'template' ] = str_replace(':' . $name . ':', $value, $messageInfo[ 'template' ]); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - return $messageInfo['template']; |
|
| 154 | + return $messageInfo[ 'template' ]; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | Reason::GOTO_KEYWORD, |
| 100 | 100 | $node->getLine(), |
| 101 | 101 | null, |
| 102 | - ['name' => $node->name] |
|
| 102 | + [ 'name' => $node->name ] |
|
| 103 | 103 | ); |
| 104 | 104 | } elseif ($node instanceof Node\Stmt\Label) { |
| 105 | 105 | $this->getResult()->addRequirement( |
| 106 | 106 | Reason::JUMP_LABEL, |
| 107 | 107 | $node->getLine(), |
| 108 | 108 | null, |
| 109 | - ['name' => $node->name] |
|
| 109 | + [ 'name' => $node->name ] |
|
| 110 | 110 | ); |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | Reason::NAMESPACE_DECLERATION, |
| 122 | 122 | $node->getLine(), |
| 123 | 123 | null, |
| 124 | - ['name' => isset($node->name) ? $node->name->toString() : '::global::'] |
|
| 124 | + [ 'name' => isset($node->name) ? $node->name->toString() : '::global::' ] |
|
| 125 | 125 | ); |
| 126 | 126 | } elseif ($node instanceof Node\Scalar\MagicConst\Namespace_) { |
| 127 | 127 | $this->getResult()->addRequirement(Reason::NAMESPACE_MAGIC_CONSTANT, $node->getLine()); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | Reason::NAMESPACE_IMPORT, |
| 131 | 131 | $node->getLine(), |
| 132 | 132 | null, |
| 133 | - ['import_count' => count($node->uses)] |
|
| 133 | + [ 'import_count' => count($node->uses) ] |
|
| 134 | 134 | ); |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | Reason::CONST_KEYWORD_DOC_SYNTAX, |
| 182 | 182 | $const->value->getLine(), |
| 183 | 183 | null, |
| 184 | - ['name' => $const->name] |
|
| 184 | + [ 'name' => $const->name ] |
|
| 185 | 185 | ); |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | class Php70Features extends LanguageFeatureAnalyser implements AnalyserAwareInterface |
| 43 | 43 | { |
| 44 | 44 | // move both to be const once 5.6+ is mandatory |
| 45 | - private static $reservedNames = ['string', 'int', 'float', 'bool', 'null', 'false', 'true']; |
|
| 46 | - private static $softReservedNames = ['object', 'resource', 'mixed', 'numeric']; |
|
| 45 | + private static $reservedNames = [ 'string', 'int', 'float', 'bool', 'null', 'false', 'true' ]; |
|
| 46 | + private static $softReservedNames = [ 'object', 'resource', 'mixed', 'numeric' ]; |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * @inheritdoc |
@@ -103,12 +103,12 @@ discard block |
||
| 103 | 103 | Reason::PHP4_CONSTRUCTOR, |
| 104 | 104 | $method->getLine(), |
| 105 | 105 | null, |
| 106 | - ['name' => $method->name], |
|
| 106 | + [ 'name' => $method->name ], |
|
| 107 | 107 | ]; |
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | if ($possibleCtorInfo !== null) { |
| 111 | - call_user_func_array([$this->getResult(), 'addLimit'], $possibleCtorInfo); |
|
| 111 | + call_user_func_array([ $this->getResult(), 'addLimit' ], $possibleCtorInfo); |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -136,9 +136,9 @@ discard block |
||
| 136 | 136 | { |
| 137 | 137 | if ($call->name instanceof Node\Name && strcasecmp('class_alias', $call->name->getLast()) === 0 |
| 138 | 138 | ) { |
| 139 | - if (isset($call->args[1]) && $call->args[1]->value instanceof Node\Scalar\String_) { |
|
| 140 | - $value = $call->args[1]->value->value; |
|
| 141 | - $this->handleClassName($value, $call->args[1]->value->getLine()); |
|
| 139 | + if (isset($call->args[ 1 ]) && $call->args[ 1 ]->value instanceof Node\Scalar\String_) { |
|
| 140 | + $value = $call->args[ 1 ]->value->value; |
|
| 141 | + $this->handleClassName($value, $call->args[ 1 ]->value->getLine()); |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -182,10 +182,10 @@ discard block |
||
| 182 | 182 | $baseName = basename(str_replace('\\', '/', $name)); |
| 183 | 183 | if ($this->mode & self::MODE_DEPRECATION && $this->isNameSoftReserved($name)) { |
| 184 | 184 | $this->getResult()->addLimit(Reason::SOFT_RESERVED_NAME, $line, null, |
| 185 | - ['fqn' => $name, 'class' => $baseName]); |
|
| 185 | + [ 'fqn' => $name, 'class' => $baseName ]); |
|
| 186 | 186 | } elseif ($this->mode & self::MODE_REMOVAL && $this->isNameReserved($name)) { |
| 187 | 187 | $this->getResult()->addLimit(Reason::RESERVED_CLASS_NAME, $line, null, |
| 188 | - ['fqn' => $name, 'class' => $baseName]); |
|
| 188 | + [ 'fqn' => $name, 'class' => $baseName ]); |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | FileFinderBuilder::SORT_BY_NAME) |
| 62 | 62 | ->addOption('listFilesOnly', null, InputOption::VALUE_NONE, |
| 63 | 63 | 'Only list matched files and do not run analysis.') |
| 64 | - ->addArgument('filters', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Filter', ['name:*.php']); |
|
| 64 | + ->addArgument('filters', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Filter', [ 'name:*.php' ]); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -133,16 +133,16 @@ discard block |
||
| 133 | 133 | $highestRequirement->getAnalysisTargetId())); |
| 134 | 134 | |
| 135 | 135 | if ($highestRequirement->count() !== 0) { |
| 136 | - $tableData = []; |
|
| 136 | + $tableData = [ ]; |
|
| 137 | 137 | // order by version->descending. Might want to implement ordering by line later. |
| 138 | 138 | foreach (array_reverse($highestRequirement->getRequirements()) as $version => $reasons) { |
| 139 | 139 | foreach ($reasons as $reason) { |
| 140 | - $tableData[] = [$reason['version'], $reason['msg'], $reason['line']]; |
|
| 140 | + $tableData[ ] = [ $reason[ 'version' ], $reason[ 'msg' ], $reason[ 'line' ] ]; |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | (new Table($out)) |
| 145 | - ->setHeaders(['Version', 'Message', 'Line']) |
|
| 145 | + ->setHeaders([ 'Version', 'Message', 'Line' ]) |
|
| 146 | 146 | ->setRows($tableData) |
| 147 | 147 | ->render(); |
| 148 | 148 | } else { |
@@ -171,14 +171,14 @@ discard block |
||
| 171 | 171 | ' for the following reasons:', |
| 172 | 172 | PHP_EOL, |
| 173 | 173 | ]); |
| 174 | - $tableData = []; |
|
| 174 | + $tableData = [ ]; |
|
| 175 | 175 | /** @var $reason Reasoning */ |
| 176 | 176 | foreach ($result->getRequirementIterator() as $reason) { |
| 177 | - $tableData[] = [$reason['version'], $reason['msg'], $reason['line']]; |
|
| 177 | + $tableData[ ] = [ $reason[ 'version' ], $reason[ 'msg' ], $reason[ 'line' ] ]; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | (new Table($out)) |
| 181 | - ->setHeaders(['Version', 'Message', 'Line']) |
|
| 181 | + ->setHeaders([ 'Version', 'Message', 'Line' ]) |
|
| 182 | 182 | ->setRows($tableData) |
| 183 | 183 | ->render(); |
| 184 | 184 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | ]); |
| 214 | 214 | $out->writeln(''); |
| 215 | 215 | |
| 216 | - $usedVersions = []; |
|
| 216 | + $usedVersions = [ ]; |
|
| 217 | 217 | /** @var AnalysisResult $result */ |
| 218 | 218 | foreach ($results as $result) { |
| 219 | 219 | $versions = array_keys($result->getRequirements()); |
@@ -222,12 +222,12 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - usort($usedVersions, function ($a, $b) { |
|
| 225 | + usort($usedVersions, function($a, $b) { |
|
| 226 | 226 | return version_compare($b, $a); |
| 227 | 227 | }); |
| 228 | 228 | |
| 229 | 229 | $table = new Table($out); |
| 230 | - $table->setHeaders(['Version', 'Message', 'Position']); |
|
| 230 | + $table->setHeaders([ 'Version', 'Message', 'Position' ]); |
|
| 231 | 231 | |
| 232 | 232 | foreach ($usedVersions as $index => $version) { |
| 233 | 233 | /** @var AnalysisResult $result */ |
@@ -237,8 +237,8 @@ discard block |
||
| 237 | 237 | foreach ($selectedResults as $reason) { |
| 238 | 238 | $table->addRow([ |
| 239 | 239 | $version, |
| 240 | - $reason['msg'], |
|
| 241 | - $this->formatOutputPath($reason['targetId']) . ':' . $reason['line'], |
|
| 240 | + $reason[ 'msg' ], |
|
| 241 | + $this->formatOutputPath($reason[ 'targetId' ]) . ':' . $reason[ 'line' ], |
|
| 242 | 242 | ]); |
| 243 | 243 | } |
| 244 | 244 | } |
@@ -47,12 +47,12 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * @var array|Reasoning[] |
| 49 | 49 | */ |
| 50 | - private $requirements = []; |
|
| 50 | + private $requirements = [ ]; |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * @var array|Reasoning[] |
| 54 | 54 | */ |
| 55 | - private $limits = []; |
|
| 55 | + private $limits = [ ]; |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * @var string|null |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | $version)); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $versionComponents += [2 => 0]; |
|
| 135 | + $versionComponents += [ 2 => 0 ]; |
|
| 136 | 136 | |
| 137 | - return $versionComponents[0] * 10000 + $versionComponents[1] * 100 + $versionComponents[2]; |
|
| 137 | + return $versionComponents[ 0 ] * 10000 + $versionComponents[ 1 ] * 100 + $versionComponents[ 2 ]; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | $line = -1, |
| 234 | 234 | $msg = null, |
| 235 | 235 | $reason = Reason::UNKNOWN, |
| 236 | - array $data = [] |
|
| 236 | + array $data = [ ] |
|
| 237 | 237 | ) { |
| 238 | 238 | $this->addArbitraryVersionConstraint(self::VERSION_LIMIT_MAX, $version, $line, $msg, $reason, |
| 239 | 239 | $data); |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | * @return $this |
| 255 | 255 | * @throws \LogicException Thrown if the reason is unknown or does not have a version requirement associated. |
| 256 | 256 | */ |
| 257 | - public function addRequirement($reason, $line = -1, $msg = null, array $data = []) |
|
| 257 | + public function addRequirement($reason, $line = -1, $msg = null, array $data = [ ]) |
|
| 258 | 258 | { |
| 259 | 259 | $version = Reason::getVersionFromReason($reason); |
| 260 | 260 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | * @param array $data |
| 277 | 277 | * @return $this |
| 278 | 278 | */ |
| 279 | - public function addLimit($reason, $line = -1, $msg = null, array $data = []) |
|
| 279 | + public function addLimit($reason, $line = -1, $msg = null, array $data = [ ]) |
|
| 280 | 280 | { |
| 281 | 281 | $version = Reason::getVersionFromReason($reason); |
| 282 | 282 | |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | $line = -1, |
| 305 | 305 | $msg = null, |
| 306 | 306 | $reason = Reason::UNKNOWN, |
| 307 | - array $data = [] |
|
| 307 | + array $data = [ ] |
|
| 308 | 308 | ) { |
| 309 | 309 | $this->addArbitraryVersionConstraint(self::VERSION_LIMIT_MIN, $version, $line, $msg, $reason, |
| 310 | 310 | $data); |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | $line = -1, |
| 327 | 327 | $msg = null, |
| 328 | 328 | $reason = Reason::UNKNOWN, |
| 329 | - array $data = [] |
|
| 329 | + array $data = [ ] |
|
| 330 | 330 | ) { |
| 331 | 331 | if ($this->isSealed()) { |
| 332 | 332 | throw new \RuntimeException('Impossible to write to already sealed result'); |
@@ -336,9 +336,9 @@ discard block |
||
| 336 | 336 | $this->count++; |
| 337 | 337 | |
| 338 | 338 | if ($type === self::VERSION_LIMIT_MAX) { |
| 339 | - $this->requirements[ $version ][] = new Reasoning($reason, $line, $this, $version, $msg, $data); |
|
| 339 | + $this->requirements[ $version ][ ] = new Reasoning($reason, $line, $this, $version, $msg, $data); |
|
| 340 | 340 | } elseif ($type === self::VERSION_LIMIT_MIN) { |
| 341 | - $this->limits[ $version ][] = new Reasoning($reason, $line, $this, $version, $msg, $data); |
|
| 341 | + $this->limits[ $version ][ ] = new Reasoning($reason, $line, $this, $version, $msg, $data); |
|
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | 344 | |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | return $this->requirements[ $version ]; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - return []; |
|
| 383 | + return [ ]; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | return $this->limits[ $version ]; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - return []; |
|
| 396 | + return [ ]; |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | /** |
@@ -436,8 +436,8 @@ discard block |
||
| 436 | 436 | public function getIterator() |
| 437 | 437 | { |
| 438 | 438 | $iterator = new \ArrayIterator(); |
| 439 | - $data = [$this->getRequirements(), $this->getLimits()]; |
|
| 440 | - array_walk_recursive($data, function ($value) use ($iterator) { |
|
| 439 | + $data = [ $this->getRequirements(), $this->getLimits() ]; |
|
| 440 | + array_walk_recursive($data, function($value) use ($iterator) { |
|
| 441 | 441 | if ($value instanceof Reasoning) { |
| 442 | 442 | $iterator->append($value); |
| 443 | 443 | } |