Closed juanfernandoe closed 5 years ago
Constants aren't scoped to the class - they're available throughout the file:
Hi,
I appreciate you taking the time to answer my question.
I have another doubt, how access class scoped psalm-type from another file?
It's not possible, unfortunately - it would introduce a level of indirection that would make the first scanning step much slower.
I understand
Have you any advise to workaround this situation?, because I'm planning to add psalm to an existent project.
I'm very influenced by the Hacklang shapes, so I have array structure across multiples classes.
No workaround that I can think of - Psalm itself copies types in a number of places: https://github.com/vimeo/psalm/search?q=IssueData&unscoped_q=IssueData
If they ever become a language feature (as they are with Hack) it may be possible to use other means to make this performative.
maybe you consider something like Phan Stubs in order to define global psalm-type in a special place, so you can parse global types at the beginning.
Ah yes, Psalm already supports stubs so that should be relatively easy. Created #1386 to track that.
Please allow to access type alias from outside class
output error: Parameter $p has wrong type 'scalar-class-constant', should be 'array<array-key, mixe d>'