Skip to content

Link mapping between container and host machine #6919

@weirdan

Description

@weirdan

Thinking out loud here.

This can be handled either by Psalm itself emitting host paths or terminal emulator converting paths in links to their host counterparts. The latter is outside of our control and I have doubts of its universal support anytime soon. This leaves us with the need to implement it ourselves.

The mapping is both machine and project specific: Alice may have her projects in /home/alice/src/<ProjectName> while Bob keeps them in C:\Users\Bob\Documents\<CompanyName>\<ProjectName>. Some projects will have their container paths rooted in /var/www/, some may use another prefix like /home/web. This dictates the need for what I would call local project configuration. This deviates from single, committed to git, config file Psalm currently uses. Local mapping specification would have to be .gitignore-d. There are two options currently supported by Psalm:

  • Commit psalm.xml.dist and .gitignore psalm.xml. Developers working on a project would have to copy psalm.xml.dist to psalm.xml and add their path mapping there. Pros: easy to understand, familiar approach used by many tools. Cons: developers would have to update their psalm.xml when upstream psalm.xml.dist changes.
  • Commit psalm.xml that uses XInclude to include file containing path mapping. The <xi:include> would have to have <xi:fallback> element to prevent errors in CI (where local project mapping file is absent). The mapping file would have to be .gitignored. Pros: developers don't need to update their config. Cons: setup is a bit more complicated.

Neither of the options require any additional development as they are already available.

As for the configuration format, I envision something like this:

<psalm>
  <directoryMapping>
     <directory from="<absolute prefix>" to="<absolute prefix"/>
  </directoryMapping>
</psalm>

With that said, it can totally be a separate feature we may add later.

Originally posted by @weirdan in #6850 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions