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
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 filesrc/MyEmitter.php
with the following contents: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:
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 https://github.com/snowplow/snowplow-php-tracker/pull/136