Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Psalm crashes for @param int|array|? $i #3716

Closed
TysonAndre opened this issue Jun 29, 2020 · 0 comments
Closed

Psalm crashes for @param int|array|? $i #3716

TysonAndre opened this issue Jun 29, 2020 · 0 comments

Comments

@TysonAndre
Copy link
Contributor

TysonAndre commented Jun 29, 2020

Expected: Should warn about unparsable docblock and not crash (standalone ? is nonsense)
Observed: Crashes with uncaught TypeError - psalm.dev does not like this example

<?php

/**
 * @return int|array|? $i
 */
function takesAnInt($i) {
}
Scanning files...
Notice: Undefined offset: 0 in /path/to/psalm/src/Psalm/Internal/Type/TypeParser.php on line 346
Uncaught TypeError: Argument 1 passed to Psalm\Internal\Type\TypeParser::getTypeFromTree() must be an instance of Psalm\Internal\Type\ParseTree, null given, called in /path/to/psalm/src/Psalm/Internal/Type/TypeParser.php on line 350 and defined in /path/to/psalm/src/Psalm/Internal/Type/TypeParser.php:114
Stack trace:
#0 /path/to/psalm/src/Psalm/Internal/Type/TypeParser.php(350): Psalm\Internal\Type\TypeParser::getTypeFromTree(NULL, Object(Psalm\Codebase), NULL, Array, Array)
#1 /path/to/psalm/src/Psalm/Internal/Type/TypeParser.php(92): Psalm\Internal\Type\TypeParser::getTypeFromTree(Object(Psalm\Internal\Type\ParseTree\UnionTree), Object(Psalm\Codebase), NULL, Array, Array)
#2 /path/to/psalm/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php(2732): Psalm\Internal\Type\TypeParser::parseTokens(Array, NULL, Array, Array)
#3 /path/to/psalm/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php(337): Psalm\Internal\PhpVisitor\ReflectorVisitor->registerFunctionLike(Object(PhpParser\Node\Stmt\Function_))
#4 /path/to/psalm/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(200): Psalm\Internal\PhpVisitor\ReflectorVisitor->enterNode(Object(PhpParser\Node\Stmt\Function_))
#5 /path/to/psalm/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(91): PhpParser\NodeTraverser->traverseArray(Array)
#6 /path/to/psalm/src/Psalm/Internal/Scanner/FileScanner.php(94): PhpParser\NodeTraverser->traverse(Array)
#7 /path/to/psalm/src/Psalm/Internal/Codebase/Scanner.php(614): Psalm\Internal\Scanner\FileScanner->scan(Object(Psalm\Codebase), Object(Psalm\Storage\FileStorage), false, Object(Psalm\Progress\DefaultProgress))
#8 /path/to/psalm/src/Psalm/Internal/Codebase/Scanner.php(370): Psalm\Internal\Codebase\Scanner->scanFile('/path/to...', Array, true)
#9 /path/to/psalm/src/Psalm/Internal/Codebase/Scanner.php(482): Psalm\Internal\Codebase\Scanner->Psalm\Internal\Codebase\{closure}(0, '/path/to...')
#10 /path/to/psalm/src/Psalm/Internal/Codebase/Scanner.php(328): Psalm\Internal\Codebase\Scanner->scanFilePaths(1)
#11 /path/to/psalm/src/Psalm/Codebase.php(477): Psalm\Internal\Codebase\Scanner->scanFiles(Object(Psalm\Internal\Codebase\ClassLikes), 7)
#12 /path/to/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(572): Psalm\Codebase->scanFiles(7)
#13 /path/to/psalm/src/psalm.php(602): Psalm\Internal\Analyzer\ProjectAnalyzer->check('/path/to...', false)
#14 /path/to/psalm/psalm(2): require_once('/path/to...')
#15 {main}
(Psalm 3.x-dev@537a1194e58da753cad0ab2d271017ca1024418a crashed due to an uncaught Throwable)
@muglug muglug closed this as completed in 7253e01 Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant