Git Product home page Git Product logo

Comments (6)

psalm-github-bot avatar psalm-github-bot commented on June 25, 2024

I found these snippets:

https://psalm.dev/r/6a9ab1188c
<?php
/** 
 * @psalm-type LoginCredsArrayShape = array{
 * domain?: string // domain being logged into
 * }
 */

/**
 * Login Class
 */
class Login
{
}
Psalm output (using commit a75d26a):

ERROR: InvalidDocblock - 11:1 - array{ domain?: string // domain being logged into } is not a valid type: Comment lines must be terminated with a new line character (\n).
https://psalm.dev/r/005b7c90a2
<?php
/** 
 * @psalm-type LoginCredsArrayShape = array{
 * domain?: string
 * }
 */

/**
 * Login Class
 */
class Login
{
}
Psalm output (using commit a75d26a):

No issues!

from psalm.

juacala avatar juacala commented on June 25, 2024

If someone can help point me to the right place in the code to look at this, I'd be happy to work on a pull request for it.

from psalm.

ging-dev avatar ging-dev commented on June 25, 2024

If someone can help point me to the right place in the code to look at this, I'd be happy to work on a pull request for it.

you can start debug from

'Comment lines must be terminated with a new line character (\\n).',

from psalm.

juacala avatar juacala commented on June 25, 2024

@ging-dev Although the same error is thrown, I can't get that line to hit in the debugger (I've verified the debugger is running and breaks on the initial PHP file). Is there a cache I need to disable to get it to appropriately reanalyze files during development?

from psalm.

ging-dev avatar ging-dev commented on June 25, 2024

@ging-dev Although the same error is thrown, I can't get that line to hit in the debugger (I've verified the debugger is running and breaks on the initial PHP file). Is there a cache I need to disable to get it to appropriately reanalyze files during development?

For xdebug to work with Psalm, you need to set the environment variable PSALM_ALLOW_XDEBUG=1 when run psalm:

PSALM_ALLOW_XDEBUG=1 path/to/psalm --no-cache

For more information, see xdebug section at https://psalm.dev/docs/running_psalm/plugins/authoring_plugins/

from psalm.

weirdan avatar weirdan commented on June 25, 2024

My understanding is that the parser (CommentAnalyzer::splitDocLine()) skips from // until \n. But specifically for type aliases, before calling the parser, we remove all newlines:

$type_string = str_replace("\n", '', implode('', $var_line_parts));
try {
$type_string = CommentAnalyzer::splitDocLine($type_string)[0];
} catch (DocblockParseException $e) {
throw new DocblockParseException($type_string . ' is not a valid type: '.$e->getMessage());
}

from psalm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.