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 finds error #137

Open
florisluiten opened this issue Feb 28, 2023 · 1 comment
Open

Psalm finds error #137

florisluiten opened this issue Feb 28, 2023 · 1 comment

Comments

@florisluiten
Copy link

We run into issues when using the snowplow tracker when we run psalm on our code. This yields an error, that we cannot fix in our own code but relies on the vendor code (of snowplow-tracker)

STR

Make a new project, run composer require snowplow/snowplow-tracker vimeo/psalm. Create a new source file src/MyEmitter.php with the following contents:

<?php

declare(strict_types=1);

use Snowplow\Tracker\Emitters\SyncEmitter;
use Snowplow\Tracker\Subject;
use Snowplow\Tracker\Tracker;

final class SnowplowTrackerFactory
{
    public function method(): Tracker {
        $emitter = new SyncEmitter('http://example.com', 'https');

        return new Tracker($emitter, new Subject(), 'whatever', 'app-id');
    }
}

Now run ./vendor/bin/psalm --init followed by ./vendor/bin/psalm, and then ./vendor/bin/psalm again (the second call uses the cache, that is critical in this case).

What I expect that psalm does not fail, for there is no error in my code. However, it fails because it is unable to determine the type.

When I apply the following patch:

diff --git a/vendor/snowplow/snowplow-tracker/src/Tracker.php b/vendor/snowplow/snowplow-tracker/src/Tracker.php
index d9ffa25..c1d3097 100644
--- a/vendor/snowplow/snowplow-tracker/src/Tracker.php
+++ b/vendor/snowplow/snowplow-tracker/src/Tracker.php
@@ -36,7 +36,7 @@ class Tracker extends Constants {
     /**
      * Constructs a new tracker object with emitter(s) and a subject.
      *
-     * @param emitter|array $emitter - Emitter object, used for sending event payloads to for processing
+     * @param Emitter|array $emitter - Emitter object, used for sending event payloads to for processing
      * @param subject $subject - Subject object, contains extra information which is parcelled with the event
      * @param string|null $namespace
      * @param string|null $app_id

psalm no longer returns failures.

Environment is linux, might be relevant since this is an issue with casing and linux have a case-sensitive filesystem by default. Also see #136

@kuba-end
Copy link

kuba-end commented Feb 20, 2025

Hi guys, two years have passed... Did you investigated this bug? Its annoying and require really small changes to fix it.

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

2 participants