@@ -24,8 +24,8 @@ |
||
| 24 | 24 | /** |
| 25 | 25 | * Initializes reflection instance for given AST-node |
| 26 | 26 | * |
| 27 | - * @param string|\Closure $functionName The name of the function to reflect or a closure. |
|
| 28 | - * @param Function_|null $functionNode Function node AST |
|
| 27 | + * @param string $functionName The name of the function to reflect or a closure. |
|
| 28 | + * @param Function_ $functionNode Function node AST |
|
| 29 | 29 | */ |
| 30 | 30 | public function __construct($functionName, Function_ $functionNode) |
| 31 | 31 | { |
@@ -106,14 +106,14 @@ |
||
| 106 | 106 | |
| 107 | 107 | return sprintf( |
| 108 | 108 | $reflectionFormat, |
| 109 | - $this->getDocComment() ? $this->getDocComment() . "\n" : '', |
|
| 109 | + $this->getDocComment() ? $this->getDocComment()."\n" : '', |
|
| 110 | 110 | $this->getName(), |
| 111 | 111 | $this->getFileName(), |
| 112 | 112 | $this->getStartLine(), |
| 113 | 113 | $this->getEndLine(), |
| 114 | 114 | count($this->getParameters()), |
| 115 | - array_reduce($this->getParameters(), function ($str, ReflectionParameter $param) { |
|
| 116 | - return $str . "\n " . $param; |
|
| 115 | + array_reduce($this->getParameters(), function($str, ReflectionParameter $param) { |
|
| 116 | + return $str."\n ".$param; |
|
| 117 | 117 | }, '') |
| 118 | 118 | ); |
| 119 | 119 | } |
@@ -306,6 +306,7 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | /** |
| 308 | 308 | * {@inheritdoc} |
| 309 | + * @param string $name |
|
| 309 | 310 | */ |
| 310 | 311 | public function getMethod($name) |
| 311 | 312 | { |
@@ -499,6 +500,7 @@ discard block |
||
| 499 | 500 | |
| 500 | 501 | /** |
| 501 | 502 | * {@inheritdoc} |
| 503 | + * @param string $name |
|
| 502 | 504 | */ |
| 503 | 505 | public function hasMethod($name) |
| 504 | 506 | { |
@@ -529,6 +531,7 @@ discard block |
||
| 529 | 531 | |
| 530 | 532 | /** |
| 531 | 533 | * {@inheritDoc} |
| 534 | + * @param string $interfaceName |
|
| 532 | 535 | */ |
| 533 | 536 | public function implementsInterface($interfaceName) |
| 534 | 537 | { |
@@ -133,17 +133,17 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $buildString = function (array $items, $indentLevel = 4) { |
|
| 136 | + $buildString = function(array $items, $indentLevel = 4) { |
|
| 137 | 137 | if (!count($items)) { |
| 138 | 138 | return ''; |
| 139 | 139 | } |
| 140 | - $indent = "\n" . str_repeat(' ', $indentLevel); |
|
| 141 | - return $indent . implode($indent, explode("\n", implode("\n", $items))); |
|
| 140 | + $indent = "\n".str_repeat(' ', $indentLevel); |
|
| 141 | + return $indent.implode($indent, explode("\n", implode("\n", $items))); |
|
| 142 | 142 | }; |
| 143 | - $buildConstants = function (array $items, $indentLevel = 4) { |
|
| 143 | + $buildConstants = function(array $items, $indentLevel = 4) { |
|
| 144 | 144 | $str = ''; |
| 145 | 145 | foreach ($items as $name => $value) { |
| 146 | - $str .= "\n" . str_repeat(' ', $indentLevel); |
|
| 146 | + $str .= "\n".str_repeat(' ', $indentLevel); |
|
| 147 | 147 | $str .= sprintf( |
| 148 | 148 | 'Constant [ %s %s ] { %s }', |
| 149 | 149 | gettype($value), |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | ($isObject ? 'Object of class' : 'Class'), |
| 168 | 168 | $modifiers, |
| 169 | 169 | $this->getName(), |
| 170 | - false !== $parentClass ? (' extends ' . $parentClass->getName()) : '', |
|
| 171 | - $interfaceNames ? (' implements ' . implode(', ', $interfaceNames)) : '', |
|
| 170 | + false !== $parentClass ? (' extends '.$parentClass->getName()) : '', |
|
| 171 | + $interfaceNames ? (' implements '.implode(', ', $interfaceNames)) : '', |
|
| 172 | 172 | $this->getFileName(), |
| 173 | 173 | $this->getStartLine(), |
| 174 | 174 | $this->getEndLine(), |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | public function getConstants() |
| 209 | 209 | { |
| 210 | 210 | if (!isset($this->constants)) { |
| 211 | - $this->constants = $this->recursiveCollect(function (array &$result, \ReflectionClass $instance) { |
|
| 211 | + $this->constants = $this->recursiveCollect(function(array &$result, \ReflectionClass $instance) { |
|
| 212 | 212 | $result += $instance->getConstants(); |
| 213 | 213 | }); |
| 214 | 214 | $this->collectSelfConstants(); |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $staticOrder = [true, false]; |
| 246 | 246 | foreach ($staticOrder as $shouldBeStatic) { |
| 247 | 247 | foreach ($properties as $property) { |
| 248 | - $isStaticProperty = $property->isStatic(); |
|
| 248 | + $isStaticProperty = $property->isStatic(); |
|
| 249 | 249 | if ($shouldBeStatic !== $isStaticProperty) { |
| 250 | 250 | continue; |
| 251 | 251 | } |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | public function getInterfaces() |
| 310 | 310 | { |
| 311 | 311 | if (!isset($this->interfaceClasses)) { |
| 312 | - $this->interfaceClasses = $this->recursiveCollect(function (array &$result, \ReflectionClass $instance) { |
|
| 312 | + $this->interfaceClasses = $this->recursiveCollect(function(array &$result, \ReflectionClass $instance) { |
|
| 313 | 313 | if ($instance->isInterface()) { |
| 314 | 314 | $result[$instance->name] = $instance; |
| 315 | 315 | } |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | { |
| 347 | 347 | if (!isset($this->methods)) { |
| 348 | 348 | $directMethods = ReflectionMethod::collectFromClassNode($this->classLikeNode, $this); |
| 349 | - $parentMethods = $this->recursiveCollect(function (array &$result, \ReflectionClass $instance, $isParent) { |
|
| 349 | + $parentMethods = $this->recursiveCollect(function(array &$result, \ReflectionClass $instance, $isParent) { |
|
| 350 | 350 | $reflectionMethods = []; |
| 351 | 351 | foreach ($instance->getMethods() as $reflectionMethod) { |
| 352 | 352 | if (!$isParent || !$reflectionMethod->isPrivate()) { |
@@ -416,9 +416,9 @@ discard block |
||
| 416 | 416 | */ |
| 417 | 417 | public function getName() |
| 418 | 418 | { |
| 419 | - $namespaceName = $this->namespaceName ? $this->namespaceName . '\\' : ''; |
|
| 419 | + $namespaceName = $this->namespaceName ? $this->namespaceName.'\\' : ''; |
|
| 420 | 420 | |
| 421 | - return $namespaceName . $this->getShortName(); |
|
| 421 | + return $namespaceName.$this->getShortName(); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | { |
| 463 | 463 | if (!isset($this->properties)) { |
| 464 | 464 | $directProperties = ReflectionProperty::collectFromClassNode($this->classLikeNode, $this->getName()); |
| 465 | - $parentProperties = $this->recursiveCollect(function (array &$result, \ReflectionClass $instance, $isParent) { |
|
| 465 | + $parentProperties = $this->recursiveCollect(function(array &$result, \ReflectionClass $instance, $isParent) { |
|
| 466 | 466 | $reflectionProperties = []; |
| 467 | 467 | foreach ($instance->getProperties() as $reflectionProperty) { |
| 468 | 468 | if (!$isParent || !$reflectionProperty->isPrivate()) { |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | break; |
| 543 | 543 | } |
| 544 | 544 | } |
| 545 | - $aliases[$adaptation->newName] = $traitName . '::'. $methodName; |
|
| 545 | + $aliases[$adaptation->newName] = $traitName.'::'.$methodName; |
|
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | 548 | |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | if ($this->functionLikeNode instanceof Function_ || $this->functionLikeNode instanceof ClassMethod) { |
| 102 | 102 | $functionName = $this->functionLikeNode->name; |
| 103 | 103 | |
| 104 | - return $this->namespaceName ? $this->namespaceName . '\\' . $functionName : $functionName; |
|
| 104 | + return $this->namespaceName ? $this->namespaceName.'\\'.$functionName : $functionName; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return false; |
@@ -174,7 +174,7 @@ |
||
| 174 | 174 | /** |
| 175 | 175 | * Gets the specified return type of a function |
| 176 | 176 | * |
| 177 | - * @return \ReflectionType |
|
| 177 | + * @return null|ReflectionType |
|
| 178 | 178 | * |
| 179 | 179 | * @link http://php.net/manual/en/reflectionfunctionabstract.getreturntype.php |
| 180 | 180 | */ |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | |
| 51 | 51 | $isRelative = !$pathScheme && ($path[0] !== '/') && ($path[1] !== ':'); |
| 52 | 52 | if ($isRelative) { |
| 53 | - $path = getcwd() . DIRECTORY_SEPARATOR . $path; |
|
| 53 | + $path = getcwd().DIRECTORY_SEPARATOR.$path; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // resolve path parts (single dot, double dot and double delimiters) |
@@ -159,6 +159,9 @@ |
||
| 159 | 159 | return ''; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | + /** |
|
| 163 | + * @return string |
|
| 164 | + */ |
|
| 162 | 165 | protected function resolveScalarMagicConstNamespace() |
| 163 | 166 | { |
| 164 | 167 | if (method_exists($this->context, 'getNamespaceName')) { |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | ++$this->nodeLevel; |
| 114 | 114 | |
| 115 | 115 | $nodeType = $node->getType(); |
| 116 | - $methodName = 'resolve' . str_replace('_', '', $nodeType); |
|
| 116 | + $methodName = 'resolve'.str_replace('_', '', $nodeType); |
|
| 117 | 117 | if (method_exists($this, $methodName)) { |
| 118 | 118 | $value = $this->$methodName($node); |
| 119 | 119 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | protected function resolveScalarMagicConstMethod() |
| 143 | 143 | { |
| 144 | 144 | if ($this->context instanceof \ReflectionMethod) { |
| 145 | - $fullName = $this->context->getDeclaringClass()->getName() . '::' . $this->context->getShortName(); |
|
| 145 | + $fullName = $this->context->getDeclaringClass()->getName().'::'.$this->context->getShortName(); |
|
| 146 | 146 | |
| 147 | 147 | return $fullName; |
| 148 | 148 | } |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $fileNamespace = new ReflectionFileNamespace($fileName, $namespaceName); |
| 237 | 237 | if ($fileNamespace->hasConstant($constantName)) { |
| 238 | 238 | $constantValue = $fileNamespace->getConstant($constantName); |
| 239 | - $constantName = $fileNamespace->getName() . '\\' . $constantName; |
|
| 239 | + $constantName = $fileNamespace->getName().'\\'.$constantName; |
|
| 240 | 240 | $isResolved = true; |
| 241 | 241 | } |
| 242 | 242 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | $this->isConstant = true; |
| 268 | - $this->constantName = (string)$node->class . '::' . $constantName; |
|
| 268 | + $this->constantName = (string) $node->class.'::'.$constantName; |
|
| 269 | 269 | |
| 270 | 270 | return $refClass->getConstant($constantName); |
| 271 | 271 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | |
| 345 | 345 | protected function resolveExprBinaryOpConcat(Expr\BinaryOp\Concat $node) |
| 346 | 346 | { |
| 347 | - return $this->resolve($node->left) . $this->resolve($node->right); |
|
| 347 | + return $this->resolve($node->left).$this->resolve($node->right); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | protected function resolveExprTernary(Expr\Ternary $node) |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | foreach ($this->namespaceNode->stmts as $namespaceLevelNode) { |
| 320 | 320 | if ($namespaceLevelNode instanceof ClassLike) { |
| 321 | 321 | $classShortName = $namespaceLevelNode->name; |
| 322 | - $className = $namespaceName ? $namespaceName .'\\' . $classShortName : $classShortName; |
|
| 322 | + $className = $namespaceName ? $namespaceName.'\\'.$classShortName : $classShortName; |
|
| 323 | 323 | |
| 324 | 324 | $namespaceLevelNode->setAttribute('fileName', $this->fileName); |
| 325 | 325 | $classes[$className] = new ReflectionClass($className, $namespaceLevelNode); |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | foreach ($this->namespaceNode->stmts as $namespaceLevelNode) { |
| 344 | 344 | if ($namespaceLevelNode instanceof Function_) { |
| 345 | 345 | $funcShortName = $namespaceLevelNode->name; |
| 346 | - $functionName = $namespaceName ? $namespaceName .'\\' . $funcShortName : $funcShortName; |
|
| 346 | + $functionName = $namespaceName ? $namespaceName.'\\'.$funcShortName : $funcShortName; |
|
| 347 | 347 | |
| 348 | 348 | $namespaceLevelNode->setAttribute('fileName', $this->fileName); |
| 349 | 349 | $functions[$funcShortName] = new ReflectionFunction($functionName, $namespaceLevelNode); |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | foreach ($this->namespaceNode->stmts as $namespaceLevelNode) { |
| 383 | 383 | if ($namespaceLevelNode instanceof FuncCall |
| 384 | 384 | && $namespaceLevelNode->name instanceof Name |
| 385 | - && (string)$namespaceLevelNode->name === 'define' |
|
| 385 | + && (string) $namespaceLevelNode->name === 'define' |
|
| 386 | 386 | ) { |
| 387 | 387 | $expressionSolver->process($namespaceLevelNode->args[0]->value); |
| 388 | 388 | $constantName = $expressionSolver->getValue(); |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | /** |
| 30 | 30 | * Initializes reflection instance |
| 31 | 31 | * |
| 32 | - * @param string|object $argument Class name or instance of object |
|
| 32 | + * @param string|null $argument Class name or instance of object |
|
| 33 | 33 | * @param ClassLike $classLikeNode AST node for class |
| 34 | 34 | */ |
| 35 | 35 | public function __construct($argument, ClassLike $classLikeNode = null) |
@@ -38,6 +38,8 @@ |
||
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * Initializes reflection data |
| 41 | + * @param boolean $allowsNull |
|
| 42 | + * @param boolean $isBuiltin |
|
| 41 | 43 | */ |
| 42 | 44 | public function __construct($type, $allowsNull, $isBuiltin) |
| 43 | 45 | { |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | if ($hasDefaultValue) { |
| 129 | 129 | $defaultValue = $this->getDefaultValue(); |
| 130 | 130 | if (is_string($defaultValue) && strlen($defaultValue) > 15) { |
| 131 | - $defaultValue = substr($defaultValue, 0, 15) . '...'; |
|
| 131 | + $defaultValue = substr($defaultValue, 0, 15).'...'; |
|
| 132 | 132 | } |
| 133 | 133 | /* @see https://3v4l.org/DJOEb for behaviour changes */ |
| 134 | 134 | if (is_double($defaultValue) && fmod($defaultValue, 1.0) === 0.0) { |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | 'Parameter #%d [ %s %s%s%s$%s%s ]', |
| 143 | 143 | $this->parameterIndex, |
| 144 | 144 | $isOptional ? '<optional>' : '<required>', |
| 145 | - $parameterType ? ReflectionType::convertToDisplayType($parameterType) . ' ' : '', |
|
| 145 | + $parameterType ? ReflectionType::convertToDisplayType($parameterType).' ' : '', |
|
| 146 | 146 | $this->isVariadic() ? '...' : '', |
| 147 | 147 | $this->isPassedByReference() ? '&' : '', |
| 148 | 148 | $this->getName(), |
| 149 | - ($isOptional && $hasDefaultValue) ? (' = ' . $defaultValue) : '' |
|
| 149 | + ($isOptional && $hasDefaultValue) ? (' = '.$defaultValue) : '' |
|
| 150 | 150 | ); |
| 151 | 151 | } |
| 152 | 152 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | throw new ReflectionException("Can not resolve a class name for parameter"); |
| 198 | 198 | } |
| 199 | - $className = $parameterType->toString(); |
|
| 199 | + $className = $parameterType->toString(); |
|
| 200 | 200 | $classOrInterfaceExists = class_exists($className, false) || interface_exists($className, false); |
| 201 | 201 | |
| 202 | 202 | return $classOrInterfaceExists ? new \ReflectionClass($className) : new ReflectionClass($className); |