Skip to content

Commit

Permalink
Fix some types
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Sep 17, 2022
1 parent 9f9c2ea commit b3ad14b
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/PhpParser/Builder/FunctionLike.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ abstract class FunctionLike extends Declaration {
/** @var Node\Param[] */
protected $params = [];

/** @var string|Node\Name|Node\NullableType|null */
/** @var Node\Identifier|Node\Name|Node\ComplexType|null */
protected $returnType = null;

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/PhpParser/Builder/TraitUseAdaptation.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function as($alias) {
throw new \LogicException('Cannot set alias for not alias adaptation buider');
}

$this->alias = $alias;
$this->alias = BuilderHelpers::normalizeIdentifier($alias);
return $this;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/PhpParser/BuilderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function enum(string $name): Builder\Enum_ {
*
* @param Node\Name|string ...$traits Trait names
*
* @return Builder\TraitUse The create trait use builder
* @return Builder\TraitUse The created trait use builder
*/
public function useTrait(...$traits): Builder\TraitUse {
return new Builder\TraitUse(...$traits);
Expand All @@ -98,7 +98,7 @@ public function useTrait(...$traits): Builder\TraitUse {
* @param Node\Name|string|null $trait Trait name
* @param Node\Identifier|string $method Method name
*
* @return Builder\TraitUseAdaptation The create trait use adaptation builder
* @return Builder\TraitUseAdaptation The created trait use adaptation builder
*/
public function traitUseAdaptation($trait, $method = null): Builder\TraitUseAdaptation {
if ($method === null) {
Expand Down
2 changes: 1 addition & 1 deletion lib/PhpParser/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public function getReformattedText() {
*/
private function getShortestWhitespacePrefixLen(string $str): int {
$lines = explode("\n", $str);
$shortestPrefixLen = \INF;
$shortestPrefixLen = \PHP_INT_MAX;
foreach ($lines as $line) {
preg_match('(^\s*)', $line, $matches);
$prefixLen = strlen($matches[0]);
Expand Down
4 changes: 2 additions & 2 deletions lib/PhpParser/Internal/PrintableNewAnonClassNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class PrintableNewAnonClassNode extends Expr {
/** @var Node\AttributeGroup[] PHP attribute groups */
public $attrGroups;
/** @var Node\Arg[] Arguments */
/** @var (Node\Arg|Node\VariadicPlaceholder)[] Arguments */
public $args;
/** @var null|Node\Name Name of extended class */
public $extends;
Expand All @@ -29,7 +29,7 @@ class PrintableNewAnonClassNode extends Expr {

/**
* @param Node\AttributeGroup[] $attrGroups PHP attribute groups
* @param Node\Arg[] $args Arguments
* @param (Node\Arg|Node\VariadicPlaceholder)[] $args Arguments
* @param Node\Name|null $extends Name of extended class
* @param Node\Name[] $implements Names of implemented interfaces
* @param Node\Stmt[] $stmts Statements
Expand Down
1 change: 1 addition & 0 deletions lib/PhpParser/JsonDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ private function reflectionClassFromNodeType(string $nodeType): \ReflectionClass
return $this->reflectionClassCache[$nodeType];
}

/** @return class-string<Node> */
private function classNameFromNodeType(string $nodeType): string {
$className = 'PhpParser\\Node\\' . strtr($nodeType, '_', '\\');
if (class_exists($className)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/PhpParser/Node/Stmt/ClassMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ClassMethod extends Node\Stmt implements FunctionLike {
* byRef?: bool,
* params?: Node\Param[],
* returnType?: null|string|Node\Identifier|Node\Name|Node\ComplexType,
* stmts?: Node\Stmt[],
* stmts?: Node\Stmt[]|null,
* attrGroups?: Node\AttributeGroup[],
* } $subNodes Array of the following optional subnodes:
* 'flags => 0 : Flags
Expand Down
2 changes: 1 addition & 1 deletion lib/PhpParser/NodeVisitor/NameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private function addAlias(Node\UseItem $use, int $type, ?Name $prefix = null): v
);
}

/** @param Stmt\Function_|Stmt\ClassMethod|Expr\Closure $node */
/** @param Stmt\Function_|Stmt\ClassMethod|Expr\Closure|Expr\ArrowFunction $node */
private function resolveSignature($node): void {
foreach ($node->params as $param) {
$param->type = $this->resolveType($param->type);
Expand Down

0 comments on commit b3ad14b

Please sign in to comment.