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

Include specifics about invalid type references #8842

Closed
dkarlovi opened this issue Dec 5, 2022 · 3 comments · Fixed by #8996
Closed

Include specifics about invalid type references #8842

dkarlovi opened this issue Dec 5, 2022 · 3 comments · Fixed by #8996

Comments

@dkarlovi
Copy link
Contributor

dkarlovi commented Dec 5, 2022

It's hard to understand WHAT references are actually invalid

https://psalm.dev/r/e582824f31

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/e582824f31
<?php

/**
 * Elastica query object.
 *
 * Creates different types of queries
 *
 * @author Nicolas Ruflin <spam@ruflin.com>
 *
 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html
 * @phpstan-type TCreateQueryArgs = TCreateQueryArgsMatching|AbstractSuggest|Collapse|Suggest
 * @phpstan-type TCreateQueryArgsMatching = AbstractQuery|TRawQuery|self|string|null
 * @phpstan-type TRawQuery = array{
 *     _source?: TSourceArgs,
 *     aggs?: list<AbstractAggregation>,
 *     collapse?: Collapse,
 *     docvalue_fields?: TDocValueFields,
 *     explain?: bool,
 *     from?: int,
 *     highlight?: THighlightArgs,
 *     indices_boost?: array<string, float>,
 *     min_score?: float,
 *     pit?: PointInTime,
 *     post_filter?: AbstractQuery,
 *     post_filter?: AbstractQuery,
 *     query?: AbstractQuery|array<string, array<string, mixed>>,
 *     rescore?: TRescoreArgs,
 *     script_fields?: ScriptFields,
 *     size?: int,
 *     sort?: TSortArgs,
 *     stored_fields?: TStoredFields,
 *     suggest?: Suggest,
 *     track_scores?: bool,
 *     track_total_hits?: bool|int,
 *     version?: bool,
 * }
 * @phpstan-type TSortArgs = list<TSortArg>|TSortArrayArg
 * @phpstan-type TSortArg = non-empty-string|TSortArrayArg
 * @phpstan-type TSortArrayArg = array<string, string>|array<string, array{
 *     order?: non-empty-string,
 *     mode?: non-empty-string,
 *     numeric_type?: non-empty-string,
 *     nested?: array{path: non-empty-string, filter?: array<mixed>, max_children?: int, nested?: array<mixed>},
 *     missing?: non-empty-string,
 *     unmapped_type?: non-empty-string,
 * }>|array{_geo_distance: array<string, mixed>}
 * @todo: improve THighlightArgs https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html
 * @phpstan-type THighlightArgs = array<mixed>
 * @phpstan-type TStoredFields = list<string>
 * @todo: improve TDocValueFields https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-docvalue-fields
 * @phpstan-type TDocValueFields = array<mixed>
 * @phpstan-type TRescoreArgs = QueryRescore|list<QueryRescore>
 * @phpstan-type TSourceArgs = non-empty-string|list<non-empty-string>|array{includes?: list<non-empty-string>, excludes?: list<non-empty-string>}|false
 */
class Query
{
}

abstract class AbstractQuery
{}
abstract class AbstractSuggest
{}
abstract class AbstractAggregation
{}
class Collapse
{}
class Suggest
{}
class ScriptFields
{}
class PointInTime
{}
Psalm output (using commit 1cd10c3):

ERROR: InvalidDocblock - 55:1 - @psalm-type TCreateQueryArgs contains invalid references

ERROR: InvalidDocblock - 55:1 - @psalm-type TCreateQueryArgsMatching contains invalid references

ERROR: InvalidDocblock - 55:1 - @psalm-type TRawQuery contains invalid references

ERROR: InvalidDocblock - 55:1 - @psalm-type TSortArgs contains invalid references

ERROR: InvalidDocblock - 55:1 - @psalm-type TSortArg contains invalid references

@weirdan
Copy link
Collaborator

weirdan commented Dec 23, 2022

With #8996 it would read:

SEVERITY LINE ISSUE DESCRIPTION
ERROR 55 InvalidDocblock @psalm-type TCreateQueryArgs contains invalid reference: Invalid type alias TCreateQueryArgsMatching provided
ERROR 55 InvalidDocblock @psalm-type TCreateQueryArgsMatching contains invalid reference: Invalid type alias TRawQuery provided
ERROR 55 InvalidDocblock @psalm-type TRawQuery contains invalid reference: Invalid type alias TSourceArgs provided
ERROR 55 InvalidDocblock @psalm-type TSortArgs contains invalid reference: Invalid type alias TSortArg provided
ERROR 55 InvalidDocblock @psalm-type TSortArg contains invalid reference: Invalid type alias TSortArrayArg provided

It won't tell you why it's invalid, though.

@dkarlovi
Copy link
Contributor Author

Thanks @weirdan! 🎉

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.

2 participants