diff --git a/lib/PhpParser/ParserAbstract.php b/lib/PhpParser/ParserAbstract.php index c31c97a950..dccc5865f6 100644 --- a/lib/PhpParser/ParserAbstract.php +++ b/lib/PhpParser/ParserAbstract.php @@ -121,7 +121,7 @@ abstract class ParserAbstract implements Parser { /** @var int Error state, used to avoid error floods */ protected $errorState; - /** @var \SplObjectStorage Array nodes created during parsing, for postprocessing of empty elements. */ + /** @var \SplObjectStorage|null Array nodes created during parsing, for postprocessing of empty elements. */ protected $createdArrays; /** diff --git a/lib/PhpParser/PrettyPrinterAbstract.php b/lib/PhpParser/PrettyPrinterAbstract.php index 1c1876870d..efea814ace 100644 --- a/lib/PhpParser/PrettyPrinterAbstract.php +++ b/lib/PhpParser/PrettyPrinterAbstract.php @@ -104,7 +104,7 @@ abstract class PrettyPrinterAbstract { /** @var PhpVersion PHP version to target */ protected $phpVersion; - /** @var TokenStream Original tokens for use in format-preserving pretty print */ + /** @var TokenStream|null Original tokens for use in format-preserving pretty print */ protected $origTokens; /** @var Internal\Differ Differ for node lists */ protected $nodeListDiffer; @@ -116,9 +116,9 @@ abstract class PrettyPrinterAbstract { */ protected $fixupMap; /** - * @var int[][] Map from "{$node->getType()}->{$subNode}" to ['left' => $l, 'right' => $r], - * where $l and $r specify the token type that needs to be stripped when removing - * this node. + * @var (int|string)[][] Map from "{$node->getType()}->{$subNode}" to ['left' => $l, 'right' => $r], + * where $l and $r specify the token type that needs to be stripped when + * removing this node. */ protected $removalMap; /** diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000000..8a04a4721b --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,141 @@ +parameters: + ignoreErrors: + - + message: "#^Unary operation \"~\" on mixed results in an error\\.$#" + count: 1 + path: lib/PhpParser/ConstExprEvaluator.php + + - + message: "#^Unary operation \"\\+\" on string results in an error\\.$#" + count: 1 + path: lib/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php + + - + message: "#^Access to an undefined property PhpParser\\\\Node\\:\\:\\$attrGroups\\.$#" + count: 1 + path: lib/PhpParser/NodeVisitor/NameResolver.php + + - + message: "#^Access to an undefined property PhpParser\\\\Node\\:\\:\\$name\\.$#" + count: 1 + path: lib/PhpParser/NodeVisitor/NameResolver.php + + - + message: "#^Access to an undefined property PhpParser\\\\Node\\:\\:\\$namespacedName\\.$#" + count: 1 + path: lib/PhpParser/NodeVisitor/NameResolver.php + + - + message: "#^Method PhpParser\\\\NodeVisitor\\\\NodeConnectingVisitor\\:\\:beforeTraverse\\(\\) should return array\\\\|null but return statement is missing\\.$#" + count: 1 + path: lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php + + - + message: "#^Method PhpParser\\\\NodeVisitor\\\\NodeConnectingVisitor\\:\\:enterNode\\(\\) should return array\\\\|int\\|PhpParser\\\\Node\\|null but return statement is missing\\.$#" + count: 1 + path: lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php + + - + message: "#^Method PhpParser\\\\NodeVisitor\\\\NodeConnectingVisitor\\:\\:leaveNode\\(\\) should return array\\\\|int\\|PhpParser\\\\Node\\|null but return statement is missing\\.$#" + count: 1 + path: lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php + + - + message: "#^Method PhpParser\\\\NodeVisitor\\\\ParentConnectingVisitor\\:\\:beforeTraverse\\(\\) should return array\\\\|null but return statement is missing\\.$#" + count: 1 + path: lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php + + - + message: "#^Method PhpParser\\\\NodeVisitor\\\\ParentConnectingVisitor\\:\\:enterNode\\(\\) should return array\\\\|int\\|PhpParser\\\\Node\\|null but return statement is missing\\.$#" + count: 1 + path: lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php + + - + message: "#^Method PhpParser\\\\NodeVisitor\\\\ParentConnectingVisitor\\:\\:leaveNode\\(\\) should return array\\\\|int\\|PhpParser\\\\Node\\|null but return statement is missing\\.$#" + count: 1 + path: lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php + + - + message: "#^Access to undefined constant static\\(PhpParser\\\\ParserAbstract\\)\\:\\:T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Access to undefined constant static\\(PhpParser\\\\ParserAbstract\\)\\:\\:T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Access to undefined constant static\\(PhpParser\\\\ParserAbstract\\)\\:\\:T_ATTRIBUTE\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Access to undefined constant static\\(PhpParser\\\\ParserAbstract\\)\\:\\:T_COALESCE_EQUAL\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Access to undefined constant static\\(PhpParser\\\\ParserAbstract\\)\\:\\:T_ECHO\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Access to undefined constant static\\(PhpParser\\\\ParserAbstract\\)\\:\\:T_ENUM\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Access to undefined constant static\\(PhpParser\\\\ParserAbstract\\)\\:\\:T_FN\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Access to undefined constant static\\(PhpParser\\\\ParserAbstract\\)\\:\\:T_MATCH\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Access to undefined constant static\\(PhpParser\\\\ParserAbstract\\)\\:\\:T_NAME_FULLY_QUALIFIED\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Access to undefined constant static\\(PhpParser\\\\ParserAbstract\\)\\:\\:T_NAME_QUALIFIED\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Access to undefined constant static\\(PhpParser\\\\ParserAbstract\\)\\:\\:T_NAME_RELATIVE\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Access to undefined constant static\\(PhpParser\\\\ParserAbstract\\)\\:\\:T_NULLSAFE_OBJECT_OPERATOR\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Access to undefined constant static\\(PhpParser\\\\ParserAbstract\\)\\:\\:T_PAAMAYIM_NEKUDOTAYIM\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Access to undefined constant static\\(PhpParser\\\\ParserAbstract\\)\\:\\:T_READONLY\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Unary operation \"\\+\" on string results in an error\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Variable \\$action might not be defined\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php + + - + message: "#^Variable \\$tokenValue might not be defined\\.$#" + count: 1 + path: lib/PhpParser/ParserAbstract.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000000..e70257c40b --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,7 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: 3 + paths: + - lib