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

Backtrace included in InvalidDocblock message #8323

Closed
AndrolGenhald opened this issue Jul 26, 2022 · 1 comment · Fixed by #10679
Closed

Backtrace included in InvalidDocblock message #8323

AndrolGenhald opened this issue Jul 26, 2022 · 1 comment · Fixed by #10679

Comments

@AndrolGenhald
Copy link
Collaborator

https://psalm.dev/r/4d782ddd22

I thought it was a crash at first, but we're actually including a backtrace in the message.

Semi-related to #8322

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/4d782ddd22
<?php
                    namespace Bar;

                    /**
                     * Asserts that two variables are not the same.
                     *
                     * @template T
                     * @param T      $expected
                     * @param mixed  $actual
                     * @psalm-assert !=$expected $actual
                     */
                    function assertNotSame($expected, $actual) : void {}

                    $expected = rand(0, 1) ? 4 : 5;
                    $actual = 6;
                    assertNotSame($expected, $actual);
/** @psalm-trace $actual */;
Psalm output (using commit 4b2935f):

ERROR: InvalidDocblock - 12:21 - Invalid @psalm-assert union type Psalm\Exception\TypeParseTreeException: Invalid type '$expected' in /var/www/vhosts/psalm.dev/httpdocs/vendor/vimeo/psalm/src/Psalm/Internal/Type/TypeParser.php:384
Stack trace:
#0 /var/www/vhosts/psalm.dev/httpdocs/vendor/vimeo/psalm/src/Psalm/Internal/Type/TypeParser.php(145): Psalm\Internal\Type\TypeParser::getTypeFromTree()
#1 /var/www/vhosts/psalm.dev/httpdocs/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php(614): Psalm\Internal\Type\TypeParser::parseTokens()
#2 /var/www/vhosts/psalm.dev/httpdocs/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php(1215): Psalm\Internal\PhpVisitor\Reflector\FunctionLikeDocblockScanner::getAssertionParts()
#3 /var/www/vhosts/psalm.dev/httpdocs/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php(230): Psalm\Internal\PhpVisitor\Reflector\FunctionLikeDocblockScanner::handleAssertions()
#4 /var/www/vhosts/psalm.dev/httpdocs/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php(517): Psalm\Internal\PhpVisitor\Reflector\FunctionLikeDocblockScanner::addDocblockInfo()
#5 /var/www/vhosts/psalm.dev/httpdocs/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php(235): Psalm\Internal\PhpVisitor\Reflector\FunctionLikeNodeScanner->start()
#6 /var/www/vhosts/psalm.dev/httpdocs/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(200): Psalm\Internal\PhpVisitor\ReflectorVisitor->enterNode()
#7 /var/www/vhosts/psalm.dev/httpdocs/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114): PhpParser\NodeTraverser->traverseArray()
#8 /var/www/vhosts/psalm.dev/httpdocs/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode()
#9 /var/www/vhosts/psalm.dev/httpdocs/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(91): PhpParser\NodeTraverser->traverseArray()
#10 /var/www/vhosts/psalm.dev/httpdocs/vendor/vimeo/psalm/src/Psalm/Internal/Scanner/FileScanner.php(88): PhpParser\NodeTraverser->traverse()
#11 /var/www/vhosts/psalm.dev/httpdocs/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(581): Psalm\Internal\Scanner\FileScanner->scan()
#12 /var/www/vhosts/psalm.dev/httpdocs/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(809): Psalm\Internal\Codebase\Scanner->scanFile()
#13 /var/www/vhosts/psalm.dev/httpdocs/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(451): Psalm\Internal\Codebase\Scanner->scanAPath()
#14 /var/www/vhosts/psalm.dev/httpdocs/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php(304): Psalm\Internal\Codebase\Scanner->scanFilePaths()
#15 /var/www/vhosts/psalm.dev/httpdocs/vendor/vimeo/psalm/src/Psalm/Codebase.php(504): Psalm\Internal\Codebase\Scanner->scanFiles()
#16 /var/www/vhosts/psalm.dev/httpdocs/src/OnlineChecker.php(76): Psalm\Codebase->scanFiles()
#17 /var/www/vhosts/psalm.dev/httpdocs/views/snippet.php(88): PsalmDotOrg\OnlineChecker::getResults()
#18 {main}

INFO: UnusedParam - 12:44 - Param $expected is never referenced in this method

INFO: UnusedParam - 12:55 - Param $actual is never referenced in this method

INFO: Trace - 17:28 - $actual: 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant