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

MissingPropertyType on third party code (ignoreFiles directory) #2388

Closed
leocavalcante opened this issue Nov 28, 2019 · 4 comments
Closed

MissingPropertyType on third party code (ignoreFiles directory) #2388

leocavalcante opened this issue Nov 28, 2019 · 4 comments

Comments

@leocavalcante
Copy link
Contributor

leocavalcante commented Nov 28, 2019

lib/third-party.php
class ThirdPartyCode
{
    public $foo;
}
src/index.php
require_once 'lib/third-party.php';

$bar = new ThirdPartyCode();

/** @var int $baz */
$baz = $bar->foo;
ERROR: MissingPropertyType - src\index.php:8:8 - Property ThirdPartyCode::$foo does not have a declared type
$baz = $bar->foo
<?xml version="1.0"?>
<psalm
    totallyTyped="true"
    resolveFromConfigFile="true"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="https://getpsalm.org/schema/config"
    xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
    <projectFiles>
        <directory name="src" />
        <ignoreFiles>
            <directory name="vendor" />
            <directory name="lib" />
        </ignoreFiles>
    </projectFiles>

    <issueHandlers>
        <LessSpecificReturnType errorLevel="info" />
    </issueHandlers>
</psalm>

PS: I'm actually getting this on a third party code inside vendor (regular composer package) this is a code sample that reproduces the issue.

PS 2: Again, sorry if this is me doing bad annotations. Does Psalm have a chat (or something) for such trivial questions like that or it is ok to open issues?

@weirdan
Copy link
Collaborator

weirdan commented Nov 28, 2019

Looks like a bug to me. Apparently caused by the fact that the error is reported as originating in src/index.php - thus not filtered out.

@weirdan weirdan added the bug label Nov 28, 2019
@muglug muglug removed the bug label Dec 1, 2019
@muglug
Copy link
Collaborator

muglug commented Dec 1, 2019

Looks like a bug to me. Apparently caused by the fact that the error is reported as originating in src/index.php - thus not filtered out.

Not quite - third-party-code or otherwise, Psalm warns when there’s no property type. I think your best bet is to stub the third-party code, adding property types.

@muglug muglug closed this as completed Dec 1, 2019
@shira-374
Copy link

@muglug It looks like a bug to me as well. I'm using totallyTyped="false", hideExternalErrors="true" and ignoring the whole vendor directory, yet I'm getting errors about missing types on some symfony validator constraint props. I'd expect to just get mixed 😕

@muglug muglug reopened this Mar 6, 2020
@muglug muglug closed this as completed in 51bfc7c Mar 6, 2020
@muglug
Copy link
Collaborator

muglug commented Mar 6, 2020

Yeah, you're right, I was wrong, this is now fixed.

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

4 participants